# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1273869 | phtung | Binaria (CCO23_day1problem1) | C++20 | 0 ms | 332 KiB |
#include <bits/stdc++.h>
using namespace std;
#define name "IO"
#define int long long
const int inf = 1e18 + 7;
const int maxn = 1e6 + 5;
const int mod = 1e6 + 3;
int n, k, a[maxn];
namespace subtask2
{
void solve()
{
int res = 0;
for(int mask = 1; mask < (1 << n); mask++)
{
int j = 1, sum = 0;
bool ok = 1;
for(int i = 1; i <= n; i++)
{
sum += ((mask >> (i - 1)) & 1);
if(i - j + 1 < k) continue;
while(i - j + 1 > k)
{
sum -= ((mask >> (j - 1)) & 1);
j++;
}
if(sum != a[j])
{
ok = 0;
break;
}
}
if(ok) res++;
}
cout << res << "\n";
}
}
void solve()
{
cin >> n >> k;
for(int i = 1; i <= n - k + 1; i++) cin >> a[i];
a[0] = a[1];
for(int i = 1; i <= n - k + 1; i++)
{
if(a[i] > k || abs(a[i] - a[i - 1]) > 1)
{
cout << 0 << "\n";
return;
}
}
if(n <= 10)
{
subtask2::solve();
return;
}
}
signed main()
{
if (fopen (name".INP", "r"))
{
freopen (name".INP", "r", stdin);
freopen (name".OUT", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
clock_t start = clock();
int t = 1;
while(t--) solve();
std::cerr << "Time: " << clock() - start << "ms\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |