Submission #213608

# Submission time Handle Problem Language Result Execution time Memory
213608 2020-03-26T09:16:00 Z _7_7_ Chameleon's Love (JOI20_chameleon) C++14
0 / 100
34 ms 2560 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];




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) {
			used[i] = used[v[i][0]] = 1;
			Answer(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) {
				Answer(v[i][1], i); 
			 	used[v[i][1]] = 1;
			} else {
				assert(l[v[i][1]] == i);
				Answer(v[i][0], i);
				used[v[i][0]] = 1;
			}					
		}

}
# 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 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 412 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 384 KB Output is correct
8 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 412 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 384 KB Output is correct
8 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 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 34 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 2560 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -