제출 #203294

#제출 시각아이디문제언어결과실행 시간메모리
203294MKopchev새로운 문제 (POI13_mor)C++14
100 / 100
2182 ms27384 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=5e3+42,kmax=1e6+42,inf=1e9+42; int n,m,k; vector<int> adj[nmax]; struct query { int from,to,dist,id; }; query inp[kmax]; bool cmp(query a,query b) { return a.from<b.from; } bool output[kmax]; int dist[nmax][2]; queue< pair<int,bool> > active; void bfs(int start) { for(int i=1;i<=n;i++) { dist[i][0]=inf; dist[i][1]=inf; } active.push({start,0}); dist[start][0]=0; while(active.size()) { pair<int,bool> current=active.front(); active.pop(); int node=current.first; bool type=current.second; //cout<<node<<" "<<type<<" "<<dist[node][type]<<endl; for(auto k:adj[node]) if(dist[node][type]+1<dist[k][!type]) { dist[k][!type]=dist[node][type]+1; active.push({k,!type}); } } } int main() { scanf("%i%i%i",&n,&m,&k); int u,v; for(int i=1;i<=m;i++) { scanf("%i%i",&u,&v); adj[u].push_back(v); adj[v].push_back(u); } for(int i=1;i<=k;i++) { scanf("%i%i%i",&inp[i].from,&inp[i].to,&inp[i].dist); inp[i].id=i; } sort(inp+1,inp+k+1,cmp); int pointer=1; for(int i=1;i<=n;i++) { bfs(i); while(inp[pointer].from==i) { if(dist[inp[pointer].to][inp[pointer].dist%2]<=inp[pointer].dist) { if(dist[inp[pointer].to][inp[pointer].dist%2]==0&&adj[inp[pointer].to].size()==0)output[inp[pointer].id]=0; else output[inp[pointer].id]=1; } pointer++; } } for(int i=1;i<=k;i++) if(output[i])printf("TAK\n"); else printf("NIE\n"); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

mor.cpp: In function 'int main()':
mor.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
mor.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&u,&v);
         ~~~~~^~~~~~~~~~~~~~
mor.cpp:66:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i%i",&inp[i].from,&inp[i].to,&inp[i].dist);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...