Submission #651086

# Submission time Handle Problem Language Result Execution time Memory
651086 2022-10-17T02:34:58 Z tuanvip870 Zagrade (COI20_zagrade) C++14
71 / 100
1020 ms 716 KB
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#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); }
*/

const int N = 1e5 + 1;
int n, k;
stack<int> Q;
int ask (int l, int r) {
	cout << "? " << l << " " << r << endl;
	int m; cin >> m;
	return m;
}
char res[N];

int main()
{
	ios_base::sync_with_stdio(0);
	// freopen("TEST.inp", "r", stdin);
	// freopen("TEST.out", "w", stdout);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	Q.push(1);
	res[1] = '(';
	for (int i = 2; i <= n; ++i) {
		if (!Q.empty() && ask(Q.top(), i)) {
			res[i] = ')';
			Q.pop();
		}
		else {
			res[i] = '(';
			Q.push(i);
		}
	}
	cout << "! ";
	for (int i = 1; i <= n; ++i) cout << res[i];
	cout << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 14 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 6 ms 260 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
8 Correct 11 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 342 ms 608 KB Output is correct
3 Correct 543 ms 520 KB Output is correct
4 Correct 456 ms 392 KB Output is correct
5 Correct 543 ms 504 KB Output is correct
6 Correct 1020 ms 576 KB Output is correct
7 Correct 787 ms 716 KB Output is correct
8 Correct 677 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -