QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#319236 | #3061. Donut Drone | Register_int | WA | 19ms | 12460kb | C++14 | 2.0kb | 2024-02-02 10:43:30 | 2024-02-02 10:43:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e3 + 10;
int n, m;
struct node {
int l, r, p[MAXN];
node operator + (const node &rhs) const {
node res; res.l = l, res.r = rhs.r;
for (int i = 1; i <= n; i++) res.p[i] = rhs.p[p[i]];
return res;
}
} t[MAXN << 2]; int a[MAXN][MAXN], pre[MAXN], suf[MAXN];
inline
int get(int x, int y) {
int v = max({ a[x][y], a[pre[x]][y], a[suf[x]][y] });
if (v == a[x][y]) return x;
if (v == a[pre[x]][y]) return pre[x];
if (v == a[suf[x]][y]) return suf[x];
}
inline
void pushup(int p) {
t[p] = t[p << 1] + t[p << 1 | 1];
}
inline
void upd(int p) {
int l = t[p].l;
for (int i = 1; i <= n; i++) t[p].p[i] = get(i, l);
}
void build(int l, int r, int p) {
t[p].l = l, t[p].r = r;
if (l == r) return upd(p); int mid = l + r >> 1;
build(l, mid, p << 1), build(mid + 1, r, p << 1 | 1), pushup(p);
}
void change(int k, int p) {
if (t[p].l == t[p].r) return upd(p);
int mid = t[p].l + t[p].r >> 1;
change(k, p << 1 | k > mid), pushup(p);
}
int dp[MAXN][31];
void init() {
for (int i = 1; i <= n; i++) dp[i][0] = t[1].p[i];
for (int j = 1; j <= 30; j++) {
for (int i = 1; i <= n; i++) dp[i][j] = dp[dp[i][j - 1]][j - 1];
}
}
int q, x = 1, y = 1;
char opt[10]; int qx, qy, v, w;
int main() {
scanf("%d%d", &n, &m);
for (int i = 2; i <= n; i++) pre[i] = i - 1; pre[1] = n;
for (int i = 1; i < n; i++) suf[i] = i + 1; suf[n] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
}
build(1, m, 1);
for (scanf("%d", &q); q--;) {
scanf("%s", opt);
if (*opt == 'c') {
scanf("%d%d%d", &qx, &qy, &v), a[qx][qy] = v;
change(qy, 1), init();
} else {
scanf("%d", &v);
for (; v && y != m; x = get(x, ++y), v--);
w = v / m, v %= m;
for (int i = 30; ~i; i--) if (w >> i & 1) x = dp[x][i], w ^= 1 << i;
for (; v; x = get(x, y = y % m + 1), v--);
printf("%d %d\n", x, y);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5964kb
input:
4 4 1 2 9 3 3 5 4 8 4 3 2 7 5 8 1 6 4 move 1 move 1 change 1 4 100 move 1
output:
4 2 1 3 1 4
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 7928kb
input:
3 4 10 20 30 40 50 60 70 80 90 93 95 99 3 move 4 change 2 1 100 move 4
output:
3 1 2 1
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 2ms
memory: 5996kb
input:
20 30 8 1 7 4 3 1 2 1 5 5 2 7 6 4 7 1 2 9 1 9 9 9 9 6 4 9 1 6 3 10 7 3 5 6 5 3 5 3 1 9 8 8 7 7 6 7 5 10 9 6 5 3 8 2 7 10 6 8 4 3 6 4 3 1 7 7 6 7 2 7 3 6 8 6 3 2 7 8 10 8 6 5 6 10 2 6 5 10 10 9 2 5 10 9 4 9 3 6 10 8 1 7 3 3 7 3 3 6 7 5 1 1 10 6 8 5 4 2 1 8 5 1 2 8 3 4 2 4 4 9 6 3 1 5 9 1 9 3 8 3 7 10...
output:
19 10 18 19 3 24 3 30 3 2 4 3 3 8 7 14 3 21 2 27 3 7 3 8 6 16 5 17 3 24 2 27 3 29 3 8 7 12 6 16 3 22 3 2 7 12 3 19 1 22 4 25 4 3 3 5 7 12 3 20 1 22 2 24 3 2 6 11 3 20 2 24 4 4 3 5 5 10 6 11 4 18 2 21 3 29 3 2 3 5 4 9 6 16 2 25 1 26 2 1 4 6 7 15 2 24 3 2 7 12 3 19 3 28 5 4 9 11 9 12 11 17 10 19 12 21...
result:
ok 1945 lines
Test #4:
score: 0
Accepted
time: 10ms
memory: 6264kb
input:
50 50 126812431 909179109 607682292 96000160 425314080 189788877 721251789 103560861 114082307 888028612 277663589 257100764 842807257 327052508 652365304 770138116 384723035 680037089 675501229 509497026 174936063 991259231 761329528 658883078 806406343 741076652 973854314 192609094 398064987 65322...
output:
46 21 46 21 1 49 47 20 46 37 1 42 45 35 50 50 2 17 1 43 2 38 2 47 50 50 2 38 50 50 2 26 2 17 2 34 2 21 4 9 3 6 1 2 1 30 2 40 2 21 2 35 2 17 2 31 2 32 4 9 2 42 3 12 4 8 2 31 1 3 2 15 1 48 1 20 1 30 2 17 49 49 2 14 2 4 1 30 1 29 2 40 2 24 1 27 1 36 1 27 49 47 3 6 2 32 3 41 49 48 2 34 3 41 47 22 49 28 ...
result:
ok 502 lines
Test #5:
score: -100
Wrong Answer
time: 19ms
memory: 12460kb
input:
100 191 178 164 436 292 160 15 447 40 415 308 107 456 61 483 370 222 49 178 96 272 359 232 285 356 320 316 56 450 34 30 300 15 53 269 210 271 443 169 387 273 181 175 38 177 167 447 376 252 434 97 334 389 349 216 293 265 227 273 171 351 68 481 430 249 482 117 206 429 359 61 431 207 163 336 329 490 20...
output:
0 140 0 149 0 91 0 19 0 121 0 169 0 51 0 97 0 37 0 37 0 61 0 10 0 13 0 179 0 146 0 8 0 130 0 6 0 158 0 122 0 181 0 140 0 117 0 176 0 133 0 38 0 29 0 68 0 59 0 46 0 124 0 155 0 139 0 143 0 10 0 63 0 184 0 164 0 62 0 57 0 41 0 10 0 84 0 2 0 89 0 119 0 92 0 166 0 7 0 110 0 6 0 97 0 63 0 20 0 43 0 103 0...
result:
wrong answer 1st lines differ - expected: '94 140', found: '0 140'