제출 #816335

#제출 시각아이디문제언어결과실행 시간메모리
816335QwertyPiBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
738 ms114124 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
using namespace std;

const int MAXN = 1e7 + 11;
const int MAXM = 1e5 + 11;
int p[MAXM];
int lp[MAXN], dp[MAXN], c[MAXN], c2[MAXN], cm = 0;

int d[100], di = 0;
int32_t main(){
    cin.tie(0); cout.tie(0)->sync_with_stdio(false);
    int n, Q; cin >> n >> Q;
    for(int i = 0; i < n; i++) cin >> p[i]; sort(p, p + n);
    for(int i = 0; i < n; i++){
        for(int j = p[i]; j < MAXN; j += p[i]){
            if(!lp[j]) lp[j] = p[i];
        }
    }

    dp[0] = 0; c2[0] = n; cm = 0;
    for(int i = 1; i < MAXN; i++){
        int x = i;
        di = 0;
        while(lp[x] != 0){
            if(lp[x] != lp[x / lp[x]]) d[di++] = lp[x];
            x /= lp[x];
        }

        for(int i = 0; i < di; i++){
            c2[c[d[i]]]--;
            while(cm < MAXN - 1 && c2[cm] == 0) cm++;
        }
        int cur = cm;
        for(int i = 0; i < di; i++){
            c[d[i]] = cur + 1; c2[cur + 1]++;
        }
        dp[i] = cur + 1;
    }
    for(int i = 0; i < Q; i++){
        int k; cin >> k; cout << (dp[k] != MAXN ? to_string(dp[k]) : "oo") << '\n';
    }
}

컴파일 시 표준 에러 (stderr) 메시지

brunhilda.cpp: In function 'int32_t main()':
brunhilda.cpp:15:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   15 |     for(int i = 0; i < n; i++) cin >> p[i]; sort(p, p + n);
      |     ^~~
brunhilda.cpp:15:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   15 |     for(int i = 0; i < n; i++) cin >> p[i]; sort(p, p + n);
      |                                             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...