답안 #112074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
112074 2019-05-17T08:41:44 Z AMO5 Memory 2 (JOI16_memory2) C++
100 / 100
3 ms 1408 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "Memory2_lib.h"

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end() 

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

long long INF=numeric_limits<long long>::max();

int vis[1011],p[1011];
int adj[505][505];
vector<int> pos[55];
/*
int Flip(int a, int b)
{
	cout << a << " " << b << endl;
	int c;
	cin >> c;
	return c;
}

void Answer(int a, int b, int c)
{
	cout << a << " " << b << " " << c << endl;
	p[a] = c; p[b] = c;
	return; 
}
*/
void query(int a, int b, int c)
{
	//cout << "q " << a << " " << b << " " << c << endl;
	if(adj[a][b]==adj[b][c]&&adj[a][b]==adj[a][c])
	{
	}
	else if(adj[a][b] == adj[a][c]&&!vis[a])
	{
		int val = adj[a][b];
		pos[val].pb(a);
		vis[a] = 1;
	}
	else if(adj[a][b] == adj[b][c]&&!vis[b])
	{
		int val = adj[a][b];
		pos[val].pb(b);
		vis[b] = 1;
	}
	else if(adj[a][c] == adj[b][c]&&!vis[c])
	{
		int val = adj[a][c];
		pos[val].pb(c);
		vis[c] = 1;
	}
	return;
}

void Solve(int T, int N){
	int n = N; N*=2;
	memset(vis,0,sizeof(vis));
	memset(adj,-1,sizeof(adj));
	for(int i = 0; i < N; i++)
	{
		if(vis[i])continue;
		for(int j = i+1; j < N; j++)
		{
			if(vis[j]||vis[i])continue;
			if(adj[i][j]==-1)adj[i][j] = Flip(i,j);
			for(int k = j+1; k < N; k++)
			{
				if(vis[k]||vis[j]||vis[i])continue;
				if(adj[i][k]==-1)adj[i][k] = Flip(i,k);
				if(adj[j][k]==-1)adj[j][k] = Flip(j,k);
				query(i,j,k);
			}
		}
	}
	/*
	for(int i = 0; i < n; i++)
	{
		cout << i << " --- ";
		for(int j = 0; j < pos[i].size(); j++){
			cout << pos[i][j] << " " ;
		}
		cout << endl;
	}
	*/
	//visit smallest 
	int ptr = -1;
	for(int i = 0; i < n; i++)
	{
		if(pos[i].empty())
		{
			ptr = i;
			break;
		}
	}
	
	for(int i = 0; i < N; i++)
	{
		if(!vis[i])pos[ptr].pb(i);
	}
	
	for(int i = 0; i < n; i++)
	{
		Answer(pos[i][0],pos[i][1],i);
	}
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1280 KB Output is correct
2 Correct 3 ms 1280 KB Output is correct
3 Correct 1 ms 1280 KB Output is correct
4 Correct 3 ms 1408 KB Output is correct
5 Correct 2 ms 1408 KB Output is correct
6 Correct 2 ms 1408 KB Output is correct
7 Correct 2 ms 1408 KB Output is correct
8 Correct 2 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1280 KB Output is correct
2 Correct 3 ms 1408 KB Output is correct
3 Correct 3 ms 1296 KB Output is correct
4 Correct 2 ms 1408 KB Output is correct
5 Correct 2 ms 1280 KB Output is correct
6 Correct 3 ms 1408 KB Output is correct
7 Correct 2 ms 1408 KB Output is correct
8 Correct 3 ms 1328 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1408 KB Output is correct
2 Correct 2 ms 1408 KB Output is correct
3 Correct 3 ms 1280 KB Output is correct
4 Correct 2 ms 1408 KB Output is correct
5 Correct 2 ms 1280 KB Output is correct
6 Correct 2 ms 1280 KB Output is correct
7 Correct 3 ms 1408 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct