Submission #118377

# Submission time Handle Problem Language Result Execution time Memory
118377 2019-06-18T20:22:02 Z davitmarg Lottery (CEOI18_lot) C++17
45 / 100
524 ms 14080 KB
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;

int n,l,a[10004],cnt[2003][2003],Q,k;
int main()
{
    cin>>n>>l;
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);


    cin>>Q;
    if(Q!=1)
    {
        for(int i=1;i<=n-l+1;i++)
            for(int j=i+1;j<=n-l+1;j++)
                for(int p=0;p<l;p++)
                    cnt[i][j]+=(a[i+p]!=a[j+p]);
    }
    for(int QQ=0;QQ<Q;QQ++)
    {
        scanf("%d",&k);
        vector<int> ans(n-l+3);
        if(Q!=1)
        {
            for(int i=1;i<=n-l+1;i++)
                for(int j=i+1;j<=n-l+1;j++)
                {
                    ans[i]+=(cnt[i][j]<=k);
                    ans[j]+=(cnt[i][j]<=k);
                }
        }
        else
        {
        for(int i=1;i<=n-l+1;i++)
            for(int j=i+1;j<=n-l+1;j++)
            {
                int c=0;
                for(int p=0;p<l;p++)
                    c+=(a[i+p]!=a[j+p]);
                ans[i]+=(cnt[i][j]<=k);
                ans[j]+=(cnt[i][j]<=k);
            }
        }
        for(int i=1;i<=n-l+1;i++)
            printf("%d ",ans[i]);
        printf("\n");
    }

	return 0;
}


/*


*/

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",a+i);
         ~~~~~^~~~~~~~~~
lot.cpp:44:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 6 ms 1664 KB Output is correct
11 Correct 6 ms 1664 KB Output is correct
12 Correct 6 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 6 ms 1664 KB Output is correct
11 Correct 6 ms 1664 KB Output is correct
12 Correct 6 ms 1536 KB Output is correct
13 Correct 47 ms 14080 KB Output is correct
14 Correct 524 ms 8944 KB Output is correct
15 Correct 498 ms 8924 KB Output is correct
16 Correct 372 ms 12484 KB Output is correct
17 Correct 452 ms 11768 KB Output is correct
18 Correct 448 ms 11640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 49 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 49 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 6 ms 1664 KB Output is correct
11 Correct 6 ms 1664 KB Output is correct
12 Correct 6 ms 1536 KB Output is correct
13 Correct 47 ms 14080 KB Output is correct
14 Correct 524 ms 8944 KB Output is correct
15 Correct 498 ms 8924 KB Output is correct
16 Correct 372 ms 12484 KB Output is correct
17 Correct 452 ms 11768 KB Output is correct
18 Correct 448 ms 11640 KB Output is correct
19 Runtime error 49 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Halted 0 ms 0 KB -