QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#311481#4829. Mark on a Graphxztmax670 17ms24304kbC++141.4kb2024-01-22 14:05:082024-01-22 14:05:09

Judging History

你现在查看的是最新测评结果

  • [2024-01-22 14:05:09]
  • 评测
  • 测评结果:0
  • 用时:17ms
  • 内存:24304kb
  • [2024-01-22 14:05:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5e3+100;
int n,m;
vector<int>g[N];
int vis[N],a[N][N];
int check(vector<int>&st)
{
	int tot=0;
	for(int i=0;i<st.size();i++)for(int j=i+1;j<st.size();j++)if(a[st[i]][st[j]])tot++;
	return tot;
}
void dfs(int x,vector<int>st)
{
	st.push_back(x);vis[x]=1;
	if(check(st)!=st.size()*(st.size()-1)/2)return;
	if(st.size()==5){cout<<"ok"<<endl;exit(0);}
	for(auto y:g[x])if(!vis[y])dfs(y,st);
	st.pop_back();vis[x]=0;
}
signed main()
{
//	freopen("q.in","r",stdin);
	cin>>n>>m;for(int i=1,x,y;i<=m;i++)cin>>x>>y,g[x].push_back(y),g[y].push_back(x),a[x][y]=a[y][x]=1;
	for(int i=1;i<=n;i++)dfs(i,vector<int>{});
	memset(vis,0,sizeof(vis));
	uniform_int_distribution<int>dist(1,n);mt19937 rd(time(0));
	while(1)
	{
		vector<int>p;
		for(int i=1;i<=3;i++)
		{
			int x;while((x=dist(rd))&&vis[x]);
			vis[x]=1;p.push_back(x);
		}
		shuffle(g[p[0]].begin(),g[p[0]].end(),rd);
		shuffle(g[p[1]].begin(),g[p[1]].end(),rd);
		for(auto x:g[p[0]])if(!vis[x]){p.push_back(x),vis[x]=1;break;}
		for(auto x:g[p[1]])if(!vis[x]){p.push_back(x),vis[x]=1;break;}
//		for(auto x:p)cout<<x<<' ';
//		cout<<check(p)<<endl;
		if(check(p)>=5)
		{
			cout<<"mark"<<endl<<10-check(p)<<endl;
			for(int i=0;i<p.size();i++)for(int j=i+1;j<p.size();j++)if(!a[p[i]][p[j]])
				cout<<p[i]<<' '<<p[j]<<endl;
			exit(0);
		}
		for(auto x:p)vis[x]=0;
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 17ms
memory: 24304kb

input:

1000 3560
603 151
415 20
102 569
895 552
678 734
24 614
689 518
440 223
751 919
223 433
711 551
502 634
706 583
812 501
514 535
780 751
720 530
532 384
888 139
864 791
292 675
171 881
30 592
464 557
280 299
654 650
894 335
250 532
792 10
83 969
118 771
579 300
852 983
243 940
957 939
817 889
911 319...

output:

mark
5
399 228
399 536
399 293
228 536
684 293

input:

1000 3565
721 353
295 222
429 542
522 656
682 141
107 833
746 181
656 841
184 189
392 102
559 187
643 633
397 161
180 790
481 180
640 763
782 897
224 873
974 302
521 507
368 691
676 977
113 433
858 583
16 526
726 125
348 806
70 757
464 840
87 733
355 335
232 485
178 201
182 394
201 34
453 528
557 93...

output:

mark
5
186 708
186 357
708 18
708 465
465 357

result:

wrong answer Token "mark" doesn't correspond to pattern "ok"