답안 #471848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471848 2021-09-11T07:15:11 Z dennisstar Memory 2 (JOI16_memory2) C++17
10 / 100
1 ms 332 KB
#include "Memory2_lib.h"
#include <bits/stdc++.h>

using namespace std;

void Solve(int t, int n) {
	vector<int> val(2*n, -1);
	vector<vector<int>> st(n);
	priority_queue<int> pq;
	for (int i=0; i<2*n; i++) pq.emplace(i);
	int lx;
	while (pq.size()) {
		int x=pq.top();
		pq.pop();
		while (pq.size()) {
			int y=pq.top();
			pq.pop();
			int r=Flip(x, y);
			if (st[r].size()==2) {
				val[x]=r;
				pq.emplace(y);
				for (auto &i:st[r]) pq.emplace(i);
				for (int i=0; i<n; i++) {
					if (i!=r) for (auto &j:st[i]) val[j]=i;
					st[i].clear();
				}
				break;
			}
			st[r].emplace_back(y);
		}
		lx=x;
	}
	for (int i=0; i<2*n; i++) if (val[i]!=-1) st[val[i]].emplace_back(i);
	for (int i=0; i<n; i++) {
		if (st[i].size()==1) st[i].emplace_back(lx);
		Answer(st[i][0], st[i][1], i);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Wrong Answer[3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Runtime error 1 ms 332 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -