Submission #891485

# Submission time Handle Problem Language Result Execution time Memory
891485 2023-12-23T05:46:01 Z Sir_Ahmed_Imran Split the Attractions (IOI19_split) C++17
0 / 100
759 ms 1048576 KB
                              ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define N 100000
vector<int> color;
vector<int> e[N];
int s[N];
int A[N];
int B[N];
int C[N];
int y,z;
void dfs(int v,int u,int a,int b,int c){
    s[v]=1;
    for(auto& i:e[v]){
        if(i==u) continue;
        dfs(i,v,a,b,c);
        s[v]+=s[i];
        if(A[i]) A[v]=1;
        if(B[i]) B[v]=1;
        if(C[i]) C[v]=1;
    }
    cout<<s[v]<<nl;
    if(s[v]==a) A[v]=1;
    if(s[v]==b) B[v]=1;
    if(s[v]==c) C[v]=1;
}
void Color(int v,int u,int a,int b,int c){
    if(!z){
        if(A[v] && s[v]==a+b) z=3;
        if(B[v] && s[v]==a+b) z=3;
        if(A[v] && s[v]==a+c) z=2;
        if(C[v] && s[v]==a+c) z=2;
        if(B[v] && s[v]==c+b) z=1;
        if(C[v] && s[v]==c+b) z=1;
        if(z) color[v]=4;
    }
    if(color[v]==4 && s[v]==a && z!=1 && !y){
        color[v]=1;
        y=5-z;
    }
    if(color[v]==4 && s[v]==b && z!=2 && !y){
        color[v]=2;
        y=4-z;
    }
    if(color[v]==4 && s[v]==c && z!=3 && !y){
        color[v]=3;
        y=3-z;
    }
    for(auto& i:e[v]){
        if(i==u) continue;
        color[i]=color[v];
        Color(i,v,a,b,c);
    }
}
vector<int> find_split(int n,int a,int b,int c,vector<int> p,vector<int> q){
    for(int i=y=z=0;i<p.size();i++){
        e[p[i]].append(q[i]);
        e[q[i]].append(p[i]);
    }
    for(int i=0;i<n;i++)
        color.append(0);
    dfs(1,0,a,b,c);
    Color(1,0,a,b,c);
    for(int i=0;i<n;i++){
        if(color[i]==0) color[i]=z;
        if(color[i]==4) color[i]=y;
        cout<<color[i]<<' ';
    }
    return color;
}

Compilation message

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i=y=z=0;i<p.size();i++){
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3932 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 3928 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3932 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 759 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3932 KB secret mismatch
2 Halted 0 ms 0 KB -