답안 #439524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439524 2021-06-30T07:39:46 Z K4YAN Political Development (BOI17_politicaldevelopment) C++17
16 / 100
3000 ms 37040 KB
//Be Name Khoda
// 10:55 -> 10:50 shoroo
// 12:05 | 12:05

#include<bits/stdc++.h>
#pragma GCC optimize ("unroll-loops, Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define plll pair<pll, ll>
#define piii pair<pii, int>
#define piiii pair<pii, pii>

const int mxn = 5e3 + 5;
int n, k, q, v, w;
vector<int> dp[mxn][11], kmk;
vector<vector<int>> g[11];
bool edge[mxn][mxn];

void input() {

    int tmp = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> q;
        for(int j = 0; j < q; j++) {
            cin >> v;
            edge[v][i] = edge[i][v] = 1;
            if(i < v) {
                dp[i][2].push_back(tmp);
                dp[v][2].push_back(tmp++);
                g[2].push_back({i, v});
            }
        }
    }

}

void solve() {

    for(int i = 3; i <= k; i++) {
        int tmp = 0;

        for(int j = 0; j < n; j++) {

            for(auto u : g[i - 1]) {

                bool b = true;
                for(auto e : u) {

                    if(edge[j][e] == false) {
                        b = false;
                        break;
                    }

                }

                if(b == false) {
                    continue;
                }
                for(auto e : u) {
                    kmk.push_back(e);
                    dp[e][i].push_back(tmp);
                }
                dp[j][i].push_back(tmp++);
                kmk.push_back(j);
                g[i].push_back(kmk);
                kmk.clear();
            }
        }
        if(int(g[i].size()) == 0) {
            break;
        }
    }

    for(int i = 2; i <= k; i++) {
        if(int(g[i].size()) == 0) {
            cout << i - 1 << endl;
            return;
        }
    }
    cout << k << endl;
    return;

}

int main() {

    ios_base::sync_with_stdio(false);

    input(), solve();

    return 0;

}
/*
5 3
2 1 2
3 0 2 3
3 0 1 4
2 1 4
2 2 3
*/

Compilation message

politicaldevelopment.cpp:6:44: warning: bad option '-f Ofast' to pragma 'optimize' [-Wpragmas]
    6 | #pragma GCC optimize ("unroll-loops, Ofast")
      |                                            ^
politicaldevelopment.cpp:25:12: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
   25 | void input() {
      |            ^
politicaldevelopment.cpp:44:12: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
   44 | void solve() {
      |            ^
politicaldevelopment.cpp:92:10: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
   92 | int main() {
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 2 ms 1612 KB Output is correct
3 Correct 14 ms 23076 KB Output is correct
4 Correct 12 ms 22092 KB Output is correct
5 Correct 13 ms 22112 KB Output is correct
6 Correct 12 ms 19788 KB Output is correct
7 Correct 12 ms 20144 KB Output is correct
8 Correct 1 ms 1612 KB Output is correct
9 Correct 1 ms 1612 KB Output is correct
10 Correct 2 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 2 ms 1612 KB Output is correct
3 Correct 14 ms 23076 KB Output is correct
4 Correct 12 ms 22092 KB Output is correct
5 Correct 13 ms 22112 KB Output is correct
6 Correct 12 ms 19788 KB Output is correct
7 Correct 12 ms 20144 KB Output is correct
8 Correct 1 ms 1612 KB Output is correct
9 Correct 1 ms 1612 KB Output is correct
10 Correct 2 ms 1612 KB Output is correct
11 Correct 14 ms 22092 KB Output is correct
12 Correct 789 ms 22160 KB Output is correct
13 Correct 0 ms 1612 KB Output is correct
14 Correct 852 ms 22172 KB Output is correct
15 Correct 2 ms 1612 KB Output is correct
16 Correct 837 ms 20096 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 834 ms 19824 KB Output is correct
19 Correct 2 ms 1612 KB Output is correct
20 Correct 441 ms 19592 KB Output is correct
21 Correct 464 ms 19660 KB Output is correct
22 Correct 5 ms 1612 KB Output is correct
23 Correct 1004 ms 24564 KB Output is correct
24 Correct 5 ms 1644 KB Output is correct
25 Correct 1053 ms 24900 KB Output is correct
26 Correct 916 ms 23792 KB Output is correct
27 Correct 828 ms 24656 KB Output is correct
28 Correct 1049 ms 23704 KB Output is correct
29 Correct 818 ms 24720 KB Output is correct
30 Correct 1118 ms 24172 KB Output is correct
31 Correct 1075 ms 25540 KB Output is correct
32 Correct 1082 ms 24396 KB Output is correct
33 Correct 1157 ms 25524 KB Output is correct
34 Correct 1131 ms 25448 KB Output is correct
35 Correct 270 ms 13516 KB Output is correct
36 Correct 286 ms 13492 KB Output is correct
37 Correct 331 ms 13516 KB Output is correct
38 Correct 95 ms 7244 KB Output is correct
39 Correct 96 ms 7320 KB Output is correct
40 Correct 1641 ms 26388 KB Output is correct
41 Correct 104 ms 7300 KB Output is correct
42 Correct 1747 ms 26180 KB Output is correct
43 Correct 1864 ms 26240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 1 ms 1612 KB Output is correct
4 Correct 1 ms 1612 KB Output is correct
5 Correct 1 ms 1612 KB Output is correct
6 Correct 1 ms 1612 KB Output is correct
7 Correct 2 ms 1612 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 2 ms 1612 KB Output is correct
10 Correct 2 ms 1612 KB Output is correct
11 Runtime error 5 ms 3020 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 2 ms 1612 KB Output is correct
3 Correct 14 ms 23076 KB Output is correct
4 Correct 12 ms 22092 KB Output is correct
5 Correct 13 ms 22112 KB Output is correct
6 Correct 12 ms 19788 KB Output is correct
7 Correct 12 ms 20144 KB Output is correct
8 Correct 1 ms 1612 KB Output is correct
9 Correct 1 ms 1612 KB Output is correct
10 Correct 2 ms 1612 KB Output is correct
11 Correct 14 ms 22092 KB Output is correct
12 Correct 789 ms 22160 KB Output is correct
13 Correct 0 ms 1612 KB Output is correct
14 Correct 852 ms 22172 KB Output is correct
15 Correct 2 ms 1612 KB Output is correct
16 Correct 837 ms 20096 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 834 ms 19824 KB Output is correct
19 Correct 2 ms 1612 KB Output is correct
20 Correct 441 ms 19592 KB Output is correct
21 Correct 464 ms 19660 KB Output is correct
22 Correct 5 ms 1612 KB Output is correct
23 Correct 1004 ms 24564 KB Output is correct
24 Correct 5 ms 1644 KB Output is correct
25 Correct 1053 ms 24900 KB Output is correct
26 Correct 916 ms 23792 KB Output is correct
27 Correct 828 ms 24656 KB Output is correct
28 Correct 1049 ms 23704 KB Output is correct
29 Correct 818 ms 24720 KB Output is correct
30 Correct 1118 ms 24172 KB Output is correct
31 Correct 1075 ms 25540 KB Output is correct
32 Correct 1082 ms 24396 KB Output is correct
33 Correct 1157 ms 25524 KB Output is correct
34 Correct 1131 ms 25448 KB Output is correct
35 Correct 270 ms 13516 KB Output is correct
36 Correct 286 ms 13492 KB Output is correct
37 Correct 331 ms 13516 KB Output is correct
38 Correct 95 ms 7244 KB Output is correct
39 Correct 96 ms 7320 KB Output is correct
40 Correct 1641 ms 26388 KB Output is correct
41 Correct 104 ms 7300 KB Output is correct
42 Correct 1747 ms 26180 KB Output is correct
43 Correct 1864 ms 26240 KB Output is correct
44 Execution timed out 3093 ms 37040 KB Time limit exceeded
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 2 ms 1612 KB Output is correct
3 Correct 14 ms 23076 KB Output is correct
4 Correct 12 ms 22092 KB Output is correct
5 Correct 13 ms 22112 KB Output is correct
6 Correct 12 ms 19788 KB Output is correct
7 Correct 12 ms 20144 KB Output is correct
8 Correct 1 ms 1612 KB Output is correct
9 Correct 1 ms 1612 KB Output is correct
10 Correct 2 ms 1612 KB Output is correct
11 Correct 14 ms 22092 KB Output is correct
12 Correct 789 ms 22160 KB Output is correct
13 Correct 0 ms 1612 KB Output is correct
14 Correct 852 ms 22172 KB Output is correct
15 Correct 2 ms 1612 KB Output is correct
16 Correct 837 ms 20096 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 834 ms 19824 KB Output is correct
19 Correct 2 ms 1612 KB Output is correct
20 Correct 441 ms 19592 KB Output is correct
21 Correct 464 ms 19660 KB Output is correct
22 Correct 5 ms 1612 KB Output is correct
23 Correct 1004 ms 24564 KB Output is correct
24 Correct 5 ms 1644 KB Output is correct
25 Correct 1053 ms 24900 KB Output is correct
26 Correct 916 ms 23792 KB Output is correct
27 Correct 828 ms 24656 KB Output is correct
28 Correct 1049 ms 23704 KB Output is correct
29 Correct 818 ms 24720 KB Output is correct
30 Correct 1118 ms 24172 KB Output is correct
31 Correct 1075 ms 25540 KB Output is correct
32 Correct 1082 ms 24396 KB Output is correct
33 Correct 1157 ms 25524 KB Output is correct
34 Correct 1131 ms 25448 KB Output is correct
35 Correct 270 ms 13516 KB Output is correct
36 Correct 286 ms 13492 KB Output is correct
37 Correct 331 ms 13516 KB Output is correct
38 Correct 95 ms 7244 KB Output is correct
39 Correct 96 ms 7320 KB Output is correct
40 Correct 1641 ms 26388 KB Output is correct
41 Correct 104 ms 7300 KB Output is correct
42 Correct 1747 ms 26180 KB Output is correct
43 Correct 1864 ms 26240 KB Output is correct
44 Correct 2 ms 1612 KB Output is correct
45 Runtime error 4 ms 3020 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -