Submission #946833

#TimeUsernameProblemLanguageResultExecution timeMemory
946833guagua0407Lottery (CEOI18_lot)C++17
100 / 100
806 ms8788 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int dx[4]={0,0,1,-1}; int dy[4]={1,-1,0,0}; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } int main() {_ int n,l; cin>>n>>l; vector<int> a(n); for(int i=0;i<n;i++){ cin>>a[i]; } int q; cin>>q; vector<int> qs(q); vector<int> vec; for(int i=0;i<q;i++){ cin>>qs[i]; vec.push_back(qs[i]); } sort(all(vec)); vec.resize(unique(all(vec))-vec.begin()); vector<vector<int>> ans(n,vector<int>(vec.size()+1)); for(int d=1;d+l-1<n;d++){ int cur=0; for(int i=0;i<l;i++){ cur+=(a[i]!=a[i+d]); } int pos=lower_bound(all(vec),cur)-vec.begin(); ans[0][pos]++; ans[d][pos]++; for(int i=1;i+d+l-1<n;i++){ cur-=(a[i-1]!=a[i+d-1]); cur+=(a[i+l-1]!=a[i+d+l-1]); int pos=lower_bound(all(vec),cur)-vec.begin(); ans[i][pos]++; ans[i+d][pos]++; } } for(int i=0;i<n;i++){ for(int j=1;j<vec.size();j++){ ans[i][j]+=ans[i][j-1]; } } for(int i=0;i<q;i++){ int pos=lower_bound(all(vec),qs[i])-vec.begin(); for(int j=0;j+l-1<n;j++){ cout<<ans[j][pos]<<' '; } cout<<'\n'; } return 0; } //maybe its multiset not set //yeeorz //laborz

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int j=1;j<vec.size();j++){
      |                     ~^~~~~~~~~~~
lot.cpp: In function 'void setIO(std::string)':
lot.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     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...