제출 #780922

#제출 시각아이디문제언어결과실행 시간메모리
780922christinelynnZagrade (COI20_zagrade)C++17
100 / 100
757 ms860 KiB
#include<bits/stdc++.h> using namespace std; bool ask(int l, int r) { if((r-l)&1^1) return 0; cout << "? " << l << ' ' << r << endl; bool ret; cin >> ret; return ret; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; stack<int> J; string s; for(int i=0; i<n; i++) s+='-'; for(int i=0; i<n; i++) { if(J.empty()) J.push(i); else { if(ask(J.top()+1, i+1)) s[J.top()]='(', s[i]=')', J.pop(); else J.push(i); } } int sz=(int)J.size() >> 1; while(!J.empty()) { if(sz) s[J.top()]='(', sz--; else s[J.top()]=')'; J.pop(); } cout << "! " << s << '\n'; return 0; }

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

zagrade.cpp: In function 'bool ask(int, int)':
zagrade.cpp:4:11: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
    4 |   if((r-l)&1^1) return 0;
      |      ~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...