| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 967933 | phoenix0423 | Binaria (CCO23_day1problem1) | C++17 | 69 ms | 29008 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
#define lowbit(x) x&-x
const int maxn = 1e6 + 1;
const int N = 1e6 + 3;
const int INF = 1e18;
int f[maxn], inf[maxn];
ll fpow(ll a, ll b){
ll ret = 1;
while(b){
if(b & 1) ret = ret * a % N;
a = a * a % N;
b >>= 1;
}
return ret;
}
ll inv(ll a){ return fpow(a, N - 2);}
void precal(){
f[0] = 1;
for(int i = 1; i < maxn; i++) f[i] = f[i - 1] * i % N;
inf[maxn - 1] = inv(f[maxn - 1]);
for(int i = maxn - 2; i >= 0; i--) inf[i] = inf[i + 1] * (i + 1) % N;
}
ll binom(ll n, ll k){
if(n < k) return 0;
return f[n] * inf[k] % N * inf[n - k] % N;
}
signed main(void){
fastio;
precal();
int n, k;
cin>>n>>k;
vector<int> s(n - k + 1);
int bad = 0;
for(auto &x : s){
cin>>x;
if(x > k) bad = 1;
}
for(int i = 0; i < s.size() - 1; i++){
if(abs(s[i + 1] - s[i]) >= 2) bad = 1;
}
if(bad){
cout<<0<<"\n";
return 0;
}
int fr = k, cnt = 0;
for(int i = 0; i < k; i++){
int nd = -1;
for(int j = i; j + 1 < s.size(); j += k){
if(s[j + 1] - s[j] == 0) continue;
if(s[j + 1] - s[j] == 1){
nd = 0;
break;
}
if(s[j + 1] - s[j] == -1){
nd = 1;
break;
}
}
if(nd != -1) fr--, cnt += nd;
}
cout<<binom(fr, s[0] - cnt)<<"\n";
}
컴파일 시 표준 에러 (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... | ||||
