Submission #1154338

#TimeUsernameProblemLanguageResultExecution timeMemory
1154338MinhTuan11Zagrade (COI20_zagrade)C++20
100 / 100
228 ms1356 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second const int N = 2e5 + 5; const int K = 1e2 + 5; const int mod = 1e9 + 7; const int inf = 1e18 + 7; #define all(v) (v).begin(), (v).end() #define pii pair<int, int> using namespace std; mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int n, q; stack<int> st; int ask(int l, int r) { cout << "? " << l << ' ' << r << endl; int rep; cin >> rep; return rep; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); if(ifstream("file.inp")){ freopen("file.inp", "r", stdin); freopen("file.out", "w", stdout); } cin >> n >> q; string s(n, '.'); for(int i = 1; i <= n; i++) { if(st.size() == 0) { st.push(i); continue; } int rep = ask(st.top(), i); if(rep == 1) { s[st.top() - 1] = '('; s[i - 1] = ')'; st.pop(); } else { st.push(i); } } int rem = st.size(); for(int i = 1; i <= rem / 2; i++) { s[st.top() - 1] = '('; st.pop(); } for(int i = 1; i <= rem / 2; i++) { s[st.top() - 1] = ')'; st.pop(); } cout << "! " << s << endl; return 0; } // tuntun172

Compilation message (stderr)

zagrade.cpp: In function 'int main()':
zagrade.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen("file.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
zagrade.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen("file.out", "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...