Submission #512034

#TimeUsernameProblemLanguageResultExecution timeMemory
512034PoPularPlusPlusTales of seafaring (POI13_mor)C++17
40 / 100
1749 ms131076 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pb(e) push_back(e) #define sv(a) sort(a.begin(),a.end()) #define sa(a,n) sort(a,a+n) #define mp(a,b) make_pair(a,b) #define vf first #define vs second #define ar array #define all(x) x.begin(),x.end() const int inf = 0x3f3f3f3f; const ll mod = 1000000007; const double PI=3.14159265358979323846264338327950288419716939937510582097494459230; bool remender(ll a , ll b){return a%b;} void solve(){ int n , m; cin >> n >> m; int k; cin >> k; vector<int> adj[n + 1]; for(int i = 0; i < m; i++){ int a,b; cin >> a >> b; adj[a].pb(b); adj[b].pb(a); } int dis[n + 1][n + 1][2]; memset(dis,-1,sizeof dis); //cout << "came" << endl; for(int i = 1; i <= n; i++){ dis[i][i][0] = 0; queue<pair<int,int>> q; q.push(mp(i,0)); while(q.size()){ pair<int,int> node = q.front(); q.pop(); for(int j : adj[node.vf]){ if(dis[i][j][(node.vs + 1) % 2] == -1){ dis[i][j][(node.vs + 1) % 2] = dis[i][node.vf][node.vs] + 1; q.push(mp(j,(node.vs + 1)%2)); } } } } //cout << "came" << endl; while(k--){ int u , v , t; cin >> u >> v >> t; if(dis[u][v][t % 2] == -1){ cout << "NIE\n"; } else if(dis[u][v][t % 2] > t){ cout << "NIE\n"; } else cout << "TAK\n"; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen("rblock.in", "r", stdin); //freopen("rblock.out", "w", stdout); //int t;cin >> t;while(t--) solve(); return 0; }
#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...