Submission #1110203

# Submission time Handle Problem Language Result Execution time Memory
1110203 2024-11-09T01:57:50 Z vjudge1 Board Game (JOI24_boardgame) C++17
3 / 100
26 ms 4448 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
string s;
int f[60000];
vector<int>a[60000];
queue<int>q;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen("c.INP","r")){
        freopen("c.INP","r",stdin);
        freopen("c.OUT","w",stdout);
    }
    cin >>n>>m>>k;
    while(m--){
        int x,y;
        cin >>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        f[i]=-1;
    }
    cin>>s;
    int x;
    cin >>x;
    f[x]=0;
    q.push(x);
    for(int i=1;i<k;i++){
        cin >>x;
    }
    while(!q.empty()){
        int i=q.front();
        q.pop();
        for(auto o:a[i]){
            if(f[o]==-1){
                f[o]=f[i]+1;
                q.push(o);
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout <<f[i]<<'\n';
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         freopen("c.INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen("c.OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1872 KB Output is correct
2 Correct 13 ms 3664 KB Output is correct
3 Correct 20 ms 4000 KB Output is correct
4 Correct 18 ms 4448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 4432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 4432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1872 KB Output is correct
2 Correct 13 ms 3664 KB Output is correct
3 Correct 20 ms 4000 KB Output is correct
4 Correct 18 ms 4448 KB Output is correct
5 Incorrect 3 ms 1872 KB Output isn't correct
6 Halted 0 ms 0 KB -