Submission #926475

# Submission time Handle Problem Language Result Execution time Memory
926475 2024-02-13T05:26:37 Z Mohammadamin__Sh Lottery (CEOI18_lot) C++17
45 / 100
3000 ms 4444 KB
//In His Name
#include <bits/stdc++.h>
#pragma GCC optimization("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
using namespace std;
#define ll long long
//#define int ll
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
#define bug(x) cout << "Ah shit , here we go again : " << x <<endl
#define all(x) x.begin() , x.end()
const int maxn = 1e4 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;

int n , l , a[maxn] , q , dp[maxn][101];
vector<int> query , allq;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> l;
    for(int i = 1 ; i <= n ; i++) cin >> a[i];
    cin >> q;
    for(int i = 1 ; i <= q ; i++){
        int x;
        cin >> x;
        query.pb(x) , allq.pb(x);
    }
    sort(all(query));
    query.resize(unique(all(query)) - query.begin());
    for(int i = 1 ; i <= n-l+1 ; i++){
        for(int j = i+1 ; j <= n-l+1 ; j++){
            int w = 0;
            for(int k = 0 ; k < l ; k++) if(a[i+k] != a[j+k]) w++;
            int idx = lower_bound(all(query) , w) - query.begin() + 1 ;
            dp[i][idx]++ , dp[j][idx]++;
        }
    }
    for(int i = 1 ; i <= n-l+1 ; i++) for(int j = 1 ; j <= q ; j++) dp[i][j] += dp[i][j-1];
    for(int j = 0 ; j < q ; j++){
        int x = allq[j];
        int idx = lower_bound(all(query) , x) - query.begin() + 1 ;
        for(int i = 1 ; i <= n-l+1 ; i++) cout << dp[i][idx] << " ";
        cout << '\n';
    }
}

Compilation message

lot.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization("O3")
      |
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 21 ms 2648 KB Output is correct
14 Correct 231 ms 2676 KB Output is correct
15 Correct 256 ms 2676 KB Output is correct
16 Correct 151 ms 2676 KB Output is correct
17 Correct 165 ms 2672 KB Output is correct
18 Correct 187 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 489 ms 4444 KB Output is correct
2 Correct 656 ms 4440 KB Output is correct
3 Correct 359 ms 4440 KB Output is correct
4 Execution timed out 3029 ms 4184 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 489 ms 4444 KB Output is correct
2 Correct 656 ms 4440 KB Output is correct
3 Correct 359 ms 4440 KB Output is correct
4 Execution timed out 3029 ms 4184 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 21 ms 2648 KB Output is correct
14 Correct 231 ms 2676 KB Output is correct
15 Correct 256 ms 2676 KB Output is correct
16 Correct 151 ms 2676 KB Output is correct
17 Correct 165 ms 2672 KB Output is correct
18 Correct 187 ms 2680 KB Output is correct
19 Correct 489 ms 4444 KB Output is correct
20 Correct 656 ms 4440 KB Output is correct
21 Correct 359 ms 4440 KB Output is correct
22 Execution timed out 3029 ms 4184 KB Time limit exceeded
23 Halted 0 ms 0 KB -