답안 #588984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
588984 2022-07-04T08:31:58 Z Arnch The Potion of Great Power (CEOI20_potion) C++17
0 / 100
3000 ms 58680 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];
vector<int> pos[maxn], val[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];
		pos[a[i]].push_back(b[i]), pos[b[i]].push_back(a[i]);
	}

	for(int i = 0; i < n; i++) {
		sort(pos[i].begin(), pos[i].end());
		int cnt = 0;
		for(int j = 0; j < pos[i].size(); j++) {
			cnt++;
			if(j == pos[i].size() - 1 || pos[i][j] != pos[i][j + 1]) {
				if(cnt % 2 == 1) val[i].push_back(pos[i][j]);
				cnt = 0;
				continue;
			}
		}
	}
}

int question(int x, int y, int v) {
	int ans = 1e9;
	for(auto it : val[x]) {
		for(auto it2 : val[y]) {
			ans = min(ans, abs(h[it] - h[it2]));
		}
	}

	return ans;
}

Compilation message

potion.cpp: In function 'void curseChanges(int, int*, int*)':
potion.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int j = 0; j < pos[i].size(); j++) {
      |                  ~~^~~~~~~~~~~~~~~
potion.cpp:26:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    if(j == pos[i].size() - 1 || pos[i][j] != pos[i][j + 1]) {
      |       ~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 47260 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 47352 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 58612 KB Output is correct
2 Correct 200 ms 58636 KB Output is correct
3 Correct 122 ms 53124 KB Output is correct
4 Execution timed out 3034 ms 53536 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 153 ms 58680 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 48028 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 47260 KB Incorrect
2 Halted 0 ms 0 KB -