Submission #1038879

# Submission time Handle Problem Language Result Execution time Memory
1038879 2024-07-30T08:37:37 Z vjudge1 Binaria (CCO23_day1problem1) C++17
0 / 25
1 ms 8796 KB
//ᗜˬᗜ
#include<bits/stdc++.h>
#define int long long
#define vi vector <int>
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define pb emplace_back
#define fu(i, a, b) for(int i = (a); i < (b); i++)
#define fub(i, a, b) for(int i = (a); i <= (b); i++)
#define pii pair<int, int>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
const int lim = 1e18;
const int N = 1e6 + 3;
const int M = 1e9 + 7;
int n, k, res;
int a[N], mp[N];
int expo(int a, int b){
    if(b == 0)return 1;
    if(b%2 == 0)return expo((a*a)%M, b/2)%M;
    return (a*expo((a*a)%M, b/2))%M;
}
int bico(int n, int k){
    if(k > n or n < 0 or k < 0)return 0;
    int res = 1;
    fub(i, k+1, n)res = (res*i)%M;
    fub(i, 1, n-k)res = (res*expo(i, N-2))%M;
    return res;

}
signed main(){
    fastio;
    cin >> n >> k;
    fub(i, 1, n-k+1)cin >> a[i];
    memset(mp, -1, sizeof(mp));
    fub(i, 2, n-k+1){
        if(abs(a[i] - a[i-1]) > 1){
            cout << 0;
            return 0;
        }
    }
    fub(i, 2, n-k+1){
        if(a[i] - a[i-1] == 1){
            mp[i+k-1] = 1; mp[i-1] = 0;
        }
        else if(a[i] - a[i-1] == -1){
            mp[i+k-1] = 0; mp[i-1] = 1;
        }
        else mp[i+k-1] = mp[i-1];
    }
    for(int i = n-k; i >= 1; i--)if(a[i] == a[i+1])mp[i] = mp[i+k];
    fub(i, 1, k){
        res += (mp[i] == -1);
        a[1] -= (mp[i] == 1);
    }
    cout << bico(res, a[1]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 1 ms 8796 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 1 ms 8796 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 1 ms 8796 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 1 ms 8796 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 1 ms 8796 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 1 ms 8796 KB Output isn't correct
8 Halted 0 ms 0 KB -