QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#319242#3061. Donut DroneRegister_intWA 0ms7972kbC++142.0kb2024-02-02 10:48:402024-02-02 10:48:40

Judging History

你现在查看的是最新测评结果

  • [2024-02-02 10:48:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7972kb
  • [2024-02-02 10:48:40]
  • 提交

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];
			assert(x);
			for (; v; x = get(x, y = y % m + 1), v--);
			printf("%d %d\n", x, y); break;
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7972kb

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

result:

wrong answer 2nd lines differ - expected: '1 3', found: ''