Submission #118378

# Submission time Handle Problem Language Result Execution time Memory
118378 2019-06-18T20:23:06 Z davitmarg Lottery (CEOI18_lot) C++17
45 / 100
3000 ms 14116 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]+=(c<=k);
                    ans[j]+=(c<=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 384 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 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 768 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 5 ms 896 KB Output is correct
9 Correct 4 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 384 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 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 768 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 5 ms 896 KB Output is correct
9 Correct 4 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 50 ms 14116 KB Output is correct
14 Correct 521 ms 8956 KB Output is correct
15 Correct 532 ms 9012 KB Output is correct
16 Correct 375 ms 12536 KB Output is correct
17 Correct 450 ms 11768 KB Output is correct
18 Correct 445 ms 11804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 168 ms 460 KB Output is correct
2 Correct 296 ms 504 KB Output is correct
3 Correct 173 ms 504 KB Output is correct
4 Execution timed out 3029 ms 512 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 168 ms 460 KB Output is correct
2 Correct 296 ms 504 KB Output is correct
3 Correct 173 ms 504 KB Output is correct
4 Execution timed out 3029 ms 512 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 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 768 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 5 ms 896 KB Output is correct
9 Correct 4 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 50 ms 14116 KB Output is correct
14 Correct 521 ms 8956 KB Output is correct
15 Correct 532 ms 9012 KB Output is correct
16 Correct 375 ms 12536 KB Output is correct
17 Correct 450 ms 11768 KB Output is correct
18 Correct 445 ms 11804 KB Output is correct
19 Correct 168 ms 460 KB Output is correct
20 Correct 296 ms 504 KB Output is correct
21 Correct 173 ms 504 KB Output is correct
22 Execution timed out 3029 ms 512 KB Time limit exceeded
23 Halted 0 ms 0 KB -