Submission #773476

#TimeUsernameProblemLanguageResultExecution timeMemory
773476vjudge1Zagrade (COI20_zagrade)C++17
100 / 100
835 ms900 KiB
#include <bits/stdc++.h> using namespace std; void f(){ freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); } int qu(int a, int b){ cout<<"? "<<a+1<<" "<<b+1<<endl; cin>>a; return a; } void solve(){ int n, m; cin >> n >> m; string s; stack<int> q; for(int i=0; i < n; i++) s+='.'; q.push(0); for(int i=1; i<n; i++){ if(!q.size()){ q.push(i); } else if(qu(q.top(), i)){ s[q.top()]='('; s[i]=')'; q.pop(); } else{ q.push(i); } } int p=q.size()/2; while(p--){ s[q.top()]='('; q.pop(); } while(q.size()){ s[q.top()]=')'; q.pop(); } cout<<"! "<<s<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); solve(); }

Compilation message (stderr)

zagrade.cpp: In function 'void f()':
zagrade.cpp:5:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |  freopen("in.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
zagrade.cpp:6:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  freopen("out.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...