Submission #925378

#TimeUsernameProblemLanguageResultExecution timeMemory
9253788pete8Brunhilda’s Birthday (BOI13_brunhilda)C++17
100 / 100
204 ms80064 KiB
#include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<unordered_map> #include <queue> #include<cstring> #include<cassert> #include<limits.h> #include<cmath> #include<set> #include<numeric> //gcd(a,b) #include<algorithm> #include<bitset> #include<stack> using namespace std; #define ll long long #define f first #define endl "\n" #define s second #define pii pair<int,int> #define pppiiii pair<pii,pii> #define ppii pair<int,pii> #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define pb push_back #define mp make_pair #define lb lower_bound #define ub upper_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize ("03,unroll-loops") //#define int long long const int mod=1e9+7,mxn=1e7+100000,lg=30;//inf=1e18,minf=-1e18,Mxn=100000,root=700; void setIO(string name){ ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } int n,q; int ans[mxn+10],mx[mxn+10]; int32_t main(){ //setIO("redistricting"); fastio cin>>n>>q; vector<int>v(n); for(int i=0;i<n;i++)cin>>v[i]; sort(all(v)); v.erase(unique(all(v)),v.end()); for(auto i:v)for(int j=i-1;j<=mxn;j+=i)mx[j]=max(mx[j],i-1); for(int i=mxn;i>=0;i--)mx[i]=max(mx[i],mx[i+1]-1); for(int i=1;i<=mxn;i++){ ans[i]=ans[i-mx[i]]; if(ans[i]!=-1)ans[i]++; if(mx[i]<=0)ans[i]=-1; } while(q--){ int g;cin>>g; if(ans[g]!=-1)cout<<ans[g]<<'\n'; else cout<<"oo"<<'\n'; } }

Compilation message (stderr)

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