답안 #935128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935128 2024-02-28T17:27:17 Z freedommo33 카멜레온의 사랑 (JOI20_chameleon) C++17
40 / 100
15 ms 344 KB
#include <bits/stdc++.h>
#include "chameleon.h"
#include <vector>
#define query Query
#define answer Answer
constexpr int M = 1005;
using namespace std;
vector<vector<int>> sasiedzi(M);
vector<vector<int>> g(M);
int syn[M];
bool uzyte[M];

void Solve(int n) {
	for(int i=1; i<=n*2; i++){
		for(int j=1; j<=n*2; j++){
			if(i==j) continue;
			if(query({i, j}) == 1) sasiedzi[i].push_back(j);
		}
	}
	//for(int i=1; i<=2*n; i++){
		//cout<<i<<": ";
		//for(auto j:sasiedzi[i]) cout<<j<<" ";
		//cout<<endl;
	//}
	//cout<<endl;
	for(int i=1; i<=n*2; i++){
		//cout<<"I: "<<i<<" "<<sasiedzi[i].size()<<endl;
		if(sasiedzi[i].size()!=1){
			//cout<<i<<"S: "<<sasiedzi[i][0]<<" "<<sasiedzi[i][1]<<" "<<sasiedzi[i][2]<<endl;
			if(query({i, sasiedzi[i][0], sasiedzi[i][1]})==1) syn[i] = sasiedzi[i][2];
			if(query({i, sasiedzi[i][0], sasiedzi[i][2]})==1) syn[i] = sasiedzi[i][1];
			if(query({i, sasiedzi[i][2], sasiedzi[i][1]})==1) syn[i] = sasiedzi[i][0];
		}
	}
	for(int i=1; i<=n*2; i++){
		if(syn[i]!=0){
			g[i].push_back(syn[i]);
			g[syn[i]].push_back(i);
		}
	}
	//cout<<"XD"<<endl;
	for(int i=1; i<=n*2; i++){
		sort(g[i].begin(), g[i].end());
		if(syn[i]==0){
			if(uzyte[min(i, sasiedzi[i][0])] == 0){
				//cout<<i<<","<<sasiedzi[i][0]<<endl;
				uzyte[min(i, sasiedzi[i][0])] = 1;
				answer(i, sasiedzi[i][0]);
			}
		}
		else{
			if(g[i][0] == sasiedzi[i][0] && g[i][1] == sasiedzi[i][1]){
				if(uzyte[min(i, sasiedzi[i][2])] == 0){
					//cout<<i<<","<<sasiedzi[i][2]<<endl;
					uzyte[min(i, sasiedzi[i][2])] = 1;
					answer(i, sasiedzi[i][2]);
				}
			}
			else if(g[i][0] == sasiedzi[i][0] && g[i][1] == sasiedzi[i][2]){
				if(uzyte[min(i, sasiedzi[i][1])] == 0){
					//cout<<i<<","<<sasiedzi[i][1]<<endl;
					uzyte[min(i, sasiedzi[i][1])] = 1;
					answer(i, sasiedzi[i][1]);
				}
			}
			else if(g[i][0] == sasiedzi[i][1] && g[i][1] == sasiedzi[i][2]){
				if(uzyte[min(i, sasiedzi[i][0])] == 0){
					//cout<<i<<","<<sasiedzi[i][0]<<endl;
					uzyte[min(i, sasiedzi[i][0])] = 1;
					answer(i, sasiedzi[i][0]);
				}
			}
		}
	}
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 15 ms 344 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 14 ms 344 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 15 ms 344 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -