QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546773 | #4829. Mark on a Graph | luqyou | 0 | 0ms | 4116kb | C++14 | 2.0kb | 2024-09-04 13:23:09 | 2024-09-04 13:23:09 |
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=10;
while(rep--) s+=getg();
s/=10;
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+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: 0
Wrong Answer
time: 0ms
memory: 4116kb
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 0
input:
1000 3560 554 950 217 396 376 466 702 854 18 186 833 50 137 648 739 710 184 95 383 358 175 831 48 355 279 349 167 174 494 970 582 250 506 567 695 500 326 595 253 49 418 368 882 964 292 403 831 643 999 851 125 553 102 506 437 827 726 125 932 719 641 339 948 721 790 770 146 267 749 719 186 465 360 898...
output:
mark 0
result:
wrong answer Token "mark" doesn't correspond to pattern "ok"