답안 #53558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
53558 2018-06-30T08:01:25 Z !?!?(#2015) Regions (IOI09_regions) C++11
0 / 100
1797 ms 16976 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=200010, inf=2e9;
 
void out(int x){
    printf("%d\n", x);
    fflush(stdout);
}
vector<int> P[MX]; // dfs indexes
vector<int> G[MX];
int n, H[MX], q, r;
 
int num[MX], sub[MX], now;
 
void dfs(int v){
    num[v]=++now; int &r=sub[num[v]]; r=num[v];
    for(int x:G[v]){
        dfs(x);
        r=max(r, sub[num[x]]);
    }
}
 
void init(){
    dfs(1);
    for(int i=1; i<=n; i++){
        int x=num[i];
        P[H[i]].push_back(x);
    }
    for(int i=1; i<=r; i++)
        sort(P[i].begin(), P[i].end());
}
 
int solve(int x, int y){
    vector<int> &V=P[x], &W=P[y];
 
    int ans=0;
    for(int l:V){
        int r=sub[l];
        ans+=upper_bound(W.begin(), W.end(), r) - lower_bound(W.begin(), W.end(), l);
    }
    return ans;
 
}
 
int main(){
    scanf("%d%d%d", &n, &r, &q);
    for(int i=1; i<=n; i++){
        int a,b;
        if(i==1){
            scanf("%d", &a); H[i]=a;
        }
        else{
            scanf("%d%d", &a, &b);
            G[a].push_back(i); H[i]=b;
        }
    }
    //init();
    for(; q--; ){
        int r1, r2; scanf("%d%d", &r1, &r2);
        out(1);
        //out(solve(r1,r2));
    }
    return 0;
}

Compilation message

regions.cpp: In function 'int main()':
regions.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &r, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
regions.cpp:52:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a); H[i]=a;
             ~~~~~^~~~~~~~~~
regions.cpp:55:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~
regions.cpp:61:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int r1, r2; scanf("%d%d", &r1, &r2);
                     ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 9728 KB Output isn't correct
2 Incorrect 10 ms 9728 KB Output isn't correct
3 Incorrect 12 ms 9868 KB Output isn't correct
4 Incorrect 12 ms 9868 KB Output isn't correct
5 Incorrect 12 ms 9968 KB Output isn't correct
6 Incorrect 24 ms 9968 KB Output isn't correct
7 Incorrect 30 ms 9968 KB Output isn't correct
8 Incorrect 27 ms 10020 KB Output isn't correct
9 Incorrect 47 ms 10044 KB Output isn't correct
10 Incorrect 69 ms 10304 KB Output isn't correct
11 Incorrect 82 ms 10428 KB Output isn't correct
12 Incorrect 103 ms 10560 KB Output isn't correct
13 Incorrect 129 ms 10560 KB Output isn't correct
14 Incorrect 134 ms 10944 KB Output isn't correct
15 Incorrect 178 ms 11328 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 629 ms 12480 KB Output isn't correct
2 Incorrect 685 ms 12480 KB Output isn't correct
3 Incorrect 1016 ms 13120 KB Output isn't correct
4 Incorrect 227 ms 13120 KB Output isn't correct
5 Incorrect 296 ms 13120 KB Output isn't correct
6 Incorrect 415 ms 13120 KB Output isn't correct
7 Incorrect 796 ms 13120 KB Output isn't correct
8 Incorrect 746 ms 13392 KB Output isn't correct
9 Incorrect 1108 ms 14880 KB Output isn't correct
10 Incorrect 1492 ms 15888 KB Output isn't correct
11 Incorrect 1563 ms 15888 KB Output isn't correct
12 Incorrect 663 ms 16592 KB Output isn't correct
13 Incorrect 1305 ms 16592 KB Output isn't correct
14 Incorrect 1173 ms 16592 KB Output isn't correct
15 Incorrect 1386 ms 16976 KB Output isn't correct
16 Incorrect 1286 ms 16976 KB Output isn't correct
17 Incorrect 1797 ms 16976 KB Output isn't correct