답안 #1062914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062914 2024-08-17T11:51:18 Z ewirlan 슈퍼트리 잇기 (IOI20_supertrees) C++17
96 / 100
134 ms 24252 KB
//
#ifndef __SIZEOF_INT128__
  #define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
    string name{""};
    time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
    duration<float, std::milli> dur;
    Timer() = default;
    Timer(string nm): name(nm) {}
    ~Timer() {
        end = high_resolution_clock::now(); dur= end - start;
        cout << "@" << name << "> " << dur.count() << " ms" << '\n';
    }
};
template <typename T = int> inline T in()
{
    static T x;
    std::cin >> x;
    return x;
}
std::string yn(bool b)
{
    if(b) return "YES\n";
    else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
    for(const auto& i : wek)out << i << ' ';
    return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
    out << '{'<<par.first<<", "<<par.second<<"}";
    return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
#include "supertrees.h"
constexpr int maxn = 1003;
int gr[maxn];
vector <int> za[maxn];
int sp[maxn];
vector <int> po[maxn];
int construct(vector <vector <int>> p)
{
    int n(sz(p));
    rep(i, 0, n)gr[i] = sp[i] = -1;
    vector <int> g, c;
    rep(i, 0, n)if(gr[i] == -1){
        rep(j, 0, n)if(p[i][j] == 1){
            gr[j] = i;
            za[i].pb(j);
        }
        g.pb(i);
    }
    rep(i, 0, n)rep(j, 0, n)if((gr[i] == gr[j]) != (p[i][j] == 1)){
        // cerr << "A " << i << ' ' << j << '\n';
        return 0;
    }
    for(auto i: g)if(sp[i] == -1){
        for(auto j: g)if(p[i][j]){
            sp[j] = i;
            po[i].pb(j);
        }
        c.pb(i);
    }
    // rep(i, 0, n)cerr << gr[i] << ' ';
    // cerr << '\n';
    rep(i, 0, n)rep(j, 0, n)if(gr[i] != gr[j] && (sp[gr[i]] == sp[gr[j]]) != (p[i][j] == 2)){
        // cerr << "B " << i << ' ' << j << '\n';
        return 0;
    }
    vector <vector<int>> b(n, vector <int>(n, 0));
    auto kr = [&](int x, int y){
        b[x][y] = b[y][x] = 1;
    };
    for(auto i: g){
        rep(j, 1, sz(za[i]))kr(za[i][j-1],za[i][j]);
    }
    for(auto i: c){
        if(sz(po[i]) == 2)return 0;
        if(sz(po[i]) >= 3)rep(j, 0, sz(po[i]))kr(po[i][j], po[i][(j+1)%sz(po[i])]);
    }
    build(b);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1272 KB Output is correct
7 Correct 110 ms 24028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1272 KB Output is correct
7 Correct 110 ms 24028 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 10 ms 1684 KB Output is correct
13 Correct 113 ms 24252 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 58 ms 10172 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 30 ms 6312 KB Output is correct
21 Correct 123 ms 24124 KB Output is correct
22 Correct 111 ms 24128 KB Output is correct
23 Correct 117 ms 24000 KB Output is correct
24 Correct 113 ms 24244 KB Output is correct
25 Correct 48 ms 10320 KB Output is correct
26 Correct 46 ms 10320 KB Output is correct
27 Correct 125 ms 24148 KB Output is correct
28 Correct 112 ms 24248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 6 ms 1372 KB Output is correct
9 Correct 122 ms 23964 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 111 ms 23996 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 740 KB Output is correct
17 Correct 64 ms 10172 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 28 ms 6236 KB Output is correct
22 Correct 111 ms 24116 KB Output is correct
23 Correct 112 ms 24128 KB Output is correct
24 Correct 121 ms 24056 KB Output is correct
25 Correct 53 ms 14160 KB Output is correct
26 Correct 50 ms 10320 KB Output is correct
27 Correct 113 ms 24124 KB Output is correct
28 Correct 118 ms 24144 KB Output is correct
29 Correct 50 ms 14160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 38 ms 6440 KB Output is correct
5 Correct 118 ms 24044 KB Output is correct
6 Correct 124 ms 24124 KB Output is correct
7 Correct 122 ms 23984 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 28 ms 6444 KB Output is correct
10 Correct 119 ms 24144 KB Output is correct
11 Correct 119 ms 24060 KB Output is correct
12 Correct 118 ms 24128 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 29 ms 6224 KB Output is correct
17 Correct 112 ms 24152 KB Output is correct
18 Correct 111 ms 24144 KB Output is correct
19 Correct 111 ms 24144 KB Output is correct
20 Correct 134 ms 24140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1272 KB Output is correct
7 Correct 110 ms 24028 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 10 ms 1684 KB Output is correct
13 Correct 113 ms 24252 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 58 ms 10172 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 30 ms 6312 KB Output is correct
21 Correct 123 ms 24124 KB Output is correct
22 Correct 111 ms 24128 KB Output is correct
23 Correct 117 ms 24000 KB Output is correct
24 Correct 113 ms 24244 KB Output is correct
25 Correct 48 ms 10320 KB Output is correct
26 Correct 46 ms 10320 KB Output is correct
27 Correct 125 ms 24148 KB Output is correct
28 Correct 112 ms 24248 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 6 ms 1372 KB Output is correct
37 Correct 122 ms 23964 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 5 ms 1372 KB Output is correct
41 Correct 111 ms 23996 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 3 ms 740 KB Output is correct
45 Correct 64 ms 10172 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 344 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 28 ms 6236 KB Output is correct
50 Correct 111 ms 24116 KB Output is correct
51 Correct 112 ms 24128 KB Output is correct
52 Correct 121 ms 24056 KB Output is correct
53 Correct 53 ms 14160 KB Output is correct
54 Correct 50 ms 10320 KB Output is correct
55 Correct 113 ms 24124 KB Output is correct
56 Correct 118 ms 24144 KB Output is correct
57 Correct 50 ms 14160 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 2 ms 860 KB Output is correct
61 Correct 51 ms 10300 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 33 ms 6304 KB Output is correct
66 Correct 50 ms 10156 KB Output is correct
67 Correct 57 ms 10172 KB Output is correct
68 Correct 59 ms 10304 KB Output is correct
69 Correct 52 ms 14164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1272 KB Output is correct
7 Correct 110 ms 24028 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 10 ms 1684 KB Output is correct
13 Correct 113 ms 24252 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 58 ms 10172 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 30 ms 6312 KB Output is correct
21 Correct 123 ms 24124 KB Output is correct
22 Correct 111 ms 24128 KB Output is correct
23 Correct 117 ms 24000 KB Output is correct
24 Correct 113 ms 24244 KB Output is correct
25 Correct 48 ms 10320 KB Output is correct
26 Correct 46 ms 10320 KB Output is correct
27 Correct 125 ms 24148 KB Output is correct
28 Correct 112 ms 24248 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 6 ms 1372 KB Output is correct
37 Correct 122 ms 23964 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 5 ms 1372 KB Output is correct
41 Correct 111 ms 23996 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 3 ms 740 KB Output is correct
45 Correct 64 ms 10172 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 344 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 28 ms 6236 KB Output is correct
50 Correct 111 ms 24116 KB Output is correct
51 Correct 112 ms 24128 KB Output is correct
52 Correct 121 ms 24056 KB Output is correct
53 Correct 53 ms 14160 KB Output is correct
54 Correct 50 ms 10320 KB Output is correct
55 Correct 113 ms 24124 KB Output is correct
56 Correct 118 ms 24144 KB Output is correct
57 Correct 50 ms 14160 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 38 ms 6440 KB Output is correct
62 Correct 118 ms 24044 KB Output is correct
63 Correct 124 ms 24124 KB Output is correct
64 Correct 122 ms 23984 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 28 ms 6444 KB Output is correct
67 Correct 119 ms 24144 KB Output is correct
68 Correct 119 ms 24060 KB Output is correct
69 Correct 118 ms 24128 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 1 ms 344 KB Output is correct
73 Correct 29 ms 6224 KB Output is correct
74 Correct 112 ms 24152 KB Output is correct
75 Correct 111 ms 24144 KB Output is correct
76 Correct 111 ms 24144 KB Output is correct
77 Correct 134 ms 24140 KB Output is correct
78 Correct 0 ms 348 KB Output is correct
79 Correct 0 ms 348 KB Output is correct
80 Correct 2 ms 860 KB Output is correct
81 Correct 51 ms 10300 KB Output is correct
82 Correct 0 ms 348 KB Output is correct
83 Correct 0 ms 348 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 33 ms 6304 KB Output is correct
86 Correct 50 ms 10156 KB Output is correct
87 Correct 57 ms 10172 KB Output is correct
88 Correct 59 ms 10304 KB Output is correct
89 Correct 52 ms 14164 KB Output is correct
90 Correct 0 ms 348 KB Output is correct
91 Correct 0 ms 344 KB Output is correct
92 Correct 2 ms 860 KB Output is correct
93 Correct 49 ms 10324 KB Output is correct
94 Correct 0 ms 344 KB Output is correct
95 Incorrect 1 ms 360 KB Answer gives possible 1 while actual possible 0
96 Halted 0 ms 0 KB -