# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
144495 |
2019-08-16T23:52:21 Z |
12tqian |
Lottery (CEOI18_lot) |
C++14 |
|
200 ms |
65540 KB |
#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
const double PI = 4 * atan(1);
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define vi vector<int>
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define vpi vector<pair<int, int>>
#define vpd vector<pair<double, double>>
#define pd pair<double, double>
#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
void fast_io(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
void io(string taskname){
string fin = taskname + ".in";
string fout = taskname + ".out";
const char* FIN = fin.c_str();
const char* FOUT = fout.c_str();
freopen(FIN, "r", stdin);
freopen(FOUT, "w", stdout);
fast_io();
}
const int MAX = 1e4 + 5;
vi a;
int n, l;
int pre[MAX][MAX];
int cnt[MAX][MAX];
inline int gap(int i, int j){
if(i>j) swap(i, j);
return l - (pre[j-i][j+l-1] -(j == 0?0: pre[j-i][j-1]));
}
int main(){
fast_io();
scanf("%d %d", &n, &l);
f0r(i, n){
int ai;
scanf("%d", &ai);
a.eb(ai);
}
f1r(diff, 1, n){
f0r(i, n){
if(i-diff<0) continue;
if(i-diff==0) pre[diff][i] = (a[i] == a[i-diff]);
else pre[diff][i] = pre[diff][i-1] + (a[i] == a[i-diff]);
}
}
f0r(i, n-l +1){
f1r(j, i+1, n-l+1){
int val = gap(i, j);
cnt[i][val]++;
cnt[j][val]++;
}
}
f0r(i, n-l+1){
f1r(j,1, n){
cnt[i][j] += cnt[i][j-1];
}
}
int q;
scanf("%d", &q);
//cout << q << endl;
while(q--){
int k;
scanf("%d", &k);
f0r(i, n-l + 1){
printf("%d ", cnt[i][k]);
}
printf("\n");
}
return 0;
}
Compilation message
lot.cpp:1:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/stack:200000000")
lot.cpp: In function 'void io(std::__cxx11::string)':
lot.cpp:52:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen(FIN, "r", stdin);
~~~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:53:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen(FOUT, "w", stdout);
~~~~~~~^~~~~~~~~~~~~~~~~~~
lot.cpp: In function 'int main()':
lot.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &l);
~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:70:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &ai);
~~~~~^~~~~~~~~~~
lot.cpp:93:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &q);
~~~~~^~~~~~~~~~
lot.cpp:97:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &k);
~~~~~^~~~~~~~~~
cc1plus: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Wstrict-overflow]
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1144 KB |
Output is correct |
4 |
Correct |
3 ms |
1016 KB |
Output is correct |
5 |
Correct |
3 ms |
1016 KB |
Output is correct |
6 |
Correct |
3 ms |
1144 KB |
Output is correct |
7 |
Correct |
3 ms |
1144 KB |
Output is correct |
8 |
Correct |
4 ms |
2552 KB |
Output is correct |
9 |
Correct |
5 ms |
2552 KB |
Output is correct |
10 |
Correct |
5 ms |
3320 KB |
Output is correct |
11 |
Correct |
5 ms |
3320 KB |
Output is correct |
12 |
Correct |
5 ms |
3192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1144 KB |
Output is correct |
4 |
Correct |
3 ms |
1016 KB |
Output is correct |
5 |
Correct |
3 ms |
1016 KB |
Output is correct |
6 |
Correct |
3 ms |
1144 KB |
Output is correct |
7 |
Correct |
3 ms |
1144 KB |
Output is correct |
8 |
Correct |
4 ms |
2552 KB |
Output is correct |
9 |
Correct |
5 ms |
2552 KB |
Output is correct |
10 |
Correct |
5 ms |
3320 KB |
Output is correct |
11 |
Correct |
5 ms |
3320 KB |
Output is correct |
12 |
Correct |
5 ms |
3192 KB |
Output is correct |
13 |
Runtime error |
200 ms |
40036 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
106 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
106 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1144 KB |
Output is correct |
4 |
Correct |
3 ms |
1016 KB |
Output is correct |
5 |
Correct |
3 ms |
1016 KB |
Output is correct |
6 |
Correct |
3 ms |
1144 KB |
Output is correct |
7 |
Correct |
3 ms |
1144 KB |
Output is correct |
8 |
Correct |
4 ms |
2552 KB |
Output is correct |
9 |
Correct |
5 ms |
2552 KB |
Output is correct |
10 |
Correct |
5 ms |
3320 KB |
Output is correct |
11 |
Correct |
5 ms |
3320 KB |
Output is correct |
12 |
Correct |
5 ms |
3192 KB |
Output is correct |
13 |
Runtime error |
200 ms |
40036 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
14 |
Halted |
0 ms |
0 KB |
- |