#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pi>> vvpi;
typedef vector<ld> vd;
typedef vector<long long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int M = 1e6+3;
void init(string name)
{
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
}
void solve()
{
int n,k;cin >> n >> k;
vi arr(n-k+1);
FOR(i,0,n-k+1)cin >> arr[i];
reverse(arr.begin(),arr.end());
ll ans = 0;
FOR(val,0,1<<n){
vi arr2(n,0);
int cnt = 0;
int i = val;
FOR(j,0,k){
arr2[j] = i%2;
i /= 2;
cnt += arr2[j];
}
bool ok = 1;
FOR(j,0,arr.size()){
if(arr[j] != cnt){
ok = 0;
break;
}
arr2[j+k] = i%2;
i/=2;
cnt += arr2[j+k];
cnt -= arr2[j];
}
cerr << val << " ";
for(int a:arr2)cerr << a;
cerr << " " << ok << endl;
if(ok)ans ++;
ans %= M;
}
cout << ans << endl;
}
int main()
{
fastIO();
// init("test");
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
Compilation message
Main.cpp: In function 'void solve()':
Main.cpp:24:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | #define FOR(i, a, b) for (int i = a; i < (b); i++)
| ^
Main.cpp:70:9: note: in expansion of macro 'FOR'
70 | FOR(j,0,arr.size()){
| ^~~
Main.cpp: In function 'void init(std::string)':
Main.cpp:44:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:45:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
45 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
460 KB |
Output is correct |
4 |
Correct |
16 ms |
348 KB |
Output is correct |
5 |
Correct |
16 ms |
348 KB |
Output is correct |
6 |
Correct |
15 ms |
348 KB |
Output is correct |
7 |
Correct |
15 ms |
600 KB |
Output is correct |
8 |
Correct |
16 ms |
348 KB |
Output is correct |
9 |
Correct |
17 ms |
468 KB |
Output is correct |
10 |
Correct |
17 ms |
460 KB |
Output is correct |
11 |
Correct |
16 ms |
472 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
460 KB |
Output is correct |
4 |
Correct |
16 ms |
348 KB |
Output is correct |
5 |
Correct |
16 ms |
348 KB |
Output is correct |
6 |
Correct |
15 ms |
348 KB |
Output is correct |
7 |
Correct |
15 ms |
600 KB |
Output is correct |
8 |
Correct |
16 ms |
348 KB |
Output is correct |
9 |
Correct |
17 ms |
468 KB |
Output is correct |
10 |
Correct |
17 ms |
460 KB |
Output is correct |
11 |
Correct |
16 ms |
472 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
15 ms |
348 KB |
Output is correct |
14 |
Correct |
21 ms |
348 KB |
Output is correct |
15 |
Correct |
15 ms |
464 KB |
Output is correct |
16 |
Correct |
16 ms |
348 KB |
Output is correct |
17 |
Correct |
15 ms |
476 KB |
Output is correct |
18 |
Correct |
24 ms |
464 KB |
Output is correct |
19 |
Correct |
16 ms |
348 KB |
Output is correct |
20 |
Correct |
16 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
460 KB |
Output is correct |
4 |
Correct |
16 ms |
348 KB |
Output is correct |
5 |
Correct |
16 ms |
348 KB |
Output is correct |
6 |
Correct |
15 ms |
348 KB |
Output is correct |
7 |
Correct |
15 ms |
600 KB |
Output is correct |
8 |
Correct |
16 ms |
348 KB |
Output is correct |
9 |
Correct |
17 ms |
468 KB |
Output is correct |
10 |
Correct |
17 ms |
460 KB |
Output is correct |
11 |
Correct |
16 ms |
472 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
15 ms |
348 KB |
Output is correct |
14 |
Correct |
21 ms |
348 KB |
Output is correct |
15 |
Correct |
15 ms |
464 KB |
Output is correct |
16 |
Correct |
16 ms |
348 KB |
Output is correct |
17 |
Correct |
15 ms |
476 KB |
Output is correct |
18 |
Correct |
24 ms |
464 KB |
Output is correct |
19 |
Correct |
16 ms |
348 KB |
Output is correct |
20 |
Correct |
16 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Incorrect |
254 ms |
596 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
460 KB |
Output is correct |
4 |
Correct |
16 ms |
348 KB |
Output is correct |
5 |
Correct |
16 ms |
348 KB |
Output is correct |
6 |
Correct |
15 ms |
348 KB |
Output is correct |
7 |
Correct |
15 ms |
600 KB |
Output is correct |
8 |
Correct |
16 ms |
348 KB |
Output is correct |
9 |
Correct |
17 ms |
468 KB |
Output is correct |
10 |
Correct |
17 ms |
460 KB |
Output is correct |
11 |
Correct |
16 ms |
472 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
15 ms |
348 KB |
Output is correct |
14 |
Correct |
21 ms |
348 KB |
Output is correct |
15 |
Correct |
15 ms |
464 KB |
Output is correct |
16 |
Correct |
16 ms |
348 KB |
Output is correct |
17 |
Correct |
15 ms |
476 KB |
Output is correct |
18 |
Correct |
24 ms |
464 KB |
Output is correct |
19 |
Correct |
16 ms |
348 KB |
Output is correct |
20 |
Correct |
16 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Incorrect |
254 ms |
596 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
460 KB |
Output is correct |
4 |
Correct |
16 ms |
348 KB |
Output is correct |
5 |
Correct |
16 ms |
348 KB |
Output is correct |
6 |
Correct |
15 ms |
348 KB |
Output is correct |
7 |
Correct |
15 ms |
600 KB |
Output is correct |
8 |
Correct |
16 ms |
348 KB |
Output is correct |
9 |
Correct |
17 ms |
468 KB |
Output is correct |
10 |
Correct |
17 ms |
460 KB |
Output is correct |
11 |
Correct |
16 ms |
472 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
15 ms |
348 KB |
Output is correct |
14 |
Correct |
21 ms |
348 KB |
Output is correct |
15 |
Correct |
15 ms |
464 KB |
Output is correct |
16 |
Correct |
16 ms |
348 KB |
Output is correct |
17 |
Correct |
15 ms |
476 KB |
Output is correct |
18 |
Correct |
24 ms |
464 KB |
Output is correct |
19 |
Correct |
16 ms |
348 KB |
Output is correct |
20 |
Correct |
16 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Incorrect |
254 ms |
596 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
460 KB |
Output is correct |
4 |
Correct |
16 ms |
348 KB |
Output is correct |
5 |
Correct |
16 ms |
348 KB |
Output is correct |
6 |
Correct |
15 ms |
348 KB |
Output is correct |
7 |
Correct |
15 ms |
600 KB |
Output is correct |
8 |
Correct |
16 ms |
348 KB |
Output is correct |
9 |
Correct |
17 ms |
468 KB |
Output is correct |
10 |
Correct |
17 ms |
460 KB |
Output is correct |
11 |
Correct |
16 ms |
472 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
15 ms |
348 KB |
Output is correct |
14 |
Correct |
21 ms |
348 KB |
Output is correct |
15 |
Correct |
15 ms |
464 KB |
Output is correct |
16 |
Correct |
16 ms |
348 KB |
Output is correct |
17 |
Correct |
15 ms |
476 KB |
Output is correct |
18 |
Correct |
24 ms |
464 KB |
Output is correct |
19 |
Correct |
16 ms |
348 KB |
Output is correct |
20 |
Correct |
16 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Incorrect |
254 ms |
596 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |