Submission #53553

# Submission time Handle Problem Language Result Execution time Memory
53553 2018-06-30T07:58:42 Z !?!?(#2015) Regions (IOI09_regions) C++11
0 / 100
1862 ms 28944 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);
                     ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 9720 KB Output isn't correct
2 Incorrect 9 ms 9800 KB Output isn't correct
3 Incorrect 13 ms 9884 KB Output isn't correct
4 Incorrect 16 ms 9884 KB Output isn't correct
5 Incorrect 12 ms 9884 KB Output isn't correct
6 Incorrect 24 ms 9972 KB Output isn't correct
7 Incorrect 28 ms 9972 KB Output isn't correct
8 Incorrect 38 ms 9976 KB Output isn't correct
9 Incorrect 49 ms 10360 KB Output isn't correct
10 Incorrect 68 ms 10360 KB Output isn't correct
11 Incorrect 86 ms 10632 KB Output isn't correct
12 Incorrect 66 ms 11016 KB Output isn't correct
13 Incorrect 119 ms 11016 KB Output isn't correct
14 Incorrect 139 ms 11280 KB Output isn't correct
15 Incorrect 175 ms 13756 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 724 ms 14144 KB Output isn't correct
2 Incorrect 532 ms 14144 KB Output isn't correct
3 Incorrect 939 ms 15932 KB Output isn't correct
4 Incorrect 189 ms 15932 KB Output isn't correct
5 Incorrect 345 ms 15932 KB Output isn't correct
6 Incorrect 312 ms 15932 KB Output isn't correct
7 Incorrect 459 ms 15932 KB Output isn't correct
8 Incorrect 727 ms 18108 KB Output isn't correct
9 Incorrect 1124 ms 18108 KB Output isn't correct
10 Incorrect 1540 ms 22864 KB Output isn't correct
11 Incorrect 1862 ms 22864 KB Output isn't correct
12 Incorrect 757 ms 22864 KB Output isn't correct
13 Incorrect 947 ms 22864 KB Output isn't correct
14 Incorrect 1270 ms 22864 KB Output isn't correct
15 Incorrect 1509 ms 23500 KB Output isn't correct
16 Incorrect 1496 ms 28944 KB Output isn't correct
17 Incorrect 1725 ms 28944 KB Output isn't correct