Submission #1123070

#TimeUsernameProblemLanguageResultExecution timeMemory
1123070thangdz2k7Zagrade (COI20_zagrade)C++20
100 / 100
340 ms1132 KiB
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int MaxN = 2e5; const int mod = 1e9 + 7; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} bool ask(int a, int b){ cout << "? " << a + 1 << ' ' << b + 1 << endl; int t; cin >> t; return t; } void solve(){ int n, q; cin >> n >> q; string ans; ans.resize(n); vector <int> stk; for (int i = 0; i < n; ++ i){ if (stk.empty() || !ask(stk.back(), i)){ ans[i] = '('; stk.pb(i); } else { ans[i] = ')'; stk.pop_back(); } } int sz = stk.size(); for (int i = 0; i < sz; ++ i) ans[stk[i]] = i * 2 < sz ? ')' : '('; cout << "! " << ans << endl; } int main(){ if (fopen("pqh.inp", "r")){ freopen("pqh.inp", "r", stdin); freopen("pqh.out", "w", stdout); } int t = 1; // cin >> t; while (t --) solve(); return 0; }

Compilation message (stderr)

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