답안 #3142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3142 2013-08-26T07:48:48 Z club4208 공장 (KOI13_factory) C++
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#define MAXN 500001
int up[MAXN], down[MAXN], dt[MAXN], hash[1000001];
int idx_tree[1048576], n, trs;
int getsum(int a, int b){
    int sum=0; a=trs/2+a-1; b=trs/2+b-1;
    while(a<=b){
        if(a%2==1){ sum+=idx_tree[a]; a++; }
        if(b%2==0){ sum+=idx_tree[b]; b--; }
        a/=2;
        b/=2;
    }
    return sum;
}
void add(int a){
    a=trs/2+a-1;
    while(a>=1){
        idx_tree[a]++;
        a/=2;
    }
}
int main(){
    freopen("input.txt", "r", stdin);
    freopen("output.txt', "w", stdout);

    scanf("%d", &n);
    int i, max=0;
    for(i=1;i<=n;i++){
        scanf("%d", &up[i]);
        hash[up[i]]=i;
    }
    for(i=1;i<=n;i++){
        scanf("%d", &down[i]);
        dt[i]=hash[down[i]];
    }
    trs=1;
    while(trs<n){
        trs*=2;
    }
    trs*=2;
    long long int sum=0;
    for(i=1;i<=n;i++){
        sum+=getsum(dt[i], n);
        add(dt[i]);
        if(max<dt[i]) max=dt[i];
    }
    printf("%lld", sum);
    return 0;
}

Compilation message

factory.cpp:24:29: warning: missing terminating " character [enabled by default]
factory.cpp:24:5: error: missing terminating " character
factory.cpp: In function 'int main()':
factory.cpp:24:28: error: expected ')' before 'w'
factory.cpp:23:37: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
factory.cpp:29:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
factory.cpp:33:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]