제출 #1148704

#제출 시각아이디문제언어결과실행 시간메모리
1148704Tyx2019Zagrade (COI20_zagrade)C++20
100 / 100
232 ms1356 KiB
#include <bits/stdc++.h> #define int long long #define debug(x) if(1) cout << #x << " is " << x << endl; using namespace std; const int INF = 1e18; void solve(){ int N, Q; cin >> N >> Q; char res[N+5]; for(int i=1;i<=N;i++) res[i] = '?'; int cur = 1; stack<int> stk; stk.push(1); for(int i=2;i<=N;i++){ stk.push(i); if(stk.size() < 2) continue; int b = stk.top(); stk.pop(); int a = stk.top(); stk.pop(); cout << "? " << a << " " << b << endl; int bruh; cin >> bruh; if(bruh == 1){ res[a] = '('; res[b] = ')'; } else{ stk.push(a); stk.push(b); } } int cnt = 0; for(int i=1;i<=N;i++)cnt += (res[i] == '?'); //debug(cnt); int bruh = cnt / 2; cnt = 0; for(int i=1;i<=N;i++){ cnt += (res[i] == '?'); if(res[i] != '?') continue; if(cnt <= bruh) res[i] = ')'; else res[i] = '('; } cout << "! "; for(int i=1;i<=N;i++) cout << res[i]; cout << endl; } main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T = 1; //cin >> T; while(T--) solve(); }

컴파일 시 표준 에러 (stderr) 메시지

zagrade.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...