제출 #239496

#제출 시각아이디문제언어결과실행 시간메모리
239496NucleistLottery (CEOI18_lot)C++14
100 / 100
855 ms20856 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define debug(x) cerr << " - " << #x << ": " << x << endl; #define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl; #define all(x) (x).begin(),(x).end() #define sz(x) (ll)x.size() #define ll long long #define INF 1000000000 #define MOD 1000000007 #define pb push_back #define ve vector<ll> #define dos pair<ll,ll> #define vedos vector<dos> #define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) #define EPS 0.000001 struct greateri { template<class T> bool operator()(T const &a, T const &b) const { return a > b; } }; void setIO(string s) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } ll mapi[100001]; ll ans[10000][210]; int main() { flash; ll n,l; cin>>n>>l; ve hed; for (ll i = 0; i < n; ++i) { ll yo;cin>>yo;hed.pb(yo); } ll q; cin>>q; ve que,quz; set<ll>ko; while(q--){ ll yo; cin>>yo; que.pb(yo); ko.insert(yo); } for(auto it:ko)quz.pb(it); ll last=-1; vedos inter; for (ll i = 0; i < quz.size(); ++i) { if(quz[i]!=last+1){ inter.pb({last+1,quz[i]-1}); } inter.pb({quz[i],quz[i]}); last=quz[i]; } if(last!=10000){ inter.pb({last+1,10000}); } for (ll i = 0; i < inter.size(); ++i) { for (ll j = inter[i].first; j <= inter[i].second; ++j) { mapi[j]=i; } } for (ll i = 1; i < hed.size()-l+1; ++i) { ve cur; ll dist=0; for (ll j = i; j < i+l; ++j) { if(hed[j]!=hed[j-i])dist++; } ans[0][mapi[dist]]++; ans[i][mapi[dist]]++; for (ll k = 1; k < hed.size()-l+1; ++k) { if(hed[k+i+l-1]!=hed[k+l-1])dist++; if(hed[k+i-1]!=hed[k-1])dist--; if(k+i+l-1>=n)break; ans[i+k][mapi[dist]]++; ans[k][mapi[dist]]++; } } for (ll i = 0; i < n-l+1; ++i) { for (ll k = 1; k < inter.size(); ++k) { ans[i][k]+=ans[i][k-1]; } } for(auto it:que){ for (ll i = 0; i < n-l+1; ++i) { cout<<ans[i][mapi[it]]<<" "; } cout<<'\n'; } return 0; } //code the AC sol ! // BS/queue/map

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

lot.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
lot.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
lot.cpp: In function 'int main()':
lot.cpp:55:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (ll i = 0; i < quz.size(); ++i)
                  ~~^~~~~~~~~~~~
lot.cpp:66:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (ll i = 0; i < inter.size(); ++i)
                  ~~^~~~~~~~~~~~~~
lot.cpp:73:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (ll i = 1; i < hed.size()-l+1; ++i)
                  ~~^~~~~~~~~~~~~~~~
lot.cpp:83:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (ll k = 1; k < hed.size()-l+1; ++k)
                    ~~^~~~~~~~~~~~~~~~
lot.cpp:94:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (ll k = 1; k < inter.size(); ++k)
                    ~~^~~~~~~~~~~~~~
lot.cpp: In function 'void setIO(std::__cxx11::string)':
lot.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen((s+".in").c_str(),"r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...