답안 #215878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
215878 2020-03-26T12:01:59 Z _7_7_ 카멜레온의 사랑 (JOI20_chameleon) C++14
4 / 100
115 ms 512 KB
#include "chameleon.h"                                      
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e3 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 333;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;
 
 
 



int l[N], n;
bool used[N];
vi v[2], g[N];

int query (int i, int j, int x) {
    vi tmp;

	for (int y = 0; y <= j; ++y)
		tmp.pb(v[i][y]);

	tmp.pb(x);

	return Query(tmp);
}


void ans (int x, int y) {
	assert(used[x] == used[y]);

	if (!used[x])
		Answer(x, y);

	used[x] = used[y] = 1;
}

void f () {
	for (auto x : v[0]) {
		if (query(1, n - 1, x) == n) {
			int l = 0, r = n - 1, j = -1;
			while (l <= r) {
				int mid = (l + r) >> 1;
				if (query(1, mid, x) == mid + 1) {
					j = mid;
					r = mid - 1;
				} else
					l = mid + 1;
			}
			assert(j > -1);
			ans(x, v[1][j]);
		} else {
			vi prv = v[1];
			while (sz(g[x]) < 3) {
				int l = 0, r = sz(v[1]) - 1, j = -1;
				while (l <= r) {
					int mid = (l + r) >> 1;
					if (query(1, mid, x) != mid + 2) {
						j = mid;
						r = mid - 1;
					} else
						l = mid + 1;					 
				}

				assert(j > -1);
				g[x].pb(v[1][j]);
				swap(v[1][j], v[1][sz(v[1]) - 1]);
				v[1].ppb();
			}
			
			v[1] = prv;
			for (int j = 0; j < 3; ++j) {
				vi tmp;
				tmp.pb(x);
				for (int jj = 0; jj < 3; ++jj)
					if (jj != j) 
						tmp.pb(g[x][jj]);

				if (Query(tmp) == 1) {
					l[x] = g[x][j]; 
					break;
				}
			}
			assert(l[x]);
		}
	}
}
 
void Solve(int nn) {
	n = nn;
	for (int i = 1; i <= n + n; ++i)  {
		v[0].pb(i);	
		if (Query(v[0]) != sz(v[0])) {
			v[1].pb(i);
			v[0].ppb();
		}
	}

	if (sz(v[0]) != n)
		return;
	f();
	swap(v[1], v[0]);
	f();
	for (auto x : v[0]) {
		if (used[x])
			continue;
		for (int i = 0; i < 3; ++i) 
			if (g[x][i] == l[x])  {
				swap(g[x][i], g[x][2]);	
				g[x].ppb();
			}
		
		if (l[g[x][0]] == x || used[g[x][0]]) 
			ans(x, g[x][1]);
		else {
		 	assert(l[g[x][1]] == x || used[g[x][1]]);
		 	ans(x, g[x][0]);
		}					
	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 62 ms 448 KB Output is correct
4 Correct 56 ms 384 KB Output is correct
5 Correct 55 ms 384 KB Output is correct
6 Correct 54 ms 384 KB Output is correct
7 Correct 53 ms 384 KB Output is correct
8 Correct 53 ms 384 KB Output is correct
9 Correct 57 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Incorrect 5 ms 384 KB Wrong Answer [7]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Incorrect 5 ms 384 KB Wrong Answer [7]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 115 ms 480 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 62 ms 448 KB Output is correct
4 Correct 56 ms 384 KB Output is correct
5 Correct 55 ms 384 KB Output is correct
6 Correct 54 ms 384 KB Output is correct
7 Correct 53 ms 384 KB Output is correct
8 Correct 53 ms 384 KB Output is correct
9 Correct 57 ms 416 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Incorrect 5 ms 384 KB Wrong Answer [7]
14 Halted 0 ms 0 KB -