Submission #1047952

# Submission time Handle Problem Language Result Execution time Memory
1047952 2024-08-07T18:39:55 Z cpdreamer Connecting Supertrees (IOI20_supertrees) C++17
46 / 100
113 ms 24148 KB
#include "supertrees.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <utility>
#define V vector
#define P pair
#define S second
#define F first
#define pb push_back
#define all(v) v.begin(),v.end()
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7
int construct(std::vector<std::vector<int>> p) {
    int n=(int)p.size();
    V<V<int>>ans(n,V<int>(n,0));
    V<int>component(n);
    V<int>visited(n,false);
    V<bool>vp(n,false);
    V<bool>cycle(n,false);
    for(int i=0;i<n;i++){
        if(visited[i])continue;
        component[i]=i;
        vp[i]=true;
        visited[i]=true;
        for(int j=0;j<n;j++){
            if(i==j)continue;
            if(p[i][j]==1) {
                if (visited[j])continue;
                visited[j] = true;
                ans[i][j] = ans[j][i] = 1;
                component[j]=i;
            }
        }
    }
    for(int i=0;i<n-1;i++){
        if(vp[i]){
            if(!cycle[i]) {
                V<int> ls;
                ls.pb(i);
                for (int j = i + 1; j < n; j++) {
                    if (vp[j])
                        if (p[i][j] == 2)
                            ls.pb(j);
                }
                if (ls.size() > 2) {
                    int s = (int) ls.size();
                    ans[ls[0]][ls[s - 1]] = ans[ls[s - 1]][ls[0]] = 1;
                    for (int j = 0; j < s - 1; j++) {
                        ans[ls[j]][ls[j + 1]] = ans[ls[j + 1]][ls[j]] = 1;
                    }
                    for (int j = 0; j < s; j++) {
                        cycle[ls[j]]=true;
                    }
                }
            }
        }
    }
    build(ans);
    return 1;
}

Compilation message

supertrees.cpp:16:12: warning: 'called' defined but not used [-Wunused-variable]
   16 | static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7
      |            ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 504 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 4 ms 1116 KB Output is correct
7 Correct 92 ms 22044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 504 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 4 ms 1116 KB Output is correct
7 Correct 92 ms 22044 KB Output is correct
8 Correct 0 ms 348 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 4 ms 1116 KB Output is correct
13 Correct 101 ms 22040 KB Output is correct
14 Incorrect 0 ms 344 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Incorrect 1 ms 600 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 23 ms 5724 KB Output is correct
5 Correct 94 ms 22036 KB Output is correct
6 Correct 91 ms 22096 KB Output is correct
7 Correct 113 ms 22104 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 24 ms 6288 KB Output is correct
10 Correct 95 ms 23928 KB Output is correct
11 Correct 95 ms 24148 KB Output is correct
12 Correct 97 ms 23892 KB Output is correct
13 Correct 0 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 25 ms 6312 KB Output is correct
17 Correct 95 ms 23944 KB Output is correct
18 Correct 92 ms 24148 KB Output is correct
19 Correct 91 ms 23892 KB Output is correct
20 Correct 94 ms 23924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 504 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 4 ms 1116 KB Output is correct
7 Correct 92 ms 22044 KB Output is correct
8 Correct 0 ms 348 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 4 ms 1116 KB Output is correct
13 Correct 101 ms 22040 KB Output is correct
14 Incorrect 0 ms 344 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 504 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 4 ms 1116 KB Output is correct
7 Correct 92 ms 22044 KB Output is correct
8 Correct 0 ms 348 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 4 ms 1116 KB Output is correct
13 Correct 101 ms 22040 KB Output is correct
14 Incorrect 0 ms 344 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -