Submission #140264

#TimeUsernameProblemLanguageResultExecution timeMemory
140264abacabaPlaninarenje (COCI18_planinarenje)C++14
48 / 160
441 ms2168 KiB
#include <bits/stdc++.h> using namespace std; #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define ll long long #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define uset unordered_set #define umap unordered_map #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> const int N = 5e4 + 15; int n, m, dp[N]; vector <int> g[N]; bool used[N]; void dfs(int v, int p = -1) { used[v] = true; for(int to : g[v]) { if(!used[to]) dfs(to, v); if(to != p) { if(v > n) { if(dp[to] == 1) dp[v] = 1; else if(!dp[v] && dp[to]) dp[v] = 2; } else { if(dp[to] == 2) dp[v] = 2; else if(!dp[v] && dp[to]) dp[v] = 1; } } } if(!dp[v]) dp[v] = (v <= n ? 1 : 2); } int main() { cin >> n >> m; for(int i = 1; i <= m; ++i) { int u, v; cin >> u >> v; g[u].pb(v + n); g[v + n].pb(u); } for(int i = 1; i <= n; ++i) { memset(used, 0, sizeof(used)); memset(dp, 0, sizeof(dp)); dfs(i); if(dp[i] == 1) puts("Mirko"); else puts("Slavko"); } 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...