답안 #68832

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68832 2018-08-18T17:10:53 Z reality Memory 2 (JOI16_memory2) C++17
60 / 100
3 ms 1024 KB
#include "Memory2_lib.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

const int N = 128;

int G[N][N];

int get(int x,int y) {
	assert(x != y);
	if (x > y)
		swap(x,y);
	if (G[x][y] == -1)
		G[x][y] = Flip(x,y);
	return G[x][y];
}

int ans[N];

vi pos[N];

void Solve(int T, int NN) {
	int n = NN;
	memset(G,-1,sizeof(G));
	if (n == 1) {
		Answer(0,1,0);
		return;
	}
	int A = 0,B = 1,C = 2;
	for (int i = 3;i < n + n;++i) {
		vi p = {A,B,C,i};
		int who = -1;
		for (int i = 0;i < 4;++i) {
			vi v;
			for (int j = 0;j < 4;++j)
				if (i != j)
					v.pb(get(p[i],p[j]));
			sort(all(v));
			if (v[0] == v.back()) {
				who = i;
				break;
			}
		}
		assert(who != -1);
		ans[p[who]] = get(p[who == 0],p[who]);
		p.erase(p.begin() + who);
		A = p[0];
		B = p[1];
		C = p[2];
	}
	if (get(A,B) == get(A,C)) {
		ans[A] = get(A,B);
		ans[B] = ans[C] = n - 1;
	} else
	if (get(A,B) == get(B,C)) {
		ans[B] = get(A,B);
		ans[A] = ans[C] = n - 1;
	} else {
		ans[C] = get(A,C);
		ans[A] = ans[B] = n - 1;
	}
	for (int i = 0;i < n + n;++i)
		pos[ans[i]].pb(i);
	for (int i = 0;i < n;++i)
		assert(pos[i].size() == 2);
	for (int i = 0;i < n;++i)
		Answer(pos[i][0],pos[i][1],i);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 684 KB Output is correct
4 Correct 3 ms 780 KB Output is correct
5 Correct 3 ms 780 KB Output is correct
6 Correct 2 ms 780 KB Output is correct
7 Correct 3 ms 780 KB Output is correct
8 Correct 3 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 780 KB Output is correct
2 Correct 3 ms 780 KB Output is correct
3 Correct 2 ms 780 KB Output is correct
4 Correct 3 ms 780 KB Output is correct
5 Correct 3 ms 780 KB Output is correct
6 Correct 3 ms 780 KB Output is correct
7 Correct 3 ms 804 KB Output is correct
8 Correct 3 ms 840 KB Output is correct
9 Correct 2 ms 840 KB Output is correct
10 Correct 2 ms 840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -