Submission #19102


Source Code Expand

Copy
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false; for(int i=2;i*i<=n;i++)if(n%i==0)return false; return true;}
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

int N,K;
int a[20];
bool bad[20][20];

bool simulate(void){
	for(int i = 0 ; i < N ; i++) a[i] = i;
	for(int i = 0 ; i < K ; i++){
		int x = rand() % N, y = (x + rand() % (N - 1) + 1) % N;
		swap(a[x],a[y]);
	}
	for(int i = 0 ; i < N ; i++) if( bad[a[i]][a[(i+1)%N]] ) return false;
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	
	int M;
	cin >> N >> M >> K;
	
	for(int i = 0 ; i < M ; i++){
		int x,y;
		cin >> x >> y;
		bad[x][y] = bad[y][x] = true;
	}
	
	clock_t start = clock();
	
	int cnt = 0;
	int iter;
	for(iter = 0 ; ; iter++){
		if( iter % 100000 == 0 ){
			double t = (double)(clock() - start) / CLOCKS_PER_SEC;
			if(t > 9.0) break;
		}
		if(simulate()) cnt++;
	}
	
	cout << cnt << ' ' << iter << endl;
	double ans = (double)cnt / iter;
	printf("%.9f\n",ans);
}

Submission Info

Submission Time
Task D - シャッフル席替え
User kyulidenamida
Language C++ (G++ 4.6.4)
Score 0
Code Size 2280 Byte
Status WA
Exec Time 9111 ms
Memory 824 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
WA × 71
Set Name Test Cases
all 00_mini_01.txt, 00_mini_02.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_rnd_11_01.txt, 01_rnd_11_02.txt, 01_rnd_11_03.txt, 01_rnd_11_04.txt, 01_rnd_11_05.txt, 01_rnd_11_06.txt, 01_rnd_11_07.txt, 01_rnd_11_08.txt, 01_rnd_11_09.txt, 01_rnd_11_10.txt, 01_rnd_11_11.txt, 01_rnd_11_12.txt, 01_rnd_11_13.txt, 01_rnd_11_14.txt, 01_rnd_11_15.txt, 01_rnd_11_16.txt, 01_rnd_11_17.txt, 01_rnd_11_18.txt, 01_rnd_11_19.txt, 01_rnd_11_20.txt, 01_rnd_11_21.txt, 01_rnd_11_22.txt, 01_rnd_7_01.txt, 01_rnd_7_02.txt, 01_rnd_7_03.txt, 01_rnd_7_04.txt, 01_rnd_7_05.txt, 01_rnd_7_06.txt, 01_rnd_7_07.txt, 01_rnd_7_08.txt, 01_rnd_7_09.txt, 01_rnd_7_10.txt, 01_rnd_7_11.txt, 01_rnd_7_12.txt, 01_rnd_7_13.txt, 01_rnd_7_14.txt, 01_rnd_7_15.txt, 01_rnd_7_16.txt, 01_rnd_7_17.txt, 01_rnd_7_18.txt, 01_rnd_7_19.txt, 01_rnd_7_20.txt, 01_rnd_7_21.txt, 01_rnd_7_22.txt, 01_rnd_8_01.txt, 01_rnd_8_02.txt, 01_rnd_8_03.txt, 01_rnd_8_04.txt, 01_rnd_8_05.txt, 01_rnd_8_06.txt, 01_rnd_8_07.txt, 01_rnd_8_08.txt, 01_rnd_8_09.txt, 01_rnd_8_10.txt, 01_rnd_8_11.txt, 01_rnd_8_12.txt, 01_rnd_8_13.txt, 01_rnd_8_14.txt, 01_rnd_8_15.txt, 01_rnd_8_16.txt, 01_rnd_8_17.txt, 01_rnd_8_18.txt, 01_rnd_8_19.txt, 01_rnd_8_20.txt, 01_rnd_8_21.txt, 01_rnd_8_22.txt
Case Name Status Exec Time Memory
00_mini_01.txt WA 9059 ms 792 KB
00_mini_02.txt WA 9077 ms 812 KB
00_sample_01.txt WA 9049 ms 824 KB
00_sample_02.txt WA 9109 ms 784 KB
00_sample_03.txt WA 9032 ms 788 KB
01_rnd_11_01.txt WA 9099 ms 784 KB
01_rnd_11_02.txt WA 9072 ms 788 KB
01_rnd_11_03.txt WA 9039 ms 768 KB
01_rnd_11_04.txt WA 9101 ms 816 KB
01_rnd_11_05.txt WA 9050 ms 792 KB
01_rnd_11_06.txt WA 9070 ms 764 KB
01_rnd_11_07.txt WA 9074 ms 792 KB
01_rnd_11_08.txt WA 9040 ms 792 KB
01_rnd_11_09.txt WA 9111 ms 780 KB
01_rnd_11_10.txt WA 9052 ms 816 KB
01_rnd_11_11.txt WA 9095 ms 788 KB
01_rnd_11_12.txt WA 9095 ms 792 KB
01_rnd_11_13.txt WA 9040 ms 784 KB
01_rnd_11_14.txt WA 9044 ms 768 KB
01_rnd_11_15.txt WA 9091 ms 788 KB
01_rnd_11_16.txt WA 9070 ms 788 KB
01_rnd_11_17.txt WA 9043 ms 824 KB
01_rnd_11_18.txt WA 9037 ms 816 KB
01_rnd_11_19.txt WA 9060 ms 736 KB
01_rnd_11_20.txt WA 9053 ms 788 KB
01_rnd_11_21.txt WA 9052 ms 800 KB
01_rnd_11_22.txt WA 9047 ms 760 KB
01_rnd_7_01.txt WA 9075 ms 820 KB
01_rnd_7_02.txt WA 9087 ms 760 KB
01_rnd_7_03.txt WA 9050 ms 792 KB
01_rnd_7_04.txt WA 9058 ms 800 KB
01_rnd_7_05.txt WA 9047 ms 788 KB
01_rnd_7_06.txt WA 9051 ms 788 KB
01_rnd_7_07.txt WA 9036 ms 796 KB
01_rnd_7_08.txt WA 9048 ms 816 KB
01_rnd_7_09.txt WA 9071 ms 792 KB
01_rnd_7_10.txt WA 9095 ms 764 KB
01_rnd_7_11.txt WA 9109 ms 812 KB
01_rnd_7_12.txt WA 9038 ms 788 KB
01_rnd_7_13.txt WA 9050 ms 792 KB
01_rnd_7_14.txt WA 9060 ms 820 KB
01_rnd_7_15.txt WA 9045 ms 764 KB
01_rnd_7_16.txt WA 9051 ms 796 KB
01_rnd_7_17.txt WA 9060 ms 784 KB
01_rnd_7_18.txt WA 9048 ms 816 KB
01_rnd_7_19.txt WA 9039 ms 780 KB
01_rnd_7_20.txt WA 9040 ms 792 KB
01_rnd_7_21.txt WA 9042 ms 812 KB
01_rnd_7_22.txt WA 9040 ms 792 KB
01_rnd_8_01.txt WA 9041 ms 764 KB
01_rnd_8_02.txt WA 9086 ms 792 KB
01_rnd_8_03.txt WA 9062 ms 792 KB
01_rnd_8_04.txt WA 9049 ms 788 KB
01_rnd_8_05.txt WA 9069 ms 816 KB
01_rnd_8_06.txt WA 9097 ms 784 KB
01_rnd_8_07.txt WA 9087 ms 788 KB
01_rnd_8_08.txt WA 9093 ms 792 KB
01_rnd_8_09.txt WA 9090 ms 784 KB
01_rnd_8_10.txt WA 9067 ms 792 KB
01_rnd_8_11.txt WA 9063 ms 788 KB
01_rnd_8_12.txt WA 9075 ms 824 KB
01_rnd_8_13.txt WA 9033 ms 788 KB
01_rnd_8_14.txt WA 9056 ms 788 KB
01_rnd_8_15.txt WA 9040 ms 820 KB
01_rnd_8_16.txt WA 9059 ms 764 KB
01_rnd_8_17.txt WA 9070 ms 816 KB
01_rnd_8_18.txt WA 9050 ms 812 KB
01_rnd_8_19.txt WA 9059 ms 788 KB
01_rnd_8_20.txt WA 9059 ms 768 KB
01_rnd_8_21.txt WA 9035 ms 788 KB
01_rnd_8_22.txt WA 9044 ms 788 KB