Submission #416050

# Submission time Handle Problem Language Result Execution time Memory
416050 2021-06-01T21:02:43 Z duality Connecting Supertrees (IOI20_supertrees) C++14
100 / 100
268 ms 24128 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#include "supertrees.h"

int com1[1000],com2[1000],r[1000];
vi vv[1000];
int construct(vector<vector<int> > p) {
    int i,j,n = p.size();
    int c1 = 0,c2 = 0;
    for (i = 0; i < n; i++) {
        for (j = 0; j < i; j++) {
            if (p[i][j] == 3) return 0;
            if (p[i][j] > 0) {
                com1[i] = com1[j];
                break;
            }
        }
        if (j == i) com1[i] = c1++;
        for (j = 0; j < i; j++) {
            if (p[i][j] == 1) {
                com2[i] = com2[j];
                break;
            }
        }
        if (j == i) com2[i] = c2++,vv[com1[i]].pb(i),r[c2-1] = i;
        for (j = 0; j < i; j++) {
            if ((com1[i] == com1[j]) == (p[i][j] == 0)) return 0;
            if ((com2[i] == com2[j]) != (p[i][j] == 1)) return 0;
        }
    }
    vector<vi> b(n,vi(n,0));
    for (i = 0; i < n; i++) {
        if (r[com2[i]] != i) b[i][r[com2[i]]] = b[r[com2[i]]][i] = 1;
    }
    for (i = 0; i < c1; i++) {
        if (vv[i].size() == 2) return 0;
        else if (vv[i].size() > 1) {
            for (j = 0; j < vv[i].size(); j++) {
                b[vv[i][j]][vv[i][(j+1) % vv[i].size()]] = 1;
                b[vv[i][(j+1) % vv[i].size()]][vv[i][j]] = 1;
            }
        }
    }
    build(b);
    return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:92:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |             for (j = 0; j < vv[i].size(); j++) {
      |                         ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 10 ms 1232 KB Output is correct
7 Correct 231 ms 23948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 10 ms 1232 KB Output is correct
7 Correct 231 ms 23948 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 11 ms 1228 KB Output is correct
13 Correct 233 ms 24004 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 5 ms 720 KB Output is correct
17 Correct 101 ms 10124 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 59 ms 6212 KB Output is correct
21 Correct 231 ms 23956 KB Output is correct
22 Correct 246 ms 24004 KB Output is correct
23 Correct 241 ms 24004 KB Output is correct
24 Correct 232 ms 24032 KB Output is correct
25 Correct 99 ms 10128 KB Output is correct
26 Correct 93 ms 10136 KB Output is correct
27 Correct 238 ms 23956 KB Output is correct
28 Correct 230 ms 23964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 11 ms 1224 KB Output is correct
9 Correct 233 ms 24004 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 11 ms 1228 KB Output is correct
13 Correct 268 ms 24112 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 5 ms 716 KB Output is correct
17 Correct 104 ms 10048 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 74 ms 6280 KB Output is correct
22 Correct 233 ms 24056 KB Output is correct
23 Correct 235 ms 24004 KB Output is correct
24 Correct 245 ms 23960 KB Output is correct
25 Correct 105 ms 14148 KB Output is correct
26 Correct 97 ms 10164 KB Output is correct
27 Correct 258 ms 24004 KB Output is correct
28 Correct 240 ms 24004 KB Output is correct
29 Correct 118 ms 14148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 61 ms 6188 KB Output is correct
5 Correct 233 ms 23944 KB Output is correct
6 Correct 247 ms 23956 KB Output is correct
7 Correct 246 ms 23948 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 60 ms 6224 KB Output is correct
10 Correct 239 ms 23944 KB Output is correct
11 Correct 232 ms 23944 KB Output is correct
12 Correct 238 ms 24008 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 58 ms 6276 KB Output is correct
17 Correct 244 ms 23944 KB Output is correct
18 Correct 249 ms 24008 KB Output is correct
19 Correct 246 ms 24128 KB Output is correct
20 Correct 230 ms 24008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 10 ms 1232 KB Output is correct
7 Correct 231 ms 23948 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 11 ms 1228 KB Output is correct
13 Correct 233 ms 24004 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 5 ms 720 KB Output is correct
17 Correct 101 ms 10124 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 59 ms 6212 KB Output is correct
21 Correct 231 ms 23956 KB Output is correct
22 Correct 246 ms 24004 KB Output is correct
23 Correct 241 ms 24004 KB Output is correct
24 Correct 232 ms 24032 KB Output is correct
25 Correct 99 ms 10128 KB Output is correct
26 Correct 93 ms 10136 KB Output is correct
27 Correct 238 ms 23956 KB Output is correct
28 Correct 230 ms 23964 KB Output is correct
29 Correct 2 ms 204 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 11 ms 1224 KB Output is correct
37 Correct 233 ms 24004 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 11 ms 1228 KB Output is correct
41 Correct 268 ms 24112 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 5 ms 716 KB Output is correct
45 Correct 104 ms 10048 KB Output is correct
46 Correct 1 ms 316 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 74 ms 6280 KB Output is correct
50 Correct 233 ms 24056 KB Output is correct
51 Correct 235 ms 24004 KB Output is correct
52 Correct 245 ms 23960 KB Output is correct
53 Correct 105 ms 14148 KB Output is correct
54 Correct 97 ms 10164 KB Output is correct
55 Correct 258 ms 24004 KB Output is correct
56 Correct 240 ms 24004 KB Output is correct
57 Correct 118 ms 14148 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 2 ms 332 KB Output is correct
60 Correct 5 ms 716 KB Output is correct
61 Correct 101 ms 10060 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 320 KB Output is correct
64 Correct 1 ms 324 KB Output is correct
65 Correct 60 ms 6212 KB Output is correct
66 Correct 99 ms 10140 KB Output is correct
67 Correct 97 ms 10180 KB Output is correct
68 Correct 126 ms 10124 KB Output is correct
69 Correct 102 ms 14020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 10 ms 1232 KB Output is correct
7 Correct 231 ms 23948 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 11 ms 1228 KB Output is correct
13 Correct 233 ms 24004 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 5 ms 720 KB Output is correct
17 Correct 101 ms 10124 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 59 ms 6212 KB Output is correct
21 Correct 231 ms 23956 KB Output is correct
22 Correct 246 ms 24004 KB Output is correct
23 Correct 241 ms 24004 KB Output is correct
24 Correct 232 ms 24032 KB Output is correct
25 Correct 99 ms 10128 KB Output is correct
26 Correct 93 ms 10136 KB Output is correct
27 Correct 238 ms 23956 KB Output is correct
28 Correct 230 ms 23964 KB Output is correct
29 Correct 2 ms 204 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 11 ms 1224 KB Output is correct
37 Correct 233 ms 24004 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 11 ms 1228 KB Output is correct
41 Correct 268 ms 24112 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 5 ms 716 KB Output is correct
45 Correct 104 ms 10048 KB Output is correct
46 Correct 1 ms 316 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 74 ms 6280 KB Output is correct
50 Correct 233 ms 24056 KB Output is correct
51 Correct 235 ms 24004 KB Output is correct
52 Correct 245 ms 23960 KB Output is correct
53 Correct 105 ms 14148 KB Output is correct
54 Correct 97 ms 10164 KB Output is correct
55 Correct 258 ms 24004 KB Output is correct
56 Correct 240 ms 24004 KB Output is correct
57 Correct 118 ms 14148 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 324 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 61 ms 6188 KB Output is correct
62 Correct 233 ms 23944 KB Output is correct
63 Correct 247 ms 23956 KB Output is correct
64 Correct 246 ms 23948 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 60 ms 6224 KB Output is correct
67 Correct 239 ms 23944 KB Output is correct
68 Correct 232 ms 23944 KB Output is correct
69 Correct 238 ms 24008 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 1 ms 332 KB Output is correct
72 Correct 1 ms 204 KB Output is correct
73 Correct 58 ms 6276 KB Output is correct
74 Correct 244 ms 23944 KB Output is correct
75 Correct 249 ms 24008 KB Output is correct
76 Correct 246 ms 24128 KB Output is correct
77 Correct 230 ms 24008 KB Output is correct
78 Correct 1 ms 204 KB Output is correct
79 Correct 2 ms 332 KB Output is correct
80 Correct 5 ms 716 KB Output is correct
81 Correct 101 ms 10060 KB Output is correct
82 Correct 1 ms 332 KB Output is correct
83 Correct 1 ms 320 KB Output is correct
84 Correct 1 ms 324 KB Output is correct
85 Correct 60 ms 6212 KB Output is correct
86 Correct 99 ms 10140 KB Output is correct
87 Correct 97 ms 10180 KB Output is correct
88 Correct 126 ms 10124 KB Output is correct
89 Correct 102 ms 14020 KB Output is correct
90 Correct 1 ms 332 KB Output is correct
91 Correct 1 ms 204 KB Output is correct
92 Correct 5 ms 716 KB Output is correct
93 Correct 99 ms 10128 KB Output is correct
94 Correct 1 ms 332 KB Output is correct
95 Correct 2 ms 332 KB Output is correct
96 Correct 1 ms 204 KB Output is correct
97 Correct 25 ms 2708 KB Output is correct
98 Correct 95 ms 10116 KB Output is correct
99 Correct 96 ms 10136 KB Output is correct
100 Correct 93 ms 10052 KB Output is correct
101 Correct 94 ms 10120 KB Output is correct
102 Correct 97 ms 10140 KB Output is correct
103 Correct 95 ms 10052 KB Output is correct
104 Correct 94 ms 10256 KB Output is correct
105 Correct 102 ms 10136 KB Output is correct