Submission #213631

# Submission time Handle Problem Language Result Execution time Memory
213631 2020-03-26T09:55:34 Z _7_7_ Chameleon's Love (JOI20_chameleon) C++14
40 / 100
31 ms 2588 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 = 2e3 + 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;
 
 
map < vi, int > Was;
bool used[N];
vi tmp, v[N];
int l[N];

void ans (int x, int y) {
	assert(used[x] == used[y]);
	if (!used[x])
		Answer(x, y);
	used[x] = used[y] = 1;
} 
 
 
 
int query (int x, int y, int z = -1) {
	tmp.clear();
	tmp.pb(x);
	tmp.pb(y);
	
	if (z > -1)
		tmp.pb(z);
 
	sort(all(tmp));
 
	if (Was.count(tmp))
		return Was[tmp];
 
	return Was[tmp] = Query(tmp); 
}
 
 
void Solve(int n) {
	for (int i = 1; i <= n + n; ++i) { 
		if (used[i])
			continue;

		for (int j = 1; j <= n + n; ++j)
			if (j != i && query(i, j) == 1)
				v[i].pb(j);
 
		if (sz(v[i]) == 1) 
			ans(i, v[i][0]);
		else {
			assert(sz(v[i]) == 3);
			for (int j = 0; j < 3; ++j) {
			    int a = -1, b = -1;
				for (int jj = 0; jj < 3; ++jj)
					if (j != jj) {
						if (a == -1)
							a = v[i][jj];
						else
							b = v[i][jj];
					}
 
				if (query(a, b, i) == 1) {
					l[i] = v[i][j];
					break;
				}
				assert(query(a, b, i) == 2);
			}
 
			assert(l[i]);
		}
	}
	
	for (int i = 1; i <= n + n; ++i)
		if (!used[i]) {
			for (int j = 0; j < 3; ++j)
				if (v[i][j] == l[i]) {
					swap(v[i][j], v[i][sz(v[i]) - 1]);
					v[i].ppb();
					break;
				}
 
			assert(sz(v[i]) == 2);
			if (l[v[i][0]] == i || used[v[i][0]]) 
				ans(v[i][1], i); 
			else {
//				assert(l[v[i][1]] == i || used[v[i][1]]);
				ans(v[i][0], i);
			}					
		}
 
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 31 ms 2588 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
11 Correct 7 ms 844 KB Output is correct
12 Correct 9 ms 1024 KB Output is correct
13 Correct 9 ms 1152 KB Output is correct
14 Correct 9 ms 1024 KB Output is correct
15 Correct 7 ms 896 KB Output is correct
16 Correct 9 ms 1024 KB Output is correct
17 Correct 9 ms 1024 KB Output is correct
18 Correct 9 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Incorrect 30 ms 2560 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 31 ms 2588 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -