답안 #1066203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066203 2024-08-19T16:20:59 Z NemanjaSo2005 Board Game (JOI24_boardgame) C++17
3 / 100
29 ms 5140 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=5e4+5;
vector<int> graf[maxn];
ll N,M,K,poz[maxn],res[maxn];
string stop;
void solve1(){
   int poc=poz[1];
   for(int i=1;i<=N;i++)
      res[i]=1e18;
   queue<pair<int,int>> Q;
   Q.push({poc,0});
   while(Q.size()){
      auto x=Q.front();
      Q.pop();
      int tren=x.first;
      int d=x.second;
      if(res[tren]!=1e18)
         continue;
      res[tren]=d;
      for(int y:graf[tren])
         Q.push({y,d+1});
   }
   for(int i=1;i<=N;i++)
      cout<<res[i]<<"\n";
}
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cin>>N>>M>>K;
   while(M--){
      int a,b;
      cin>>a>>b;
      graf[a].push_back(b);
      graf[b].push_back(a);
   }
   cin>>stop;
   stop="0"+stop+"0000";
   for(int i=0;i<stop.size();i++)
      stop[i]-='0';
   for(int i=1;i<=K;i++)
      cin>>poz[i];
   bool hasstop=false;
   for(int i=1;i<=N;i++)
      if(stop[i])
         hasstop=true;
   if(hasstop==false){
      solve1();
      return 0;
   }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |    for(int i=0;i<stop.size();i++)
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1652 KB Output is correct
2 Correct 11 ms 3804 KB Output is correct
3 Correct 29 ms 5140 KB Output is correct
4 Correct 15 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 3884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 3884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1652 KB Output is correct
2 Correct 11 ms 3804 KB Output is correct
3 Correct 29 ms 5140 KB Output is correct
4 Correct 15 ms 4444 KB Output is correct
5 Incorrect 1 ms 1628 KB Output isn't correct
6 Halted 0 ms 0 KB -