답안 #26233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26233 2017-06-28T12:39:11 Z 카제비(#1106, kajebiii) Snowy Roads (JOI16_snowy) C++14
0 / 100
13 ms 4228 KB
#include "Anyalib.h"

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e3 + 50;

static vector<pi> Ed[MAX_N];
static int N;

static pi Ix[MAX_N], Nr[MAX_N];
static int IN;

static int dfs(int v, int p) {
    for(pi &t : Ed[v]) {
        int w, ix; tie(w, ix) = t;
        if(w != p) {
            int st = IN;
            Nr[st] = pi(ix, +1); IN++;
            dfs(w, v);
            int en = IN;
            Nr[en] = pi(ix, -1); IN++;
            Ix[ix] = pi(st, en);
        }
    }
}
void InitAnya(int n, int a[], int b[]) {
    N = n;
    for(int i=0; i+1<n; i++) {
        Ed[a[i]].push_back(pi(b[i], i));
        Ed[b[i]].push_back(pi(a[i], i));
    }
    dfs(0, -1);
    return;
}

static int Sum[MAX_N];
void Anya(int C[]) {
    for(int i=0; i+1<N; i++) {
        int st, en; tie(st, en) = Ix[i];
        if(C[i] == 0) continue;
        Sum[st]++; Sum[en]--;
    }
    for(int i=1; i<IN/20*20+20; i++) {
        Sum[i] += Sum[i-1];
//        printf("Sum[%d] = %d\n", i, Sum[i]);
    }
    for(int i=0; i<N-1; i++)
        Save(i, C[i]);
    for(int i=1; i<=IN/20; i++) {
        int cnt[10] = {0, };
        int val = Sum[i*20-1];
//        printf("send : %d -> %d\n", i, val);
        for(int k=0; k<10; k++) {
            cnt[k] = val & 1;
            val >>= 1;
        }
        for(int k=0; k<10; k++) {
//            printf("save at (%d) %d is %d\n", i, 500 + 10 * (i-1) + k, cnt[k]);
            Save(500 + 10 * (i-1) + k, cnt[k]);
        }
    }
}
#include "Borislib.h"

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e3 + 50;

static vector<pi> Ed[MAX_N];
static int N;

static pi Ix[MAX_N], Nr[MAX_N];
static int IN, ixP[MAX_N];

static int dfs(int v, int p) {
    for(pi &t : Ed[v]) {
        int w, ix; tie(w, ix) = t;
        if(w != p) {
            int st = IN;
            Nr[st] = pi(ix, +1); IN++;
            ixP[w] = ix;
            dfs(w, v);
            int en = IN;
            Nr[en] = pi(ix, -1); IN++;
            Ix[ix] = pi(st, en);
        }
    }
}
void InitBoris(int n, int a[] , int b[]) {
    N = n;
    for(int i=0; i+1<n; i++) {
        Ed[a[i]].push_back(pi(b[i], i));
        Ed[b[i]].push_back(pi(a[i], i));
    }
    dfs(0, -1);
//    for(int i=0; i<IN; i++) printf("%d %d\n", Nr[i].one, Nr[i].two); puts("");
    return;
}

int getG(int g) {
    if(g == 0) return 0;
    if(g > IN / 20) return 0;
    int res = 0;
    for(int k=9; k>=0; k--) {
        res *= 2;
        res += Ask(500 + 10 * (g-1) + k);
    }
    return res;
}
int getVal(int p) {
    if(p >= IN) return 0;
    int ix, t; tie(ix, t) = Nr[p];
//    printf("%d : %d\n", p, t * Ask(ix));
    return t * Ask(ix);
}
int Boris(int city) {
    int ix = Ix[ixP[city]].one;
//    printf("(line %d | %d)\n", ixP[city], ix);

    int ans = 0;
    if(ix - ix / 20 * 20 < 10) {
        ans = getG(ix / 20);
        for(int i=ix/20*20; i<=ix; i++)
            ans += getVal(i);
    }else{
        ans = getG(ix / 20 + 1);
        for(int i=ix+1; i < (ix/20 + 1) * 20; i++)
            ans -= getVal(i);
    }
    return ans;
}

Compilation message

Anya.cpp: In function 'int dfs(int, int)':
Anya.cpp:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^

Boris.cpp: In function 'int dfs(int, int)':
Boris.cpp:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4228 KB Output is correct
2 Correct 0 ms 4228 KB Output is correct
3 Incorrect 0 ms 4228 KB Wrong Answer [4]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4228 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 4228 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 4228 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -