Submission #19542


Source Code Expand

Copy
#include<stdio.h>
#include "stdafx.h"
#include<vector>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
	int num,kum,kai;
	scanf("%d%d%d",&num,&kum,&kai);
	vector<int>vec[11];
	for(int i=0;i<kum;i++)
	{
		int za,zb;
		scanf("%d%d",&za,&zb);
		vec[za].push_back(zb);
		vec[zb].push_back(za);
	}
	int ret=0;
	for(int p=0;p<5000000;p++)
	{
		vector<int>ve;
		for(int i=0;i<num;i++)
		{
			ve.push_back(i);
		}
		for(int j=0;j<kai;j++)
		{
			l01:;
			int a=rand()%num;
			int b=rand()%num;
			if(a==b)
			{
				goto l01;
			}
			swap(ve[a],ve[b]);
		}
		int han=1;
		for(int k=0;k<num;k++)
		{
			for(int l=0;l<vec[ve[k]].size();l++)
			{
				if(ve[(k+1)%num]==vec[ve[k]][l])
				{
					han=0;
					break;
				}
			}
		}
		ret+=han;
	}
	printf("%lf\n",double(ret)/5000000.0);
}

Submission Info

Submission Time
Task D - シャッフル席替え
User DEGwer
Language C++ (G++ 4.6.4)
Score 0
Code Size 850 Byte
Status CE

Compile Error

./Main.cpp:2:20: fatal error: stdafx.h: No such file or directory
compilation terminated.