結果

問題 No.382 シャイな人たち (2)
ユーザー sigma425sigma425
提出日時 2017-09-15 01:56:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7,084 ms / 8,000 ms
コード長 1,684 bytes
コンパイル時間 1,720 ms
コンパイル使用メモリ 150,800 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 17:07:24
合計ジャッジ時間 157,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7,029 ms
4,380 KB
testcase_01 AC 7,031 ms
4,380 KB
testcase_02 AC 7,027 ms
4,384 KB
testcase_03 AC 7,029 ms
4,380 KB
testcase_04 AC 7,031 ms
4,376 KB
testcase_05 AC 7,029 ms
4,380 KB
testcase_06 AC 7,029 ms
4,376 KB
testcase_07 AC 7,030 ms
4,376 KB
testcase_08 AC 7,025 ms
4,376 KB
testcase_09 AC 7,027 ms
4,380 KB
testcase_10 AC 7,027 ms
4,376 KB
testcase_11 AC 7,033 ms
4,376 KB
testcase_12 AC 7,025 ms
4,376 KB
testcase_13 AC 7,084 ms
4,376 KB
testcase_14 AC 7,031 ms
4,376 KB
testcase_15 AC 7,035 ms
4,376 KB
testcase_16 AC 7,029 ms
4,376 KB
testcase_17 AC 7,026 ms
4,376 KB
testcase_18 AC 7,026 ms
4,380 KB
testcase_19 AC 7,033 ms
4,380 KB
testcase_20 AC 7,030 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
struct Timer{
	clock_t st;
	void start(){
		st = clock();
	}
	int ms(){
		return (clock()-st)*1000 / CLOCKS_PER_SEC;
	}
};

typedef long long ll;
ll S;
int next(){
	S = S*12345%1000003;
	return S;
}
int N,P;
bitset<128> E[128];

unsigned long long seed = 1145141919810893ULL;
int xor_rand(){
	seed = seed ^ (seed<<13);
	seed = seed ^ (seed>>7);
	seed = seed ^ (seed<<17);
	return (seed>>33);
}

int main(){
	Timer timer;
	timer.start();

	cin>>S;
	N = next()%120 + 2;
	P = next();
	rep(i,N) for(int j=i+1;j<N;j++) if(next()>=P) E[i].set(j),E[j].set(i);	//1:cannot

	vector<int> p(N);
	rep(i,N) p[i] = i;

	vector<int> ans;

	int prevt = timer.ms();

	while(true){
		int t = timer.ms();
		if(t + (t-prevt) >= 7000) break;
		prevt = t;
		rep(tt,5000){
			bitset<128> B;
			vector<int> tmp;
			rep(j,N) swap(p[j],p[xor_rand()%(j+1)]);
			rep(j,N) if(!B[p[j]]){
				tmp.pb(p[j]);
				B |= E[p[j]];
			}
			if(tmp.size()>ans.size()) ans = tmp;
		}
	}

	if(ans.size()==N){
		puts("-1");
		return 0;
	}
	int K = ans.size();
	cout<<K+1<<endl;
	rep(i,K) cout<<ans[i]+1<<(i==K-1?"\n":" ");

}
0