# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
381419 |
2021-03-25T07:39:12 Z |
Vimmer |
Zagrade (COI20_zagrade) |
C++14 |
|
989 ms |
17568 KB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-Ofast")
#define N 200500
#define NN 1005000
#define PB push_back
//#define endl '\n'
#define pri(x) cout << x << endl
#define _ << " " <<
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define M ll(1e9 + 7)
#define F first
#define S second
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//ordered_set se;
void TL()
{
while (1)
{
}
}
int n, q;
unordered_map <int, int> mp[N];
int ask(int l, int r)
{
if (mp[l].find(r) != mp[l].end())
return mp[l][r];
q--;
if (q == -1)
TL();
pri("?" _ l _ r);
int x;
cin >> x;
mp[l][r] = x;
return x;
}
char ans[N];
int ls[N], nx[N];
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("1.in", "r", stdin);
cin >> n >> q;
for (int i = 2; i <= n; i++)
ls[i] = i - 1;
nx[n] = ls[1] = -1;
for (int i = 1; i < n; i++)
nx[i] = i + 1;
for (int i = 1; i <= n; i++)
ans[i] = 'a';
int beg = 1;
while (1)
{
while (beg <= n && ans[beg] != 'a')
beg++;
if (beg > n)
break;
int cur = beg;
bool ft = 0;
while (1)
{
int l = cur, r = nx[cur];
if (r == -1)
break;
if (ans[l] == 'a' && ans[r] == 'a' && ask(l, r))
{
ans[l] = '(';
ans[r] = ')';
int lst = ls[l];
int nxt = nx[r];
if (lst != -1)
nx[lst] = nxt;
if (nxt != -1)
ls[nxt] = lst;
ft = 1;
if (lst != -1)
{
cur = lst;
continue;
}
}
cur = r;
}
if (!ft)
{
for (int i = 1; i <= n; i++)
if (ans[i] == 'a')
ans[i] = ')';
break;
}
}
cout << "! ";
for (int i = 1; i <= n; i++)
cout << ans[i];
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
11372 KB |
Output is correct |
2 |
Correct |
15 ms |
11372 KB |
Output is correct |
3 |
Correct |
22 ms |
11372 KB |
Output is correct |
4 |
Correct |
17 ms |
11372 KB |
Output is correct |
5 |
Correct |
14 ms |
11372 KB |
Output is correct |
6 |
Correct |
17 ms |
11372 KB |
Output is correct |
7 |
Correct |
16 ms |
11372 KB |
Output is correct |
8 |
Correct |
17 ms |
11372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
11372 KB |
Mismatch at position 2. Expected (, found ) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
11372 KB |
Output is correct |
2 |
Correct |
545 ms |
15468 KB |
Output is correct |
3 |
Correct |
989 ms |
17440 KB |
Output is correct |
4 |
Correct |
720 ms |
17568 KB |
Output is correct |
5 |
Correct |
699 ms |
17344 KB |
Output is correct |
6 |
Correct |
815 ms |
17228 KB |
Output is correct |
7 |
Correct |
932 ms |
17260 KB |
Output is correct |
8 |
Correct |
796 ms |
17292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
11372 KB |
Mismatch at position 3. Expected (, found ) |
2 |
Halted |
0 ms |
0 KB |
- |