Submission #883835

#TimeUsernameProblemLanguageResultExecution timeMemory
883835noiaintBinaria (CCO23_day1problem1)C++17
0 / 25
11 ms12892 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif #define file "" #define mp make_pair #define fi first #define se second #define all(x) x.begin(), x.end() #define bit(x) (1LL << (x)) #define getbit(x, i) (((x) >> (i)) & 1) #define popcount __builtin_popcountll mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { return l + rd() % (r - l + 1); } const int N = 1e6 + 5; const int mod = (int)1e9 + 7; // 998244353; const int lg = 25; // lg + 1 const int oo = 1e9; const long long ooo = 1e18; template<class X, class Y> bool mini(X &a, Y b) { return a > b ? (a = b, true) : false; } template<class X, class Y> bool maxi(X &a, Y b) { return a < b ? (a = b, true) : false; } void add(int &a, int b) { a += b; if (a >= mod) a -= mod; if (a < 0) a += mod; } int n, k; int a[N]; int pw(int x, int y) { int res = 1; while (y) { if (y & 1) res = 1LL * res * x % mod; x = 1LL * x * x % mod; y >>= 1; } return res; } int fac[N], inv[N]; void pre() { int n = 1e6; fac[0] = 1; for (int i = 1; i <= n; ++i) fac[i] = 1LL * fac[i - 1] * i % mod; inv[n] = pw(fac[n], mod - 2); for (int i = n; i >= 1; --i) inv[i - 1] = 1LL * inv[i] * i % mod; } int nCk(int n, int k) { if (k < 0 || k > n) return 0; return 1LL * fac[n] * inv[k] % mod * inv[n - k] % mod; } int ok[N]; void process() { pre(); cin >> n >> k; for (int i = 1; i <= n - k + 1; ++i) cin >> a[i]; memset(ok, -1, sizeof ok); for (int i = 1; i <= n - k; ++i) { if (a[i] == a[i + 1]) ok[i] = ok[i + k]; if (a[i] < a[i + 1]) { ok[i] = 0; if (ok[i + k] == 0) { cout << 0; return; } } if (a[i] > a[i + 1]) { ok[i] = 1; if (ok[i + k] == 1) { cout << 0; return; } } if (abs(a[i] - a[i + 1]) > 1) { cout << 0; return; } } int cnt = 0; for (int i = 1; i <= k; ++i) { a[1] -= (ok[i] == 1); cnt += (ok[i] == -1); } debug(cnt, a[1]); cout << nCk(cnt, a[1]); } int main() { ios::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #else // freopen(file".inp", "r", stdin); // freopen(file".out", "w", stdout); #endif int tc = 1; // cin >> tc; while (tc--) { process(); } return 0; } /* */

Compilation message (stderr)

Main.cpp: In function 'void process()':
Main.cpp:8:20: warning: statement has no effect [-Wunused-value]
    8 | #define debug(...) 42
      |                    ^~
Main.cpp:112:5: note: in expansion of macro 'debug'
  112 |     debug(cnt, a[1]);
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...