Submission #72779

# Submission time Handle Problem Language Result Execution time Memory
72779 2018-08-26T23:56:54 Z RezwanArefin01 Amusement Park (JOI17_amusement_park) C++17
0 / 100
88 ms 9464 KB
#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;

const int N = 10010; 
vector<int> g[N], adj[N], t[N]; 
int vis[N], p[N], num[N], cnt, d[N]; 

void gen(int u) {
    vis[u] = 1; 
    for(int v : g[u]) if(!vis[v]) {
        adj[u].push_back(v);
        adj[v].push_back(u); 
        gen(v);
    }
}

vector<int> q; 
void dfs(int u, int par) {
    q.push_back(u);     
    p[u] = par; 
    num[u] = cnt++; 
    for(int v : adj[u]) if(v - par && cnt < 10) 
        dfs(v, u); 
}
bool has(vector<int> &T, int x) {
    return binary_search(T.begin(), T.end(), x); 
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
    for(int i = 0; i < M; i++) {
        g[A[i]].push_back(B[i]); 
        g[B[i]].push_back(A[i]); 
    } gen(0);
    memset(num, -1, sizeof num);
    dfs(0, -1); 
    sort(q.begin(), q.end());
    for(int u : q) t[u] = q; 
    for(int i = 0; i < q.size(); i++) {
       int u = q[i]; 
       for(int v : adj[u]) if(num[v] == -1) {
           vector<int> T = t[u]; 
           for(int w : T) {
               int x = p[w]; 
               if(x != -1 && has(T, x)) 
                   d[w]++, d[x]++; 
           }
           int x = -1; 
           for(int w : T) if(w != u && d[w] == 1) x = w; 
           num[v] = num[x]; 
           for(int w : T) if(w != x) t[v].push_back(w);
           t[v].push_back(v); 
           p[v] = u; 
           q.push_back(v); 
           for(int w : T) d[w] = 0;
           sort(t[v].begin(), t[v].end()); 
        }
    }
    for(int i = 0; i < N; i++) 
        MessageBoard(i, X >> num[i] & 1);        
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;

const int N = 10010; 
vector<int> g[N], adj[N], t[N]; 
int vis[N], p[N], num[N], cnt, d[N]; 

void gen(int u) {
    vis[u] = 1; 
    for(int v : g[u]) if(!vis[v]) {
        adj[u].push_back(v);
        adj[v].push_back(u); 
        gen(v);
    }
}

vector<int> q; 
void dfs(int u, int par) {
    q.push_back(u);     
    p[u] = par; 
    num[u] = cnt++; 
    for(int v : adj[u]) if(v - par && cnt < 10) 
        dfs(v, u); 
}
bool has(vector<int> &T, int x) {
    return binary_search(T.begin(), T.end(), x); 
}
long long X;  
void solve(int u, int par) {
    for(int v : adj[u]) if(v - par && has(t[u], v)) {
        int x = move(v); 
        if(x) X |= 1 << num[v]; 
        dfs(v, u); 
    } if(par + 1) move(par); 
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
    for(int i = 0; i < M; i++) {
        g[A[i]].push_back(B[i]); 
        g[B[i]].push_back(A[i]); 
    } gen(0);
    memset(num, -1, sizeof num);
    dfs(0, -1); 
    sort(q.begin(), q.end());
    for(int u : q) t[u] = q; 
    for(int i = 0; i < q.size(); i++) {
       int u = q[i]; 
       for(int v : adj[u]) if(num[v] == -1) {
           vector<int> T = t[u]; 
           for(int w : T) {
               int x = p[w]; 
               if(x != -1 && has(T, x)) 
                   d[w]++, d[x]++; 
           }
           int x = -1; 
           for(int w : T) if(w != u && d[w] == 1) x = w; 
           num[v] = num[x]; 
           for(int w : T) if(w != x) t[v].push_back(w);
           t[v].push_back(v); 
           p[v] = u; 
           q.push_back(v); 
           for(int w : T) d[w] = 0;
           sort(t[v].begin(), t[v].end()); 
        }
    }
    
    if(V) X = 1 << num[P]; 
    solve(P, -1); 
    return X; 
}

Compilation message

Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:38:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < q.size(); i++) {
                    ~~^~~~~~~~~~

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:47:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < q.size(); i++) {
                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 2412 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 8180 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 8200 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 8956 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9464 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -