Submission #651083

#TimeUsernameProblemLanguageResultExecution timeMemory
651083tuanvip870Zagrade (COI20_zagrade)C++14
100 / 100
897 ms1504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef string str; typedef pair <int, int> ii; #define file "TEST" #define st first #define nd second #define pb push_back #define vll vector<ll> #define vi vector<int> #define all(v) (v).begin(), (v).end() #define FOR(i,x,y) for(ll i = x; i <= y; ++i) #define FOS(i,x,y) for(ll i = x; i >= y; --i) #define EACH(i,x) for (auto &(i) : (x)) #define el cout << endl; const ll MOD = 1e9 + 7; #define dbg(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " #define dbge(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]" << endl; /* mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } */ //#define int long long const ll N = 1e5 + 5; int n, k; int ask (int l, int r) { cout << "? " << l << " " << r; el; int m; cin >> m; return m; } char res[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; vector<ll> Q; Q.pb(1); res[1] = '('; FOR(i, 2, n) { if (Q.size() && ask(Q.back(), i)) { res[i] = ')'; Q.pop_back(); } else { res[i] = '('; Q.pb(i); } } ll sz = Q.size() / 2; FOR(i, 0, sz - 1) { res[Q[i]] = ')'; } cout << "! "; FOR(i, 1, n) { cout << res[i]; } el; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...