QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546777 | #4829. Mark on a Graph | luqyou | 0 | 23ms | 11904kb | C++14 | 2.0kb | 2024-09-04 13:31:14 | 2024-09-04 13:31:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define sc second
#define pii pair<int,int>
#define pb push_back
const int maxn=1000+10;
int n,m,f[maxn][maxn],d[maxn],g[maxn][maxn],in[maxn];
mt19937_64 rd(time(0));
int getg(){
for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) g[i][j]=0;
for(int i=1;i<=n;i++) g[i][i]=1,in[i]=0;
int rep=m;
while(rep--){
int u=rd()%n+1,v=rd()%n+1;
while(g[u][v]) u=rd()%n+1,v=rd()%n+1;
g[u][v]=g[v][u]=1,in[u]++,in[v]++;
}
int minn=1e9,mincnt=0;
for(int i=1;i<=n;i++) minn=min(minn,in[i]);
for(int i=1;i<=n;i++) mincnt+=(minn==in[i]);
// cout<<mincnt<<endl;
return mincnt;
}
void solve(){
cin>>n>>m;
for(int i=1,u,v;i<=m;i++) cin>>u>>v,f[u][v]=f[v][u]=1,d[u]++,d[v]++;
int s=0,rep=100;
while(rep--) s+=getg();
s/=100;
int minn=1e9,mini=0;
for(int i=1;i<=n;i++){
if(d[i]<minn) minn=d[i],mini=i;
}
int cnt=0;
for(int i=1;i<=n;i++) cnt+=(d[i]==minn);
for(int i=1;i<=n;i++) minn=min(minn,d[i]);
// cout<<s<<endl;
if(minn==0&&cnt>=s+(m<=2500?5:(m<=3500?3:2))) return cout<<"ok"<<endl,void();
cout<<"mark"<<endl;
vector<pii> res;
priority_queue<pii,vector<pii>,greater<pii> > q;
for(int i=1;i<=n;i++) q.push({d[i],i});
while(q.size()){
int u=q.top().sc;
q.pop();
for(int i=1;i<=n;i++){
if(f[i][u]){
res.pb({i,u});
if(res.size()==5) break;
}
}
if(res.size()==5) break;
}
cout<<res.size()<<endl;
for(pii p:res) cout<<p.fi<<' '<<p.sc<<endl;
}
int main(){
// freopen("graph.in","r",stdin);
// freopen("graph.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t=1;
// cin>>t;
while(t--) solve();
return 0;
}
/*
Samples
input:
output:
THINGS TODO:
妫€鏌reopen锛屽挨鍏舵槸鍚庣紑鍚?
妫€鏌ョ┖闂?
妫€鏌ヨ皟璇曡鍙ユ槸鍚﹀叏閮ㄦ敞閲?
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 23ms
memory: 11904kb
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 812 501 386 655 353 691 817 762 826 862
input:
1000 3555 330 883 295 222 601 286 238 534 446 441 833 706 669 385 656 841 184 286 383 553 86 259 598 372 355 37 167 605 250 582 576 75 693 401 667 500 954 369 380 521 756 363 977 676 920 815 831 175 688 603 282 77 102 821 70 757 292 449 733 87 373 956 67 600 547 348 430 163 547 272 583 975 937 557 2...
output:
ok
result:
ok all right
Test #2:
score: 0
Wrong Answer
time: 20ms
memory: 11820kb
input:
1000 2000 457 335 160 497 464 992 892 255 853 3 308 301 970 363 541 299 89 418 425 128 626 827 603 854 484 874 755 295 607 483 798 552 356 850 320 357 254 940 675 901 168 525 301 636 520 555 773 910 343 701 889 966 218 529 909 950 71 64 682 284 424 138 721 792 670 544 386 72 654 909 725 235 592 437 ...
output:
mark 5 642 6 287 18 977 22 264 53 720 66
input:
1000 1995 547 861 426 320 558 813 342 436 233 97 130 449 679 986 442 718 532 563 149 908 837 63 953 787 469 37 192 732 18 673 227 293 710 987 412 577 900 36 764 63 620 810 845 680 158 952 462 860 348 964 354 419 489 887 636 582 859 187 768 568 648 434 656 230 962 413 658 770 78 414 500 388 5 496 630...
output:
mark 5 704 14 533 31 316 43 233 59 778 66
result:
wrong answer Token "mark" doesn't correspond to pattern "ok"