답안 #946833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946833 2024-03-15T06:19:19 Z guagua0407 Lottery (CEOI18_lot) C++17
100 / 100
806 ms 8788 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

int main() {_
    int n,l;
    cin>>n>>l;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int q;
    cin>>q;
    vector<int> qs(q);
    vector<int> vec;
    for(int i=0;i<q;i++){
        cin>>qs[i];
        vec.push_back(qs[i]);
    }
    sort(all(vec));
    vec.resize(unique(all(vec))-vec.begin());
    vector<vector<int>> ans(n,vector<int>(vec.size()+1));
    for(int d=1;d+l-1<n;d++){
        int cur=0;
        for(int i=0;i<l;i++){
            cur+=(a[i]!=a[i+d]);
        }
        int pos=lower_bound(all(vec),cur)-vec.begin();
        ans[0][pos]++;
        ans[d][pos]++;
        for(int i=1;i+d+l-1<n;i++){
            cur-=(a[i-1]!=a[i+d-1]);
            cur+=(a[i+l-1]!=a[i+d+l-1]);
            int pos=lower_bound(all(vec),cur)-vec.begin();
            ans[i][pos]++;
            ans[i+d][pos]++;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<vec.size();j++){
            ans[i][j]+=ans[i][j-1];
        }
    }
    for(int i=0;i<q;i++){
        int pos=lower_bound(all(vec),qs[i])-vec.begin();
        for(int j=0;j+l-1<n;j++){
            cout<<ans[j][pos]<<' ';
        }
        cout<<'\n';
    }
    return 0;
}
//maybe its multiset not set
//yeeorz
//laborz

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int j=1;j<vec.size();j++){
      |                     ~^~~~~~~~~~~
lot.cpp: In function 'void setIO(std::string)':
lot.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 13 ms 604 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 7 ms 604 KB Output is correct
16 Correct 13 ms 716 KB Output is correct
17 Correct 14 ms 1116 KB Output is correct
18 Correct 12 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 1048 KB Output is correct
2 Correct 254 ms 860 KB Output is correct
3 Correct 202 ms 1056 KB Output is correct
4 Correct 206 ms 1112 KB Output is correct
5 Correct 69 ms 1152 KB Output is correct
6 Correct 194 ms 1364 KB Output is correct
7 Correct 68 ms 1116 KB Output is correct
8 Correct 111 ms 1116 KB Output is correct
9 Correct 211 ms 1124 KB Output is correct
10 Correct 215 ms 1116 KB Output is correct
11 Correct 10 ms 604 KB Output is correct
12 Correct 113 ms 860 KB Output is correct
13 Correct 89 ms 1128 KB Output is correct
14 Correct 87 ms 1136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 1048 KB Output is correct
2 Correct 254 ms 860 KB Output is correct
3 Correct 202 ms 1056 KB Output is correct
4 Correct 206 ms 1112 KB Output is correct
5 Correct 69 ms 1152 KB Output is correct
6 Correct 194 ms 1364 KB Output is correct
7 Correct 68 ms 1116 KB Output is correct
8 Correct 111 ms 1116 KB Output is correct
9 Correct 211 ms 1124 KB Output is correct
10 Correct 215 ms 1116 KB Output is correct
11 Correct 10 ms 604 KB Output is correct
12 Correct 113 ms 860 KB Output is correct
13 Correct 89 ms 1128 KB Output is correct
14 Correct 87 ms 1136 KB Output is correct
15 Correct 204 ms 872 KB Output is correct
16 Correct 167 ms 1152 KB Output is correct
17 Correct 230 ms 1132 KB Output is correct
18 Correct 197 ms 1116 KB Output is correct
19 Correct 221 ms 1112 KB Output is correct
20 Correct 211 ms 1144 KB Output is correct
21 Correct 216 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 13 ms 604 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 7 ms 604 KB Output is correct
16 Correct 13 ms 716 KB Output is correct
17 Correct 14 ms 1116 KB Output is correct
18 Correct 12 ms 604 KB Output is correct
19 Correct 287 ms 1048 KB Output is correct
20 Correct 254 ms 860 KB Output is correct
21 Correct 202 ms 1056 KB Output is correct
22 Correct 206 ms 1112 KB Output is correct
23 Correct 69 ms 1152 KB Output is correct
24 Correct 194 ms 1364 KB Output is correct
25 Correct 68 ms 1116 KB Output is correct
26 Correct 111 ms 1116 KB Output is correct
27 Correct 211 ms 1124 KB Output is correct
28 Correct 215 ms 1116 KB Output is correct
29 Correct 10 ms 604 KB Output is correct
30 Correct 113 ms 860 KB Output is correct
31 Correct 89 ms 1128 KB Output is correct
32 Correct 87 ms 1136 KB Output is correct
33 Correct 204 ms 872 KB Output is correct
34 Correct 167 ms 1152 KB Output is correct
35 Correct 230 ms 1132 KB Output is correct
36 Correct 197 ms 1116 KB Output is correct
37 Correct 221 ms 1112 KB Output is correct
38 Correct 211 ms 1144 KB Output is correct
39 Correct 216 ms 1112 KB Output is correct
40 Correct 441 ms 2384 KB Output is correct
41 Correct 12 ms 1624 KB Output is correct
42 Correct 360 ms 2464 KB Output is correct
43 Correct 360 ms 2028 KB Output is correct
44 Correct 323 ms 2128 KB Output is correct
45 Correct 806 ms 8648 KB Output is correct
46 Correct 19 ms 5208 KB Output is correct
47 Correct 485 ms 8788 KB Output is correct
48 Correct 427 ms 6476 KB Output is correct
49 Correct 429 ms 7236 KB Output is correct