답안 #316989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316989 2020-10-28T21:47:10 Z thecodingwizard Party (POI11_imp) C++11
100 / 100
946 ms 41336 KB
#include <bits/stdc++.h>

using namespace std;

#define pb push_back

bool adj[3000][3000];
int deg[3000];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m; cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; --a; --b;
        deg[a]++; deg[b]++;
        adj[a][b] = 1; adj[b][a] = 1;
    }

    vector<int> A;
    for (int i = 0; i < n; i++) {
        if (deg[i] >= n/3*2-1) {
            bool g = true;
            for (int x : A) {
                if (!adj[i][x]) g = false;
            }
            if (g) A.pb(i);
        }
        if ((int)A.size() == n/3) break;
    }

    if ((int)A.size() != n/3) {
        for (int v : A) deg[v] = -1;
        A.clear();
        for (int i = 0; i < n; i++) {
            if (deg[i] >= n/3*2-1) {
                bool g = true;
                for (int x : A) {
                    if (!adj[i][x]) g = false;
                }
                if (g) A.pb(i);
            }
            if ((int)A.size() == n/3) break;
        }
    }

    for (int x : A) cout << x+1 << " ";
    cout << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 640 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 896 KB Output is correct
2 Correct 16 ms 1792 KB Output is correct
3 Correct 16 ms 1792 KB Output is correct
4 Correct 16 ms 1792 KB Output is correct
5 Correct 16 ms 1792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1536 KB Output is correct
2 Correct 68 ms 3320 KB Output is correct
3 Correct 66 ms 3448 KB Output is correct
4 Correct 62 ms 3328 KB Output is correct
5 Correct 62 ms 3328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2048 KB Output is correct
2 Correct 161 ms 4784 KB Output is correct
3 Correct 163 ms 4736 KB Output is correct
4 Correct 162 ms 4736 KB Output is correct
5 Correct 178 ms 4736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 2944 KB Output is correct
2 Correct 263 ms 5752 KB Output is correct
3 Correct 260 ms 5752 KB Output is correct
4 Correct 250 ms 5632 KB Output is correct
5 Correct 265 ms 5756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 153 ms 4860 KB Output is correct
2 Correct 387 ms 6236 KB Output is correct
3 Correct 336 ms 6144 KB Output is correct
4 Correct 343 ms 6272 KB Output is correct
5 Correct 346 ms 6260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 335 ms 6276 KB Output is correct
2 Correct 504 ms 7160 KB Output is correct
3 Correct 499 ms 7160 KB Output is correct
4 Correct 497 ms 7160 KB Output is correct
5 Correct 491 ms 7160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 440 ms 7160 KB Output is correct
2 Correct 615 ms 7928 KB Output is correct
3 Correct 620 ms 7680 KB Output is correct
4 Correct 607 ms 7680 KB Output is correct
5 Correct 607 ms 7680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 535 ms 7680 KB Output is correct
2 Correct 720 ms 8320 KB Output is correct
3 Correct 763 ms 8320 KB Output is correct
4 Correct 757 ms 8320 KB Output is correct
5 Correct 738 ms 8328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 639 ms 8328 KB Output is correct
2 Correct 870 ms 10744 KB Output is correct
3 Correct 881 ms 38464 KB Output is correct
4 Correct 896 ms 38520 KB Output is correct
5 Correct 905 ms 38408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 829 ms 9200 KB Output is correct
2 Correct 939 ms 41336 KB Output is correct
3 Correct 945 ms 40824 KB Output is correct
4 Correct 937 ms 40956 KB Output is correct
5 Correct 946 ms 40952 KB Output is correct