Submission #1013886

#TimeUsernameProblemLanguageResultExecution timeMemory
1013886vjudge1Tales of seafaring (POI13_mor)C++17
0 / 100
487 ms131072 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<bool> vis(5006); vector<ll> v[5006]; ll dis[5006][5006],win[5006]; bool b[5006][5006]; ll n,m; void bfs(ll i){ queue<pair<ll,ll>> q; q.push({i,0}); bool vi[5006]={}; dis[i][i]=0; b[i][i]=1; vi[i]=1; while(!q.empty()){ pair<ll,ll> x=q.front(); q.pop(); for(int j=0;j<v[x.first].size();j++){ if(!vi[v[x.first][j]]){ vi[v[x.first][j]]=1; dis[i][v[x.first][j]]=x.second+1; b[i][v[x.first][j]]=1; q.push({v[x.first][j],x.second+1}); } else{ if(dis[i][v[x.first][j]]%2!=(dis[i][x.second]+1)%2){ win[v[x.first][j]]=(dis[i][x.second]+1)-dis[i][v[x.first][j]]; } } } } } int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); ll q; cin>>n>>m>>q; for(int i=0;i<m;i++){ ll x,y; cin>>x>>y;x--;y--; v[x].push_back(y); v[y].push_back(x); } for(int i=0;i<n;i++)bfs(i); for(int i=0;i<n;i++){ if(win[i]>0){ for(int j=0;j<n;j++){ if(b[i][j]){ if(win[j]==0||win[j]>win[i])win[j]=win[i]; } } } } while(q--){ ll x,y,d; cin>>x>>y>>d; x--;y--; if(b[x][y]){ if(win[x]+dis[x][y]<=d){ cout<<"TAK\n"; } else if(dis[x][y]<=d&&dis[x][y]%2==d%2){ cout<<"TAK\n"; } else{ cout<<"NIE\n"; } } else{ cout<<"NIE\n"; } } }

Compilation message (stderr)

mor.cpp: In function 'void bfs(ll)':
mor.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for(int j=0;j<v[x.first].size();j++){
      |                     ~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...