# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
716462 | Iliya | Love Polygon (BOI18_polygon) | C++17 | 227 ms | 14260 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
vector<int> Adj[N];
int n, ts, cnt;
map<string, int> MP;
vector<int> res;
bool Mark[N];
void DFS(int v) {
cnt++;
Mark[v] = true;
for (int u : Adj[v])
if (!Mark[u]) DFS(u);
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
string s, t;
cin >> s >> t;
if (!MP[s]) MP[s] = ++ts;
if (!MP[t]) MP[t] = ++ts;
Adj[MP[s]].push_back(MP[t]);
}
for (int i = 1; i <= n; i++) {
if (!Mark[i]) {
cnt = 0;
DFS(i);
res.push_back(cnt);
}
}
if (n & 1)
return cout << "NO" << '\n', 0;
int odd = 0;
int ans = 0;
for (int x : res) {
ans += x / 2;
if (x & 1) odd;
}
ans += odd / 2;
cout << ans << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |