Submission #1060161

# Submission time Handle Problem Language Result Execution time Memory
1060161 2024-08-15T11:06:55 Z user736482 Lottery (CEOI18_lot) C++17
80 / 100
3000 ms 1004 KB
#include<bits/stdc++.h>
using namespace std;
int n,q,a,k,l;
vector<int>v,poz,match[10007];//duze jedno do usuniecia
int pod[10007];
int main(){
    cin>>n>>l;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }


    cin>>q;
    while(q--){
        int licz[n-l+1];
        for(int b=0;b<n-l+1;b++)
            licz[b]=0;
        cin>>k;
        k=l-k;
        for(int i=0;i<10007;i++)
            pod[i]=0;
        for(int i=0;i<l-1;i++){
            poz.clear();
            for(int j=i+1;j<n;j++){
                if(v[i]==v[j]) poz.push_back(j);
            }
            for(int j=0;j<poz.size();j++){
                pod[-i+poz[j]]++;
            }
        }
        for(int i=l-1;i<n;i++){
            if(i!=l-1){
            poz.clear();
            i=i-l;
            for(int j=i+1;j<n;j++){
                if(v[i]==v[j]) poz.push_back(j);
            }
            for(int j=0;j<poz.size();j++){
                pod[-i+poz[j]]--;
            }
            i=i+l;}
                poz.clear();
            for(int j=i+1;j<n;j++){
                if(v[i]==v[j]) poz.push_back(j);
            }
            for(int j=0;j<poz.size();j++){
                pod[-i+poz[j]]++;
            }
            //for(int j=l-1;j<i;j++) cout<<0<<" ";
            //for(int j=i;j<n;j++)
                //cout<<pod[-i+j]<<" ";
            for(int j=i+1;j<n;j++){
                if(pod[-i+j]>=k){
                    licz[i-l+1]++;
                    licz[j-l+1]++;
                }
                //match[i-l+1].push_back(pod[-i+j]);
                //match[j-l+1].push_back(pod[-i+j]);
            }
        }
        for(int i=0;i<n-l+1;i++)
            cout<<licz[i]<<" ";
        cout<<"\n";
    }
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:28:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for(int j=0;j<poz.size();j++){
      |                         ~^~~~~~~~~~~
lot.cpp:39:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int j=0;j<poz.size();j++){
      |                         ~^~~~~~~~~~~
lot.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(int j=0;j<poz.size();j++){
      |                         ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 600 KB Output is correct
13 Correct 53 ms 728 KB Output is correct
14 Correct 68 ms 732 KB Output is correct
15 Correct 46 ms 604 KB Output is correct
16 Correct 129 ms 752 KB Output is correct
17 Correct 82 ms 736 KB Output is correct
18 Correct 79 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 426 ms 852 KB Output is correct
2 Correct 368 ms 832 KB Output is correct
3 Correct 241 ms 852 KB Output is correct
4 Correct 114 ms 852 KB Output is correct
5 Correct 121 ms 808 KB Output is correct
6 Correct 106 ms 604 KB Output is correct
7 Correct 164 ms 876 KB Output is correct
8 Correct 189 ms 876 KB Output is correct
9 Correct 184 ms 852 KB Output is correct
10 Correct 155 ms 844 KB Output is correct
11 Correct 22 ms 748 KB Output is correct
12 Correct 158 ms 820 KB Output is correct
13 Correct 167 ms 604 KB Output is correct
14 Correct 144 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 426 ms 852 KB Output is correct
2 Correct 368 ms 832 KB Output is correct
3 Correct 241 ms 852 KB Output is correct
4 Correct 114 ms 852 KB Output is correct
5 Correct 121 ms 808 KB Output is correct
6 Correct 106 ms 604 KB Output is correct
7 Correct 164 ms 876 KB Output is correct
8 Correct 189 ms 876 KB Output is correct
9 Correct 184 ms 852 KB Output is correct
10 Correct 155 ms 844 KB Output is correct
11 Correct 22 ms 748 KB Output is correct
12 Correct 158 ms 820 KB Output is correct
13 Correct 167 ms 604 KB Output is correct
14 Correct 144 ms 604 KB Output is correct
15 Correct 326 ms 844 KB Output is correct
16 Correct 134 ms 948 KB Output is correct
17 Correct 192 ms 860 KB Output is correct
18 Correct 155 ms 928 KB Output is correct
19 Correct 107 ms 932 KB Output is correct
20 Correct 109 ms 860 KB Output is correct
21 Correct 123 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 600 KB Output is correct
13 Correct 53 ms 728 KB Output is correct
14 Correct 68 ms 732 KB Output is correct
15 Correct 46 ms 604 KB Output is correct
16 Correct 129 ms 752 KB Output is correct
17 Correct 82 ms 736 KB Output is correct
18 Correct 79 ms 600 KB Output is correct
19 Correct 426 ms 852 KB Output is correct
20 Correct 368 ms 832 KB Output is correct
21 Correct 241 ms 852 KB Output is correct
22 Correct 114 ms 852 KB Output is correct
23 Correct 121 ms 808 KB Output is correct
24 Correct 106 ms 604 KB Output is correct
25 Correct 164 ms 876 KB Output is correct
26 Correct 189 ms 876 KB Output is correct
27 Correct 184 ms 852 KB Output is correct
28 Correct 155 ms 844 KB Output is correct
29 Correct 22 ms 748 KB Output is correct
30 Correct 158 ms 820 KB Output is correct
31 Correct 167 ms 604 KB Output is correct
32 Correct 144 ms 604 KB Output is correct
33 Correct 326 ms 844 KB Output is correct
34 Correct 134 ms 948 KB Output is correct
35 Correct 192 ms 860 KB Output is correct
36 Correct 155 ms 928 KB Output is correct
37 Correct 107 ms 932 KB Output is correct
38 Correct 109 ms 860 KB Output is correct
39 Correct 123 ms 860 KB Output is correct
40 Execution timed out 3084 ms 1004 KB Time limit exceeded
41 Halted 0 ms 0 KB -