Submission #242363

#TimeUsernameProblemLanguageResultExecution timeMemory
242363VimmerPlaninarenje (COCI18_planinarenje)C++14
160 / 160
76 ms5624 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 200101 #define M ll(1e9 + 7) #define inf 1e9 + 1e9 using namespace std; //using namespace __gnu_pbds; typedef long double ld; typedef long long ll; typedef short int si; typedef array <int, 2> a2; //typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; int mt[N]; bool mrk[N]; vector <int> g[N]; bool kuna(int v) { if (mrk[v]) return 0; mrk[v] = 1; for (auto it : g[v]) if (mt[it] == -1 || kuna(mt[it])) {mt[it] = v; return 1;} return 0; } bool gdr(int v) { if (mrk[v]) return 0; mrk[v] = 1; for (auto it : g[v]) if (mt[it] == -1 || gdr(mt[it])) return 1; return 0; } int main() { //freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; y += n; g[x].pb(y); g[y].pb(x); } for (int i = 1; i <= n + n; i++) mt[i] = -1; for (int i = 1; i <= n; i++) { memset(mrk, 0, sizeof(mrk)); kuna(i); } for (int i = n + 1; i <= n + n; i++) if (mt[i] != -1) mt[mt[i]] = i; for (int i = 1; i <= n; i++) if (mt[i] == -1) cout << "Mirko" << endl; else { memset(mrk, 0, sizeof(mrk)); bool gd = gdr(mt[i]); if (gd) cout << "Mirko" << endl; else cout << "Slavko" << endl; } }
#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...