Submission #1150945

#TimeUsernameProblemLanguageResultExecution timeMemory
1150945dolphyZagrade (COI20_zagrade)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb(a) push_back(a) #define pp pop_back #define mp(a, b) make_pair(a, b) int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; set <int> s; set <int>::iterator x, y, it, it2; bool valid; char bracks[n+1]; memset(bracks, 0, sizeof(bracks)); for (int i=1; i<=n; i++) s.insert(i); x=s.begin(); y=s.begin(); y++; while (y!=s.end()) { cout << "? " << *x << " " << *y << "\n" << flush; cin >> valid; if (valid) { bracks[*x]='('; bracks[*y]=')'; it=s.upper_bound(*y); s.erase(x); s.erase(y); if (s.empty()) break; it2=s.begin(); if (it==it2) { x=it; y=it; y++; } else { y=it; it--; x=it; } } else {x++; y++;} } int cnt=0, cur=0; for (int i=1; i<=n; i++) if (bracks[i]==0) cnt++; cnt/=2; cout << "! " for (int i=1; i<=n; i++) { if (bracks[i]==0) { cur++; if (cur>cnt) cout << "("; else cout << ")"; } else cout << bracks[i]; } cout << "\n"; return 0; }

Compilation message (stderr)

zagrade.cpp: In function 'int32_t main()':
zagrade.cpp:42:17: error: expected ';' before 'for'
   42 |     cout << "! "
      |                 ^
      |                 ;
   43 |     for (int i=1; i<=n; i++) {
      |     ~~~          
zagrade.cpp:43:19: error: 'i' was not declared in this scope; did you mean 'it'?
   43 |     for (int i=1; i<=n; i++) {
      |                   ^
      |                   it