답안 #68828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68828 2018-08-18T17:03:58 Z reality Memory 2 (JOI16_memory2) C++17
0 / 100
4 ms 964 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) {
	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;
			}
		}
		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[C] = 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 3 ms 484 KB Output is correct
3 Runtime error 4 ms 724 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 820 KB Output is correct
2 Correct 3 ms 820 KB Output is correct
3 Runtime error 4 ms 824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -