QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#436976#4829. Mark on a Graphbiank230 0ms0kbC++141.6kb2024-06-09 03:59:292024-06-09 03:59:30

Judging History

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

  • [2024-06-09 03:59:30]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-06-09 03:59:29]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define sz(x) int(x.size())
#define all(x) begin(x),end(x)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)
#define dbg(x) cerr<<#x<<": "<<x<<endl

#define fst first
#define snd second
#define pb push_back
#define eb emplace_back

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//const int MAXN = 2e5+5;
//const ll INF = 1e18;
const int MOD = 1e9+7;

template<class x> ostream & operator<<(ostream & out, vector<x> v){
    out<<"[ ";
    for(auto y : v) out<<y<<" ";
    out<<"]";
    return out;
}

template<class a, class b> ostream & operator<<(ostream & out, pair<a, b> p){
    return out<<"("<<p.fst<<", "<<p.snd<<")";
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n,m;
    cin>>n>>m;
    vector<vi> adj(n,vi(n,0));
    vi deg(n,0);
    forn(i,m){
        int u,v;
        cin>>u>>v;
        --u,--v;
        adj[u][v]=adj[v][u]=1;
        deg[u]++,deg[v]++;
    }
    vi p(n);
    iota(all(p),0);
    sort(all(p),[&](int u, int v){ return deg[u]<deg[v]; });
    if(deg[p[n-1]]-deg[p[n-2]]>=5){
        cout<<"ok\n";
        return 0;
    }
    vii edges;
    int k=0;
    forn(i,n) if(!adj[i][p[n-1]]){
        edges.eb(i,p[n-1]);
        if(++k==5) break;
    }
    cout<<k<<'\n';
    forn(i,k) cout<<edges[i].fst+1<<' '<<edges[i].snd+1<<'\n';
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer on the first run

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:

5
1 733
2 733
3 733
4 733
5 733

input:


output:


result:

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