Submission #1295109

#TimeUsernameProblemLanguageResultExecution timeMemory
1295109ezim1234KOVANICE (COI15_kovanice)C++20
50 / 100
103 ms26800 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define yes cout << "Yes" << "\n" #define no cout << "No" << "\n" #define pb push_back #define F first #define S second typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair <int, int> pii; typedef vector <pii> vii; typedef vector <ll> vi; typedef vector <vi> vvi; template<typename T> void read(vector<T>& v) { for (auto &x : v) cin >> x; } template<typename T> void print(const vector<T>& v) { for (auto &x : v) cout << x << ' '; cout << "\n"; } const ll MAX = 1e6 + 5; const ll MOD = 1e9 + 7; vi adj[MAX]; void solve() { int n, m, v; cin >> n >> m >> v; vi e; vector <string> res(m + 1, "?"); while (v--) { int a, b; char c; cin >> a >> c >> b; if (c == '<') { res[a] = "K1"; res[b] = "K2"; } else { adj[a].pb(b); adj[b].pb(a); e.pb(a); e.pb(b); } } queue <int> q; vi dis(m + 1, -1); for (auto x : e) { if (res[x] != "?") { q.push(x); dis[x] = 0; } } while (q.size()) { int d = q.front(); q.pop(); for (auto x : adj[d]) { if (dis[x] == -1) { res[x] = res[d]; q.push(x); dis[x] = dis[d] + 1; } } } for (int i = 1; i <= m; i++) { cout << res[i] << "\n"; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for (int i = 1; i <= t; i++) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...