Submission #1005081

# Submission time Handle Problem Language Result Execution time Memory
1005081 2024-06-22T07:00:53 Z vjudge1 Party (POI11_imp) C++17
0 / 100
727 ms 50592 KB
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
vector <int> v[3001];
int f[3001][3001];
int type[3001];
int b,r;
void dfs(int i,int cnt){
    if(type[i]!=0) return;
    type[i]=(cnt%2)+2;
    
    if(cnt%2==0) r++;
    else b++;
    
    for(int j:v[i]) dfs(j,cnt+1);
    return;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        f[a][b]=1;
        f[b][a]=1;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i!=j&&f[i][j]==0) v[i].push_back(j);
        }
    }
    for(int i=1;i<=n;i++) if(type[i]==0) dfs(i,0);
    int cnt=n/3;
    if(r>=b){
        for(int i=1;i<=n&&cnt>0;i++){
            if(type[i]==2){
                cout<<i<<" ";
                cnt--;
            }
        }    
    }
    else{
        for(int i=1;i<=n&&cnt>0;i++){
            if(type[i]==3){
                cout<<i<<" ";
                cnt--;
            }
        }    
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2652 KB Nie wszystkie wypisane osoby siê znaja
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4700 KB Nie wszystkie wypisane osoby siê znaja
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 7004 KB Output is correct
2 Incorrect 37 ms 14244 KB Nie wszystkie wypisane osoby siê znaja
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9304 KB Output is correct
2 Incorrect 86 ms 21432 KB Nie wszystkie wypisane osoby siê znaja
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 14428 KB Nie wszystkie wypisane osoby siê znaja
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 79 ms 22608 KB Output is correct
2 Incorrect 166 ms 44112 KB Nie wszystkie wypisane osoby siê znaja
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 138 ms 32848 KB Nie wszystkie wypisane osoby siê znaja
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 177 ms 38224 KB Nie wszystkie wypisane osoby siê znaja
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 388 ms 43244 KB Nie wszystkie wypisane osoby siê znaja
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 487 ms 46564 KB Nie wszystkie wypisane osoby siê znaja
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 727 ms 50592 KB Output is correct
2 Incorrect 679 ms 44712 KB Nie wszystkie wypisane osoby siê znaja
3 Halted 0 ms 0 KB -