# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
241494 | 2020-06-24T09:30:14 Z | marlicu | KOVANICE (COI15_kovanice) | C++14 | 139 ms | 17656 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 5; int n, m, v; int pripada[MAXN]; vector <int> veze[MAXN]; bool ispisan[MAXN]; int vrsta[MAXN]; void init() { for (int i = 1; i <= m; i++) { pripada[i] = i; } } void ispis() { for (int i = 1; i <= m; i++) { cout << pripada[i] << " "; } cout << '\n'; memset(ispisan, 0, sizeof(ispisan)); for (int i = 1; i <= m; i++) { if (ispisan[i]) continue; cout << i << " "; int t = i; while (veze[t].size()) { cout << veze[t][0] << " "; t = veze[t][0]; ispisan[t] = true; } cout << '\n'; ispisan[i] = true; } } void konacan_ispis() { int x; for (int i = 1; i <= m; i++) { x = pripada[i]; if (!vrsta[x]) cout << "?\n"; else cout << "K" << vrsta[x] << "\n"; } } void vaganje() { string s; cin >> s; int a, b = 0; char znak; unsigned t = -1; while (++t < s.size()) { if (s[t] == '=' || s[t] == '<') { znak = s[t]; a = b; b = 0; } else { b *= 10; b += (s[t] - '0'); } } //cout << a << " " << znak << " " << b << '\n'; a = pripada[a]; b = pripada[b]; if (znak == '=') { if (a < b) pripada[b] = a; else pripada[a] = b; } else { veze[a].push_back(b); } //ispis(); } void odredivanje() { vector <int> niz; memset(ispisan, 0, sizeof(ispisan)); for (int i = 1; i <= m; i++) { int t = pripada[i]; if (ispisan[t]) continue; ispisan[t] = true; niz.clear(); niz.push_back(t); while (veze[t].size()) { t = veze[t][0]; ispisan[t] = true; niz.push_back(t); } /* cout << niz.size() << " : "; for (auto x : niz) { cout << x << " "; } cout << '\n'; */ if (niz.size() == n) { for (int j = 0; j < n; j++) { vrsta[niz[j]] = j + 1; } } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> v; init(); for (int i = 0; i < v; i++) { vaganje(); } odredivanje(); konacan_ispis(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 7680 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 50 ms | 12412 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 9088 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 139 ms | 17656 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |