Submission #1086173

#TimeUsernameProblemLanguageResultExecution timeMemory
1086173dwuyLottery (CEOI18_lot)C++14
100 / 100
264 ms8392 KiB
/** - dwuy -       />  フ       |  _  _|       /`ミ _x ノ      /      |     /  ヽ   ?  / ̄|   | | |  | ( ̄ヽ__ヽ_)_)  \二つ **/ #include <bits/stdc++.h> #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL) #define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout) #define fi first #define se second #define endl "\n" #define len(s) (int)((s).size()) #define MASK(k)(1LL<<(k)) #define TASK "test" using namespace std; typedef tuple<int, int, int> tpiii; typedef pair<double, double> pdd; typedef pair<int, int> pii; typedef long long ll; const long long OO = 1e18; const int MOD = 1e9 + 7; const int INF = 1e9; const int MX = 10003; int n, ln, q; int a[MX]; int qr[MX]; int id[MX]; int ans[MX][103]; vector<int> rv; void nhap(){ cin >> n >> ln; for(int i=1; i<=n; i++) cin >> a[i]; cin >> q; for(int i=1; i<=q; i++){ cin >> qr[i]; rv.push_back(qr[i]); } sort(rv.begin(), rv.end()); rv.erase(unique(rv.begin(), rv.end()), rv.end()); } void solve(){ id[n+1] = 101; for(int i=0; i<len(rv); i++) id[rv[i]] = i + 1; for(int i=n; i>=0; i--) id[i] = id[i]? id[i] : id[i+1]; for(int i=ln + 1; i<=n; i++){ int cur = 0; for(int j=1; j<=ln; j++) cur += a[j] != a[i - ln + j]; ans[ln][id[cur]]++; ans[i][id[cur]]++; for(int j=i+1; j<=n; j++){ cur += a[j] != a[ln + j - i]; cur -= a[j - ln] != a[j - i]; ans[ln + j - i][id[cur]]++; ans[j][id[cur]]++; } } for(int i=1; i<103; i++){ for(int j=1; j<=n; j++) ans[j][i] += ans[j][i-1]; } for(int j=1; j<=q; j++){ for(int i=ln; i<=n; i++) cout << ans[i][id[qr[j]]] << ' '; cout << endl; } } int32_t main(){ fastIO; //file(TASK); nhap(); solve(); return 0; } /* 9 3 1 2 3 1 2 3 1 2 3 1 1 */
#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...