åæ©çãªæ§æ解æåé¡
åé¡æ¦è¦
"|---|-|----|-|-----|" ã®ãããªãæå '-' ãæå '|' 㧠separate ãããæåå ãä¸ããããã
å '-' åºéã® '-' ã®åæ°ãé ã«åºåããã
å¶ç´
èãããã¨
ããã§ã¯ for
æã§è§£ãã¦ã¿ããã次ã®å¤æ°ã管çããã
num
ï¼ä»ã®æç¹ã§ '-' ãé£ç¶ã§ä½åç¶ãã¦ããã
æååãé ã«è¦ã¦ããã次ã®ããã«å¦çããã°è¯ãã
- æå '|' ãæ¥ãã¨ã
num
ã®å¤ãåºåããnum
ã®å¤ã 0 ã«ãã
- æå '-' ãæ¥ãã¨ã
num
ã®å¤ã 1 å¢ãã
æååã®å é ã® '|' ã«ã¤ãã¦ã¯ç¡è¦ãããã
ã³ã¼ã
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int num = 0; for (int i = 1; i < S.size(); i++) { if (S[i] == '|') { cout << num << " "; num = 0; } else { num++; } } cout << endl; }