Submission #367726

#TimeUsernameProblemLanguageResultExecution timeMemory
367726arnold518Zagrade (COI20_zagrade)C++14
100 / 100
1124 ms7348 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); } } } for(int i=0; i<V.size()/2; i++) ans[V[i]]=')'; for(int i=V.size()/2; i<V.size(); i++) ans[V[i]]='('; printf("! %s\n", ans+1); fflush(stdout); }

Compilation message (stderr)

zagrade.cpp: In function 'int main()':
zagrade.cpp:50:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for(int i=0; i<V.size()/2; i++) ans[V[i]]=')';
      |               ~^~~~~~~~~~~
zagrade.cpp:51:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  for(int i=V.size()/2; i<V.size(); i++) ans[V[i]]='(';
      |                        ~^~~~~~~~~
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...