답안 #742532

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742532 2023-05-16T12:09:52 Z myrcella 카멜레온의 사랑 (JOI20_chameleon) C++17
40 / 100
19 ms 356 KB
//by szh
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
 
#include "chameleon.h"
 
namespace {
 
vector <int> edge[550];
bool vis[550];
 
}  // namespace
 
void Solve(int N) {
  rep(i,1,2*N+1)
	rep(j,1,i) {
		int cnt = Query({i,j});
		if (cnt==1) edge[i].pb(j),edge[j].pb(i);
	}
	rep(i,1,2*N+1) {
		if (SZ(edge[i])==3) {
			int x = edge[i][0], y = edge[i][1], z = edge[i][2];
			if (Query({i,x,y})==1) edge[i] = {x,y};
			else if (Query({i,x,z})==1) edge[i] = {x,z};
			else {
//				assert(Query({i,y,z})==1);
				edge[i] = {y,z};
			}
		}
	}
	rep(i,1,2*N+1) {
		if (vis[i]) continue;
		if (SZ(edge[i])==1) {
			Answer(i,edge[i][0]);
			vis[i] = vis[edge[i][0]] = 1;
		}
		else {
			assert(SZ(edge[i])==2);
			
			int x = edge[i][0], y = edge[i][1];
			if (vis[y] or SZ(edge[x])==1) {
				Answer(i,x);
				vis[i] = vis[x] = 1;
			}
			else if (vis[x] or SZ(edge[y])==1) {
				Answer(i,y);
				vis[i] = vis[y] = 1;
			}
			else {
				if (edge[x][0]==i or edge[x][1]==i) Answer(i,x),vis[i]=vis[x]=1;
				else assert(edge[y][0]==i or edge[y][1]==i),Answer(i,y),vis[i]=vis[y]=1;
			}
		}
	}
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 19 ms 320 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 2 ms 356 KB Output is correct
17 Correct 2 ms 208 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 19 ms 208 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 19 ms 320 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -