제출 #1115879

#제출 시각아이디문제언어결과실행 시간메모리
1115879TrieTrIntercastellar (JOI22_ho_t1)C++14
100 / 100
64 ms13384 KiB
#include<bits/stdc++.h>
using namespace std;

void local() {
    #define taskname ""
    if (fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
}

#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;}
template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;}

const int N = 1e6 + 5;

int n, a[N];
ll pf[N]; int lg[N];

int main() {
    fastio; local();
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) {
    	int x = a[i];
    	while(x % 2 == 0) lg[i]++, x /= 2;
    	pf[i] = pf[i - 1] + (1ll << lg[i]);
    }
    int q; cin >> q;
    while(q--) {
    	ll p; cin >> p;
    	int lo = 1, hi = n, pos = 0;
    	while(lo <= hi) {
    		int mid = (lo + hi) >> 1;
    		if(pf[mid] < p) lo = (pos = mid) + 1;
    		else hi = mid - 1;
    	}
    	pos++;
    	cout << a[pos] / (1ll << lg[pos]) << '\n';
    }
}

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

Main.cpp: In function 'void local()':
Main.cpp:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...