제출 #1120604

#제출 시각아이디문제언어결과실행 시간메모리
1120604coolboy19521KOVANICE (COI15_kovanice)C++17
0 / 100
488 ms524288 KiB
#include"bits/stdc++.h" using namespace std; const int mxN = 300005; struct Dsu { int ar[mxN]; Dsu() { fill(ar, ar + mxN, -1); } int Find(int u) { if (0 > ar[u]) { return u; } else { return ar[u] = Find(ar[u]); } } void Unite(int u, int v) { u = Find(u); v = Find(v); if (ar[u] > ar[v]) { swap(u, v); } ar[u] += ar[v]; ar[v] = u; } } dsu; main() { int N, M, V; cin >> N >> M >> V; int l = -1; int g = -1; for (int i = 0; i < V; i ++) { string S; cin >> S; int sz = S.size(); int a = 0; int ps = 0; for (int i = 0; i < sz; i ++) { if (S[i] == '=' || S[i] == '<') { break; } else { a = a * 10 + S[i] - '0'; } ps = i; } char c = S[ps + 1]; int b = 0; for (int i = ps + 2; i < sz; i ++) { b = b * 10 + S[i] - '0'; } if (c == '=') { dsu.Unite(a, b); } else { l = a, g = b; } } if (-1 == l && -1 == g) { for (int i = 0; i < M; i ++) { cout << '?' << endl; } } else { for (int i = 1; i <= M; i ++) { int u = dsu.Find(i); if (u == dsu.Find(l)) { cout << "K1" << endl; } else if (u == dsu.Find(g)) { cout << "K2" << endl; } else { cout << '?' << endl; } } } }

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

kovanice.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...