Submission #959503

#TimeUsernameProblemLanguageResultExecution timeMemory
959503yazanshIntercastellar (JOI22_ho_t1)C++17
25 / 100
600 ms524288 KiB
#include <bits/stdc++.h> #define gcd(a,b) __gcd(a,b) #define lcm(a,b) a*b/gcd(a,b) #define yon(x)(x)?cout<<"YES\n":cout<<"NO\n"; #define ll int64_t #define pb push_back #define all(x) (x).begin(),(x).end() #define ff first #define ss second #define rall(x) (x).rbegin(),(x).rend() #define rep(i,x) for(int i=0;i<x;i++) #define per(i,x) for(int i=x;i>=0;i--) using namespace std; const ll inf =1e18+1; const int mod=1e9+7; ll power(ll x,ll y); void setIO(string s); struct segtree{ struct id{ ll a,b; }; vector<ll>tree; ll sz=1; ll mrg(ll x,ll y) { return x+y; } void init(ll n) { sz=1; while(sz<n)sz*=2; tree.assign(2*sz,0); } void up(ll x, ll lx, ll rx,ll i, ll v) { if(rx-lx==1) { tree[x]=v; return; } ll mid=(lx+rx)>>1; if(i<mid) { up(2*x+1,lx,mid,i,v); } else{ up(2*x+2,mid,rx,i,v); } tree[x]=mrg(tree[2*x+1],tree[2*x+2]); } void up(ll i,ll v) { up(0,0,sz,i,v); } ll query(ll x,ll lx,ll rx,ll k) { if(rx-lx==1) { return lx; } ll mid=(lx+rx)>>1; if(tree[2*x+1]>=k+1) { return query(2*x+1,lx,mid,k); } else{ return query(2*x+2,mid,rx,abs( tree[2*x+1]-k ) ); } } ll query(ll k) { return query(0,0,sz,k); } ll get(ll x,ll lx,ll rx,ll i) { if(rx-lx==1) { return tree[x]; } ll mid=(lx+rx)>>1; if(i<mid) { return get(2*x+1,lx,mid,i); } else{ return get(2*x+2,mid,rx,i); } } ll get(ll i) { return get(0,0,sz,i); } }; void solve() { ll n; cin>>n; vector<ll>a(n); for(int i=0;i<n;i++) { cin>>a[i]; } vector<ll>b; for(int i=0;i<n;i++) { ll cnt=0; while(a[i]%2==0) { cnt++; a[i]/=2; } for(int j=0;j<power(2,cnt);j++) { b.pb(a[i]); } } ll q; cin>>q; while(q--) { ll c; cin>>c; c--; cout<<b[c]<<endl; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t=1; // cin>>t; while(t--) { solve(); cout<<'\n'; } } //******************************************************************** void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } inline ll power(ll x,ll y) { if(y==0) { return 1; } ll temp=power(x,y/2); if(y%2==0) { return temp*temp; } else { return x*temp *temp; } }

Compilation message (stderr)

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:150:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  150 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:151:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  151 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...