답안 #99872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99872 2019-03-08T07:14:55 Z TAISA_ Snowy Roads (JOI16_snowy) C++14
0 / 100
47 ms 1684 KB
#include <bits/stdc++.h>
#include "Anyalib.h"
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vector<vector<P>> G;
vector<int> a,b;
int id;
int n;
void InitAnya(int N,int A[],int B[]){
    n=N;
    a.resize(N-1);
    b.resize(N-1);
    for(int i=0;i<N-1;i++){
        a[i]=A[i];
        b[i]=B[i];
    }
}
void dfs(int i,int p,int sum,int dep){
    if(dep%10==0){
        for(int i=0;i<10;i++){
            if(sum&(1<<i)){
                Save(n+id*10+i,1);
            }
        }
        id++;
    }
    for(auto e:G[i]){
        if(e.first==p)continue;
        Save(e.first,e.second);
        dfs(e.first,i,sum+e.second,dep+1);
    }
}
void Anya(int C[]){
    G.clear();
    G.resize(n);
    id=0;
    for(int i=0;i<n-1;i++){
        G[a[i]].push_back(P(b[i],C[i]));
        G[b[i]].push_back(P(a[i],C[i]));
    }
    dfs(0,-1,0,0);
}
#include <bits/stdc++.h>
#include "Borislib.h"
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vector<vector<int>> G;
vector<int> a,b,idx,par,d;
int n,id;
void dfs(int i,int p,int dep){
    if(dep%10==0){
        idx[i]=id;
    }
    d[i]=dep;
    par[i]=p;
    for(auto e:G[i]){
        if(e==p)continue;
        dfs(e,i,dep+1);
    }
}
void InitBoris(int N,int A[],int B[]){
    n=N;
    a.resize(N-1);
    b.resize(N-1);
    idx.resize(n,-1);
    par.resize(n,-1);
    d.resize(n);
    G.resize(n);
    for(int i=0;i<N-1;i++){
        a[i]=A[i];
        b[i]=B[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    dfs(0,-1,0);
}
int Boris(int city){
    int v=city;
    int res=0;
    while(1){
        if(d[v]%10==0){
            int k=idx[v];
            for(int i=0;i<10;i++){
                if(Ask(n+10*k+i)){
                    res+=(1<<i);
                }
            }
            break;
        }else{
            res+=Ask(v);
        }
        v=par[v];
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 912 KB Output is correct
2 Correct 5 ms 792 KB Output is correct
3 Correct 6 ms 848 KB Output is correct
4 Incorrect 9 ms 1024 KB Wrong Answer [7]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1432 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 1684 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1044 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -