Submission #748482

#TimeUsernameProblemLanguageResultExecution timeMemory
748482mariowongZagrade (COI20_zagrade)C++14
100 / 100
1078 ms916 KiB
#include <bits/stdc++.h> using namespace std; int n,q,ct,x,l,r; char s[100005]; stack <int> st; int main(){ scanf("%d%d",&n,&q); st.push(1); for (int i=2;i<=n;i++){ if (!st.empty()){ printf("? %d %d\n",st.top(),i); fflush(stdout); scanf("%d",&x); if (x == 1){ s[st.top()]='('; s[i]=')'; st.pop(); ct++; } else st.push(i); } else st.push(i); } printf("! "); for (int i=1;i<=n;i++){ if (ct < n/2 && s[i] != ')' && s[i] != '('){ s[i]=')'; ct++; } else if (s[i] != '(' && s[i] != ')') s[i]='('; } for (int i=1;i<=n;i++){ printf("%c",s[i]); } printf("\n"); fflush(stdout); return 0; }

Compilation message (stderr)

zagrade.cpp: In function 'int main()':
zagrade.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d%d",&n,&q);
      |  ~~~~~^~~~~~~~~~~~~~
zagrade.cpp:15:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |    scanf("%d",&x);
      |    ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...