| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1068714 | PotatoTheWarriorFRTT | Lottery (CEOI18_lot) | C++14 | 104 ms | 1380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p1 = 27644437;
ll p2 = 1000000007;
// ll power(ll x, ll y) {
// y = y%MOD;
// x = x%MOD;
// ll res = 1;
// while(y != 0) {
// if(y%2) {
// res = (res*x)%MOD;
// }
// x = (x*x)%MOD;
// y/=2;
// }
// return res;
// }
void solve() {
int n, l; cin >> n >> l;
int a[n+1];
set<ll> s;
map<ll, vector<int>> mape;
for(int i=0;i<n;i++) {
int x; cin >> x;
s.insert(x);
mape[x].push_back(i);
}
int k = 0;
for(ll l: s) {
for(int i=0;i<mape[l].size();i++) {
a[mape[l][i]] = k;
}
k++;
}
ll powers[l+1];
powers[0] = 1;
for(int i=0;i<l-1;i++) {
powers[i+1] = (powers[i] * p1)%p2;
}
unordered_map<ll, ll> m;
ll hashes[n+1];
for(int i=0;i<n-l+1;i++) {
ll hash = 0;
for(int j=0;j<l;j++) {
hash = (hash + (a[i+j] * powers[j]))%p2;
}
hashes[i] = hash;
m[hash]++;
}
int q; cin >> q;
int ki; cin >> ki; // q=0;k=1;
for(int i=0;i<n-l+1;i++) {
cout << m[hashes[i]]-1 << " ";
}
cout << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
// int t; cin >> t;
// while(t--)
solve();
char dksfjn;
cin >> dksfjn;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
