Submission #588932

# Submission time Handle Problem Language Result Execution time Memory
588932 2022-07-04T07:55:56 Z Arnch The Potion of Great Power (CEOI20_potion) C++17
0 / 100
3000 ms 4460 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 1e3 + 10, maxn = 1e6 + 10;

int n, d, h[maxn], a[maxn], b[maxn];
bool mark[maxn], mark2[maxn];

void init(int N, int D, int H[]) {
	n = N, d = D;
	for(int i = 0; i < n; i++) h[i] = H[i];
}

void curseChanges(int U, int A[], int B[]) {
	for(int i = 0; i < U; i++) a[i] = A[i], b[i] = B[i];
}

int question(int x, int y, int v) {
	set<int> stx, sty;
	for(int i = 0; i < v; i++) {
		if(a[i] == x && b[i] == y) return 0;
		if(b[i] == x && a[i] == y) return 0;
	
		if(b[i] == x) swap(a[i], b[i]);
		if(a[i] == x) {
			if(mark[b[i]]) {
				stx.erase(b[i]);
				mark[b[i]] = 0;
			}
			else {
				mark[b[i]] = 1;
				stx.insert(b[i]);
			}
			continue;
		}

		if(b[i] == y) swap(a[i], b[i]);
		if(a[i] == y) {
			if(mark2[b[i]]) {
				sty.erase(b[i]);
				mark2[b[i]] = 0;
			}
			else {
				mark2[b[i]] = 1;
				sty.insert(b[i]);
			}
			continue;
		}
	}

	for(int i = 0; i < v; i++) {
		mark[a[i]] = mark[b[i]] = 0;
		mark2[a[i]] = mark2[b[i]] = 0;
	}

	int ans = 1e9;
	for(auto it : stx) 
		for(auto it2 : sty) {
			ans = min(ans, abs(h[it] - h[it2]));
		}


	return ans;

}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3062 ms 4460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 4448 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 588 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -