제출 #257662

#제출 시각아이디문제언어결과실행 시간메모리
257662Marlov새로운 문제 (POI13_mor)C++14
10 / 100
3078 ms1160 KiB
/* Code by @marlov */ #include <iostream> #include <fstream> #include <string> #include <sstream> #include <vector> #include <string> #include <cmath> #include <algorithm> #include <iomanip> #include <utility> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <stack> #include <queue> #include <iterator> using namespace std; typedef long long ll; typedef pair<int,int> pi; #define maxN 5005 #define maxK 1000000 #define INF 100000000 int N,M,K; vector<int> adj[maxN]; pair<pi,pi> query[maxK]; bool answer[maxK]; int dist[maxN][2]; void dfs(int cn,int cd){ for(int i=0;i<adj[cn].size();i++){ int nn=adj[cn][i]; if(dist[nn][(cd+1)%2]>cd+1){ dist[nn][(cd+1)%2]=cd+1; dfs(nn,cd+1); } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>N>>M>>K; int u,v; for(int i=0;i<M;i++){ cin>>u>>v; adj[u].push_back(v); adj[v].push_back(u); } for(int i=0;i<K;i++){ if(query[i].first.first>query[i].first.second) swap(query[i].first.first,query[i].first.second); cin>>query[i].first.first>>query[i].first.second>>query[i].second.first; query[i].second.second=i; for(int i=0;i<=N;i++){ dist[i][0]=INF; dist[i][1]=INF; } dist[query[i].first.first][0]=0; dfs(query[i].first.first,0); if(dist[query[i].first.second][query[i].second.first%2]<=query[i].second.first){ answer[query[i].second.second]=true; } } /* sort(query,query+K); int ci=0; while(ci<K){ int thn=query[ci].first.first; for(int i=0;i<=N;i++){ dist[i][0]=INF; dist[i][1]=INF; } dist[thn][0]=0; dfs(thn,0); while(query[ci].first.first==thn){ if(dist[query[ci].first.second][query[ci].second.first%2]<=query[ci].second.first){ answer[query[ci].second.second]=true; } ci++; } } */ for(int i=0;i<K;i++){ if(answer[i]){ cout<<"TAK"<<'\n'; }else{ cout<<"NIE"<<'\n'; } } return 0; } /* stuff you should look for * int overflow, array bounds * special cases (n=1,n=0?) * do smth instead of nothing and stay organized */

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

mor.cpp: In function 'void dfs(int, int)':
mor.cpp:36:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<adj[cn].size();i++){
              ~^~~~~~~~~~~~~~~
#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...