Submission #26572

# Submission time Handle Problem Language Result Execution time Memory
26572 2017-07-03T07:24:07 Z top34051 Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
0 ms 1844 KB
#include<bits/stdc++.h>
using namespace std;
#define inf (int)1e6
int n,m;
int pos[10000005];
int mem[10000005];
vector<int> a[10000005];
main() {
    int i,j,k,x;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++) scanf("%d",&x), a[x].push_back(x);
    pos[0] = n;
    for(i=1,j=0;i<=10000000;i++) {
        for(k=0;k<a[i].size();k++) {
            pos[i-a[i][k]]--; pos[i]++;
            a[i+a[i][k]].push_back(a[i][k]);
        }
        a[i].clear();
        while(j<i && pos[j]==0) j++;
        mem[i] = inf;
        mem[i] = min(mem[i],mem[j] + 1);
    }
    while(m--) {
        scanf("%d",&x);
        if(mem[x]==inf) printf("oo\n");
        else printf("%d\n",mem[x]);
    }
}

Compilation message

brunhilda.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
brunhilda.cpp: In function 'int main()':
brunhilda.cpp:14:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(k=0;k<a[i].size();k++) {
                  ^
brunhilda.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
brunhilda.cpp:11:56: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++) scanf("%d",&x), a[x].push_back(x);
                                                        ^
brunhilda.cpp:24:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)