Submission #367725

#TimeUsernameProblemLanguageResultExecution timeMemory
367725arnold518Zagrade (COI20_zagrade)C++14
71 / 100
1256 ms6964 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, Q; map<pii, int> MM; bool query(int l, int r) { if(MM.find({l, r})!=MM.end()) return MM[{l, r}]; printf("? %d %d\n", l, r); fflush(stdout); int t; scanf("%d", &t); MM[{l, r}]=t; return t; } char ans[MAXN+10]; int main() { scanf("%d%d", &N, &Q); vector<int> V; for(int i=1; i<=N; i++) { if(V.empty()) V.push_back(i); else { int t=V.back(); if(query(t, i)) { ans[t]='('; ans[i]=')'; V.pop_back(); } else { V.push_back(i); } } } printf("! %s\n", ans+1); fflush(stdout); }

Compilation message (stderr)

zagrade.cpp: In function 'bool query(int, int)':
zagrade.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
zagrade.cpp: In function 'int main()':
zagrade.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |  scanf("%d%d", &N, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...