Submission #920144

# Submission time Handle Problem Language Result Execution time Memory
920144 2024-02-02T06:18:50 Z Sir_Ahmed_Imran Lottery (CEOI18_lot) C++17
65 / 100
85 ms 31576 KB
                              ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define N 2001
ll mod=1e9+7;
ll base=621;
int s[N][N];
int x[N][N];
map<int,int> cnt;
map<int,vector<int>> a;
void Solve(int n,int m){
    ll o,p,q,r;
    vector<int> h,v;
    r=1;
    for(int i=1;i<m;i++)
        r=(r*base)%mod;
    for(int i=p=0;i<n;i++){
        cin>>o;
        v.append(o);
        if(i>=m){
            q=(v[i-m]*r)%mod;
            p=(mod+p-q)%mod;
        }
        p=(p*base+o)%mod;
        if(i+2>m){
            h.append(p);
            cnt[p]++;
        }
    }
    cin>>o>>o;
    for(int i=0;i<=n-m;i++)
        cout<<cnt[h[i]]-1<<' ';
}
void solve(){
    int n,m,o,p,q,r;
    cin>>n>>m;
    if(n>=N){
        Solve(n,m);
        return;
    }
    for(int i=1;i<=n;i++){
        cin>>o;
        x[i][0]=n-m;
        a[o].append(i);
    }
    for(auto& i:a){
        o=i.ss.size();
        for(int j=0;j<o;j++){
            for(int k=j+1;k<o;k++){
                for(int l=0;l<m;l++){
                    p=i.ss[j];
                    q=i.ss[k];
                    if(p-l<1 || q-l>n-m+1)
                        continue;
                    s[p-l][q-l]++;
                    s[q-l][p-l]++;
                    x[p-l][s[q-l][p-l]]++;
                    x[q-l][s[q-l][p-l]]++;
                }
            }
        }
    }
    cin>>o;
    for(int i=0;i<o;i++){
        cin>>p;
        for(int j=1;j<n-m+2;j++)
            cout<<x[j][m-p]<<' ';
        cout<<nl;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Compilation message

lot.cpp: In function 'void solve()':
lot.cpp:42:19: warning: unused variable 'r' [-Wunused-variable]
   42 |     int n,m,o,p,q,r;
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 2 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 2 ms 6744 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 8536 KB Output is correct
12 Correct 2 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 2 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 2 ms 6744 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 8536 KB Output is correct
12 Correct 2 ms 8536 KB Output is correct
13 Correct 18 ms 31576 KB Output is correct
14 Correct 5 ms 17240 KB Output is correct
15 Correct 45 ms 26456 KB Output is correct
16 Correct 85 ms 30032 KB Output is correct
17 Correct 11 ms 28764 KB Output is correct
18 Correct 27 ms 29264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 3 ms 856 KB Output is correct
6 Correct 4 ms 1056 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 3 ms 856 KB Output is correct
13 Correct 3 ms 1112 KB Output is correct
14 Correct 3 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 3 ms 856 KB Output is correct
6 Correct 4 ms 1056 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 3 ms 856 KB Output is correct
13 Correct 3 ms 1112 KB Output is correct
14 Correct 3 ms 856 KB Output is correct
15 Incorrect 4 ms 856 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 2 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 2 ms 6744 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 8536 KB Output is correct
12 Correct 2 ms 8536 KB Output is correct
13 Correct 18 ms 31576 KB Output is correct
14 Correct 5 ms 17240 KB Output is correct
15 Correct 45 ms 26456 KB Output is correct
16 Correct 85 ms 30032 KB Output is correct
17 Correct 11 ms 28764 KB Output is correct
18 Correct 27 ms 29264 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 2 ms 600 KB Output is correct
21 Correct 3 ms 604 KB Output is correct
22 Correct 3 ms 600 KB Output is correct
23 Correct 3 ms 856 KB Output is correct
24 Correct 4 ms 1056 KB Output is correct
25 Correct 2 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 3 ms 856 KB Output is correct
31 Correct 3 ms 1112 KB Output is correct
32 Correct 3 ms 856 KB Output is correct
33 Incorrect 4 ms 856 KB Output isn't correct
34 Halted 0 ms 0 KB -