| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 348538 | arnold518 | Link (CEOI06_link) | C++14 | 301 ms | 64108 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 5e5;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int N, K;
int A[MAXN+10];
vector<int> adj[MAXN+10];
int deg[MAXN+10];
int col[MAXN+10];
int vis[MAXN+10], cyc[MAXN+10];
int main()
{
	scanf("%d%d", &N, &K);
	for(int i=1; i<=N; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		A[u]=v;
		adj[v].push_back(u);
		deg[v]++;
	}
	int ans=987654321;
	assert(N<=30);
	for(int i=0; i<(1<<N); i++)
	{
		for(int j=1; j<=N; j++) col[j]=0;
		int now=1;
		for(int p=1; p<=K+1; p++)
		{
			col[now]=1;
			now=A[now];
		}
		for(int j=0; j<N; j++)
		{
			if(i&(1<<j))
			{
				now=j+1;
				for(int p=1; p<=K; p++)
				{
					col[now]=1;
					now=A[now];
				}
			}
		}
		bool flag=true;
		for(int j=1; j<=N; j++) if(!col[j]) flag=false;
		if(flag) ans=min(ans, __builtin_popcount(i));
	}
	printf("%d\n", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
