Submission #1005080

# Submission time Handle Problem Language Result Execution time Memory
1005080 2024-06-22T07:00:12 Z vjudge1 Party (POI11_imp) C++17
0 / 100
460 ms 50596 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]==1){
                cout<<i<<" ";
                cnt--;
            }
        }    
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2652 KB Wypisano za ma³o osób
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4700 KB Wypisano za ma³o osób
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7004 KB Output is correct
2 Incorrect 36 ms 14164 KB Wypisano za ma³o osób
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9304 KB Output is correct
2 Incorrect 83 ms 21420 KB Wypisano za ma³o osób
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 14416 KB Wypisano za ma³o osób
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 22864 KB Wypisano za ma³o osób
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 32848 KB Wypisano za ma³o osób
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 38360 KB Wypisano za ma³o osób
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 220 ms 43244 KB Nie wszystkie wypisane osoby siê znaja
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 307 ms 46560 KB Wypisano za ma³o osób
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 451 ms 50596 KB Output is correct
2 Incorrect 460 ms 44880 KB Wypisano za ma³o osób
3 Halted 0 ms 0 KB -