# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
552113 | 2022-04-22T12:40:22 Z | Killer2501 | Zagonetka (COI18_zagonetka) | C++14 | 88 ms | 496 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pll pair<int, pii> #define pii pair<int, int> #define fi first #define se second using namespace std; const int N = 2e2+5; const int M = 17; const int mod = 1e9+7; const ll base = 75; const ll inf = 1e16; int n, m, k, q, a[N], dd[N][N], b[N], d[N], c[N], dp[2][N]; void sol() { cin >> n; for(int i = 1; i <= n; i ++) { cin >> a[i]; b[a[i]] = i; } for(int i = n-1; i; i --) { fill_n(d, n+1, 0); d[i] = 1; for(int j = i+1; j <= n; j ++) { int cnt = 0; for(int p = 1; p <= j; p ++)if(!d[p])c[b[p]] = ++cnt; for(int p = i; p <= n; p ++)if(d[p] || p > j)c[b[p]] = ++cnt; cout << "query "; for(int p = 1; p <= n; p ++)cout << c[p] <<" "; cout << endl; cin >> k; if(!k) { for(int p = 1; p <= n; p ++) { if(dd[j][p] || p == j) { dd[i][p] = 1; d[p] = 1; } } } } } for(int i = 1; i <= n; i ++) { dp[0][i] = i; dp[1][i] = n-i+1; for(int j = 1; j <= n; j ++) { if(b[j] < i && dd[j][a[i]])dp[1][i] = max(dp[1][i], dp[1][b[j]]); if(b[j] < i && dd[a[i]][j])dp[0][i] = min(dp[0][i], dp[0][b[j]]); } for(int j = 1; j < i; j ++) { dp[0][j] += (dp[0][j] >= dp[0][i]); dp[1][j] -= (dp[1][j] <= dp[1][i]); } } cout << "end" << endl; for(int i = 0; i < 2; i ++) { for(int j = 1; j <= n; j ++)cout << dp[i][j] <<" "; cout << endl; } } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define task "tests" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; //cin >> test; while(test -- > 0)sol(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 316 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 336 KB | Output is correct |
2 | Correct | 24 ms | 308 KB | Output is correct |
3 | Correct | 27 ms | 312 KB | Output is correct |
4 | Correct | 33 ms | 308 KB | Output is correct |
5 | Correct | 9 ms | 208 KB | Output is correct |
6 | Correct | 22 ms | 308 KB | Output is correct |
7 | Correct | 4 ms | 208 KB | Output is correct |
8 | Correct | 6 ms | 332 KB | Output is correct |
9 | Correct | 24 ms | 208 KB | Output is correct |
10 | Correct | 13 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 328 KB | Output is correct |
2 | Correct | 3 ms | 336 KB | Output is correct |
3 | Correct | 5 ms | 464 KB | Output is correct |
4 | Correct | 6 ms | 336 KB | Output is correct |
5 | Correct | 2 ms | 324 KB | Output is correct |
6 | Correct | 5 ms | 208 KB | Output is correct |
7 | Correct | 3 ms | 208 KB | Output is correct |
8 | Correct | 5 ms | 208 KB | Output is correct |
9 | Correct | 6 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 208 KB | Output is correct |
11 | Correct | 3 ms | 328 KB | Output is correct |
12 | Correct | 4 ms | 328 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 80 ms | 436 KB | Output is correct |
2 | Correct | 72 ms | 308 KB | Output is correct |
3 | Correct | 50 ms | 328 KB | Output is correct |
4 | Correct | 49 ms | 364 KB | Output is correct |
5 | Correct | 66 ms | 496 KB | Output is correct |
6 | Correct | 88 ms | 332 KB | Output is correct |
7 | Correct | 52 ms | 456 KB | Output is correct |
8 | Correct | 44 ms | 348 KB | Output is correct |
9 | Correct | 76 ms | 472 KB | Output is correct |
10 | Correct | 81 ms | 444 KB | Output is correct |
11 | Correct | 59 ms | 344 KB | Output is correct |
12 | Correct | 62 ms | 312 KB | Output is correct |
13 | Correct | 67 ms | 464 KB | Output is correct |
14 | Correct | 63 ms | 460 KB | Output is correct |
15 | Correct | 78 ms | 340 KB | Output is correct |
16 | Correct | 60 ms | 448 KB | Output is correct |