답안 #880815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880815 2023-11-30T05:48:36 Z vjudge1 Love Polygon (BOI18_polygon) C++17
0 / 100
70 ms 15556 KB
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

const int N = 1e5 + 10;

int n, t, cnt, ans;
bool mark[N];
vector<int> G[N];
unordered_map<string, int> mp;

void dfs(int v) {
    mark[v] = true;
    cnt++;
    int u = G[v][0];
    while (!mark[u]) cnt++, mark[u] = true, u = G[u][0];
    return;
}

int main() {
    ios:: sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        string u, v;
        cin >> u >> v;
        if (mp[u] == 0) mp[u] = ++t;
        if (mp[v] == 0) mp[v] = ++t;
        G[mp[u]].pb(mp[v]);
    }
    for (int i = 1; i <= n; i++)
        if (!mark[i]) {
            dfs(i);
            if (cnt ^ 2) ans += (cnt / 2) + (cnt % 2 == 1);
            cnt = 0;
        }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 49 ms 13496 KB Output is correct
5 Correct 50 ms 13444 KB Output is correct
6 Correct 49 ms 13516 KB Output is correct
7 Incorrect 56 ms 15556 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 13584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -