Macros 더보기 #include #define REP(i,a,b) for (auto i = (a); i sync_with_stdio(0); int t; cin >> t; while (t--) solution(); } A. Spy Detected! 구현 포인트 - 범위가 작으니 카운트 배열에 때려넣으면 구현이 편해진다! 그냥 뻔한 문젠데 짜증나게 구네요. 더보기 int n; cin >> n; vector cnt(101); REP(i,1,n) { int x; cin >> x; ++cnt[x].first; cnt[x].second = i; } REP(i,1,100) { if (cnt[i].first == 1) { cout n; string x[n]; bool chk = false; pair a, b; RE..
A. Gregor and Cryptography \(P\mod a=P\mod b\) \(2\le a> n; string x, y; cin >> x >> y; x = " "+x+" ", y = " "+y+" "; bool chk[n+2] = {0,}; int cnt = 0; REP(i,1,n) { if (y[i] == '1') { if (chk[i-1] == false && x[i-1] == '1') chk[i-1] = true, ++cnt; else if (x[i] == '0') chk[i] = true, ++cnt; else if (chk[i+1] == false && x[i+1] == '1') chk[i+1] = true, ++cnt; } } cout n; SegmentTree gcdtree(n-1,..
A. Three Dice void solution() { cin >> a >> b >> c; cout > s; reverse(ALL(s)); for (char c : s) { cout > n; REP(i,1,n) cin >> a[i]; REP(i,1,n) cin >> b[i]; REP(i,1,n) cin >> c[i]; } void solution() { input(); REP(i,1,n) ++cnt[b[c[i]]]; ll ans = 0; REP(i,1,n) ans += cnt[a[i]]; cout > a >> b >> k; while (a+b) { if (!a || !b) break; if (ll c = C(a-1+b,b); c < k) { k -= c; cout