Submission #31281

# Submission time Handle Problem Language Result Execution time Memory
31281 2017-08-17T21:00:34 Z imaxblue Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
1000 ms 82592 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define foxr1(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)

int n, q, x, t, l2, k, lo=(1 << 30), dp[10000005], f[10000005];
vector<bool> p=vector<bool>(10000005), u=vector<bool>(10000005);
int main(){
    scanf("%i%i", &n, &q);
    fox(l, n){
        scanf("%i", &x);
        p[x]=1;
        lo=min(lo, 10000000/x*x);
    }
    k=p[2]*2;
    for (l2=2; l2<=10000000; l2+=2){
        f[l2]=k;
    }

    for(int l=3; l<=10000000; l+=2){
        if (u[l]) continue;
        k=p[l]*l;
        for (l2=l; l2<=10000000; l2+=l){
            f[l2]=k;
            u[l2]=1;
        }
    }
    foxr1(l, 10000000){
        t=lo;
        lo=min(lo, l-f[l]);
        f[l]=t;
        //cout << f[l] << endl;
    }
    fox1(l, 10000000){
        if (f[l]==l) dp[l]=(1 << 30);
        dp[l]=dp[f[l]]+1;
    }
    fox(l, q){
        scanf("%i", &x);
        if (dp[x]>=(1 << 30)){
            printf("oo\n");
        }
        else {
            printf("%i\n", dp[x]);
        }
    }
    return 0;
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:29:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i", &n, &q);
                          ^
brunhilda.cpp:31:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i", &x);
                        ^
brunhilda.cpp:59:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i", &x);
                        ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 82592 KB Execution timed out
2 Execution timed out 1000 ms 82592 KB Execution timed out
3 Execution timed out 1000 ms 82592 KB Execution timed out
4 Execution timed out 1000 ms 82592 KB Execution timed out
5 Execution timed out 1000 ms 82592 KB Execution timed out
6 Execution timed out 1000 ms 82592 KB Execution timed out
7 Execution timed out 1000 ms 82592 KB Execution timed out
8 Execution timed out 1000 ms 82592 KB Execution timed out
9 Execution timed out 1000 ms 82592 KB Execution timed out
10 Execution timed out 1000 ms 82592 KB Execution timed out
11 Execution timed out 1000 ms 82592 KB Execution timed out
12 Execution timed out 1000 ms 82592 KB Execution timed out
13 Execution timed out 1000 ms 82592 KB Execution timed out
14 Execution timed out 1000 ms 82592 KB Execution timed out
15 Execution timed out 1000 ms 82592 KB Execution timed out
16 Execution timed out 1000 ms 82592 KB Execution timed out
17 Execution timed out 1000 ms 82592 KB Execution timed out
18 Execution timed out 1000 ms 82592 KB Execution timed out
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 82592 KB Execution timed out
2 Execution timed out 1000 ms 82592 KB Execution timed out
3 Execution timed out 1000 ms 82592 KB Execution timed out
4 Execution timed out 1000 ms 82592 KB Execution timed out
5 Execution timed out 1000 ms 82592 KB Execution timed out
6 Execution timed out 1000 ms 82592 KB Execution timed out
7 Execution timed out 1000 ms 82592 KB Execution timed out
8 Execution timed out 1000 ms 82592 KB Execution timed out
9 Execution timed out 1000 ms 82592 KB Execution timed out
10 Execution timed out 1000 ms 82592 KB Execution timed out
11 Execution timed out 1000 ms 82592 KB Execution timed out
12 Execution timed out 1000 ms 82592 KB Execution timed out
13 Execution timed out 1000 ms 82592 KB Execution timed out
14 Execution timed out 1000 ms 82592 KB Execution timed out
15 Execution timed out 1000 ms 82592 KB Execution timed out
16 Execution timed out 1000 ms 82592 KB Execution timed out
17 Execution timed out 1000 ms 82592 KB Execution timed out
18 Execution timed out 1000 ms 82592 KB Execution timed out
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 82592 KB Execution timed out
2 Execution timed out 1000 ms 82592 KB Execution timed out
3 Execution timed out 1000 ms 82592 KB Execution timed out
4 Execution timed out 1000 ms 82592 KB Execution timed out
5 Execution timed out 1000 ms 82592 KB Execution timed out
6 Execution timed out 1000 ms 82592 KB Execution timed out
7 Execution timed out 1000 ms 82592 KB Execution timed out
8 Execution timed out 1000 ms 82592 KB Execution timed out
9 Execution timed out 1000 ms 82592 KB Execution timed out
10 Execution timed out 1000 ms 82592 KB Execution timed out
11 Execution timed out 1000 ms 82592 KB Execution timed out
12 Execution timed out 1000 ms 82592 KB Execution timed out
13 Execution timed out 1000 ms 82592 KB Execution timed out
14 Execution timed out 1000 ms 82592 KB Execution timed out
15 Execution timed out 1000 ms 82592 KB Execution timed out
16 Execution timed out 1000 ms 82592 KB Execution timed out
17 Execution timed out 1000 ms 82592 KB Execution timed out
18 Execution timed out 1000 ms 82592 KB Execution timed out
19 Execution timed out 1000 ms 82592 KB Execution timed out
20 Execution timed out 1000 ms 82592 KB Execution timed out
21 Execution timed out 1000 ms 82592 KB Execution timed out
22 Execution timed out 1000 ms 82592 KB Execution timed out
23 Execution timed out 1000 ms 82592 KB Execution timed out
24 Execution timed out 1000 ms 82592 KB Execution timed out
25 Execution timed out 1000 ms 82592 KB Execution timed out
26 Execution timed out 1000 ms 82592 KB Execution timed out
27 Execution timed out 1000 ms 82592 KB Execution timed out
28 Execution timed out 1000 ms 82592 KB Execution timed out
29 Execution timed out 1000 ms 82592 KB Execution timed out
30 Execution timed out 1000 ms 82592 KB Execution timed out
31 Execution timed out 1000 ms 82592 KB Execution timed out
32 Execution timed out 1000 ms 82592 KB Execution timed out
33 Execution timed out 1000 ms 82592 KB Execution timed out
34 Execution timed out 1000 ms 82592 KB Execution timed out
35 Execution timed out 1000 ms 82592 KB Execution timed out
36 Execution timed out 1000 ms 82592 KB Execution timed out
37 Execution timed out 1000 ms 82592 KB Execution timed out
38 Execution timed out 1000 ms 82592 KB Execution timed out
39 Execution timed out 1000 ms 82592 KB Execution timed out
40 Execution timed out 1000 ms 82592 KB Execution timed out
41 Execution timed out 1000 ms 82592 KB Execution timed out
42 Execution timed out 1000 ms 82592 KB Execution timed out