Submission #651083

# Submission time Handle Problem Language Result Execution time Memory
651083 2022-10-17T01:23:26 Z tuanvip870 Zagrade (COI20_zagrade) C++14
100 / 100
897 ms 1504 KB
#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 time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 11 ms 208 KB Output is correct
5 Correct 11 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 11 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 11 ms 324 KB Output is correct
4 Correct 6 ms 336 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 7 ms 320 KB Output is correct
7 Correct 8 ms 324 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 324 ms 448 KB Output is correct
3 Correct 652 ms 608 KB Output is correct
4 Correct 761 ms 616 KB Output is correct
5 Correct 791 ms 496 KB Output is correct
6 Correct 797 ms 512 KB Output is correct
7 Correct 897 ms 1048 KB Output is correct
8 Correct 736 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 690 ms 1504 KB Output is correct
3 Correct 606 ms 876 KB Output is correct
4 Correct 859 ms 1116 KB Output is correct
5 Correct 643 ms 964 KB Output is correct
6 Correct 808 ms 1056 KB Output is correct
7 Correct 543 ms 788 KB Output is correct
8 Correct 859 ms 520 KB Output is correct