답안 #1084245

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084245 2024-09-05T17:13:37 Z Tymond 슈퍼트리 잇기 (IOI20_supertrees) C++17
21 / 100
185 ms 32048 KB
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
using ll = long long;
using ld = long double;
#define fi first
#define se second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int MAXN = 1e3 + 7;
int vis[MAXN];
int p[MAXN][MAXN];
vi g[MAXN];
int n;
vector<vi> ans;

vi akt;
map<int, int> cnt;
void getOthers(int v){
    queue<int> q;
    q.push(v);
    vis[v] = 1;
    while(sz(q)){
        v = q.front();
        q.pop();

        cnt[v] = 1;
        akt.pb(v);
        for(auto u : g[v]){
            if(!vis[u]){
                vis[u] = 1;
                q.push(u);
            }
        }
    }
}

/*void build(vector<vi> xd){
    for(int i = 0; i < sz(xd); i++){
        for(auto ele : xd[i]){
            cout << ele << ' ';
        }
        cout << '\n';
    }
}*/

int construct(vector<vi> given) {
    n = sz(given);
    ans.resize(n);
    for(int i = 0; i < n; i++){
        ans[i].assign(n, 0);
        for(int j = 0; j < n; j++){
            p[i][j] = given[i][j];
            if(p[i][j] > 0 && i != j){
                g[i].pb(j);
            }
        }
    }

    for(int i = 0; i < n; i++){
        if(!vis[i]){
            akt.clear();
            cnt.clear();
            getOthers(i);

            int mx = 0;
            for(auto ele : akt){
                for(int x = 0; x < n; x++){
                    if(x != ele && p[ele][x] == 0 && cnt[x]){
                        return 0;
                    }
                    if(cnt[x]){
                        mx = max(mx, p[ele][x]);
                    }
                }
            }

            if(mx == 1){
                for(int x = 0; x < sz(akt) - 1; x++){
                    ans[akt[x]][akt[x + 1]] = 1;
                    ans[akt[x + 1]][akt[x]] = 1;
                }
                continue;
            }
        }
    }


    build(ans);
    return 1;
}

/*int main(){
    cout << construct({{1, 0}, {0, 1}}) << '\n';
}*/
# 결과 실행 시간 메모리 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 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 2252 KB Output is correct
7 Correct 131 ms 32048 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 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 2252 KB Output is correct
7 Correct 131 ms 32048 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 9 ms 2000 KB Output is correct
13 Correct 182 ms 28120 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 1884 KB Output is correct
17 Correct 67 ms 20656 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 36 ms 8276 KB Output is correct
21 Correct 152 ms 28576 KB Output is correct
22 Correct 161 ms 27984 KB Output is correct
23 Correct 141 ms 29992 KB Output is correct
24 Correct 181 ms 27984 KB Output is correct
25 Correct 72 ms 18520 KB Output is correct
26 Correct 59 ms 18260 KB Output is correct
27 Correct 137 ms 31312 KB Output is correct
28 Correct 185 ms 27988 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 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 2252 KB Output is correct
7 Correct 131 ms 32048 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 9 ms 2000 KB Output is correct
13 Correct 182 ms 28120 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 1884 KB Output is correct
17 Correct 67 ms 20656 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 36 ms 8276 KB Output is correct
21 Correct 152 ms 28576 KB Output is correct
22 Correct 161 ms 27984 KB Output is correct
23 Correct 141 ms 29992 KB Output is correct
24 Correct 181 ms 27984 KB Output is correct
25 Correct 72 ms 18520 KB Output is correct
26 Correct 59 ms 18260 KB Output is correct
27 Correct 137 ms 31312 KB Output is correct
28 Correct 185 ms 27988 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 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 2252 KB Output is correct
7 Correct 131 ms 32048 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 9 ms 2000 KB Output is correct
13 Correct 182 ms 28120 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 1884 KB Output is correct
17 Correct 67 ms 20656 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 36 ms 8276 KB Output is correct
21 Correct 152 ms 28576 KB Output is correct
22 Correct 161 ms 27984 KB Output is correct
23 Correct 141 ms 29992 KB Output is correct
24 Correct 181 ms 27984 KB Output is correct
25 Correct 72 ms 18520 KB Output is correct
26 Correct 59 ms 18260 KB Output is correct
27 Correct 137 ms 31312 KB Output is correct
28 Correct 185 ms 27988 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 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -