Submission #31283

# Submission time Handle Problem Language Result Execution time Memory
31283 2017-08-17T21:06:35 Z imaxblue Brunhilda’s Birthday (BOI13_brunhilda) C++14
90.4762 / 100
573 ms 81368 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);
int main(){
    scanf("%i%i", &n, &q);
    fox(l, n){
        scanf("%i", &x);
        p[x]=1;
        lo=min(lo, 10000000/x*x);
    }
    for(int l=2; l<=10000000; l++){
        if (f[l]!=0) continue;
        if (p[l]) k=l; else k=-1;
        for (l2=l; l2<=10000000; l2+=l){
            f[l2]=k;
        }
    }
    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:53: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 Incorrect 413 ms 81368 KB Output isn't correct
2 Correct 409 ms 81368 KB Output is correct
3 Incorrect 406 ms 81368 KB Output isn't correct
4 Correct 436 ms 81368 KB Output is correct
5 Correct 413 ms 81368 KB Output is correct
6 Incorrect 433 ms 81368 KB Output isn't correct
7 Incorrect 399 ms 81368 KB Output isn't correct
8 Incorrect 423 ms 81368 KB Output isn't correct
9 Correct 409 ms 81368 KB Output is correct
10 Correct 423 ms 81368 KB Output is correct
11 Incorrect 403 ms 81368 KB Output isn't correct
12 Correct 409 ms 81368 KB Output is correct
13 Correct 393 ms 81368 KB Output is correct
14 Correct 413 ms 81368 KB Output is correct
15 Correct 403 ms 81368 KB Output is correct
16 Correct 396 ms 81368 KB Output is correct
17 Correct 403 ms 81368 KB Output is correct
18 Correct 409 ms 81368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 413 ms 81368 KB Output is correct
2 Correct 439 ms 81368 KB Output is correct
3 Correct 423 ms 81368 KB Output is correct
4 Correct 423 ms 81368 KB Output is correct
5 Correct 436 ms 81368 KB Output is correct
6 Correct 416 ms 81368 KB Output is correct
7 Correct 413 ms 81368 KB Output is correct
8 Correct 429 ms 81368 KB Output is correct
9 Correct 439 ms 81368 KB Output is correct
10 Correct 403 ms 81368 KB Output is correct
11 Correct 416 ms 81368 KB Output is correct
12 Correct 376 ms 81368 KB Output is correct
13 Correct 343 ms 81368 KB Output is correct
14 Correct 426 ms 81368 KB Output is correct
15 Correct 439 ms 81368 KB Output is correct
16 Correct 436 ms 81368 KB Output is correct
17 Correct 416 ms 81368 KB Output is correct
18 Correct 453 ms 81368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 443 ms 81368 KB Output is correct
2 Correct 449 ms 81368 KB Output is correct
3 Correct 436 ms 81368 KB Output is correct
4 Correct 456 ms 81368 KB Output is correct
5 Correct 483 ms 81368 KB Output is correct
6 Correct 473 ms 81368 KB Output is correct
7 Correct 469 ms 81368 KB Output is correct
8 Correct 446 ms 81368 KB Output is correct
9 Correct 446 ms 81368 KB Output is correct
10 Correct 439 ms 81368 KB Output is correct
11 Correct 429 ms 81368 KB Output is correct
12 Correct 436 ms 81368 KB Output is correct
13 Correct 446 ms 81368 KB Output is correct
14 Incorrect 443 ms 81368 KB Output isn't correct
15 Correct 399 ms 81368 KB Output is correct
16 Correct 329 ms 81368 KB Output is correct
17 Correct 439 ms 81368 KB Output is correct
18 Correct 446 ms 81368 KB Output is correct
19 Correct 436 ms 81368 KB Output is correct
20 Correct 459 ms 81368 KB Output is correct
21 Incorrect 449 ms 81368 KB Output isn't correct
22 Correct 489 ms 81368 KB Output is correct
23 Correct 469 ms 81368 KB Output is correct
24 Correct 466 ms 81368 KB Output is correct
25 Correct 479 ms 81368 KB Output is correct
26 Correct 459 ms 81368 KB Output is correct
27 Correct 463 ms 81368 KB Output is correct
28 Correct 443 ms 81368 KB Output is correct
29 Correct 489 ms 81368 KB Output is correct
30 Correct 476 ms 81368 KB Output is correct
31 Correct 456 ms 81368 KB Output is correct
32 Correct 483 ms 81368 KB Output is correct
33 Correct 483 ms 81368 KB Output is correct
34 Correct 463 ms 81368 KB Output is correct
35 Correct 476 ms 81368 KB Output is correct
36 Correct 573 ms 81368 KB Output is correct
37 Correct 536 ms 81368 KB Output is correct
38 Correct 473 ms 81368 KB Output is correct
39 Correct 493 ms 81368 KB Output is correct
40 Correct 489 ms 81368 KB Output is correct
41 Correct 486 ms 81368 KB Output is correct
42 Correct 456 ms 81368 KB Output is correct