QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395448#3090. Inverse ProblemSamponYWWA 1ms5780kbC++141.5kb2024-04-21 14:45:432024-04-21 14:45:45

Judging History

你现在查看的是最新测评结果

  • [2024-04-21 14:45:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5780kb
  • [2024-04-21 14:45:43]
  • 提交

answer

#include <bits/stdc++.h>
#define db double
#define il inline
#define re register
#define ll long long
#define ui unsigned
#define ull ui ll
#define i128 __int128
#define pii pair<int, int>
#define fi first
#define se second
#define eb emplace_back
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define mems(v, x) memset(v, x, sizeof(v))
#define memc(a, b) memcpy(a, b, sizeof(a))
#define FOR(i, L, R) for(re int i = (L); i <= (R); ++i)
#define ROF(i, R, L) for(re int i = (R); i >= (L); --i)
#define LS i << 1, l, mid
#define RS i << 1 | 1, mid + 1, r
#define popc(x) __builtin_popcount(x)
using namespace std;
using poly = vector<int> ;
using Fp = pair<poly, poly> ;
#define N (1 << 20)
#define P 998244353
il int add(int x, int y) {return x + y < P ? x + y : x + y - P;}
il void addr(int &x, int y) {(x += y) >= P && (x -= P);}
il int qpow(int p, int n = P - 2) {
  int s = 1;
  while(n) {
    if(n & 1) s = 1ll * s * p % P;
    p = 1ll * p * p % P, n >>= 1;
  }
  return s;
}
int n, m, a[N]; bool u[N], v[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  FOR(i, 1, m) cin >> a[i], v[a[i]] = 1; int F = m;
  FOR(i, 1, m - 1) if(a[i] > a[i + 1]) {F = i; break;}
  FOR(i, 1, F) u[i] = 1;
  int cnt = 0, ans = 1;
  FOR(i, 1, n) {
    if(u[i]) {++cnt, --F; if(!F) ++cnt;}
    if(v[i]) continue;
    ans = 1ll * ans * cnt % P, ++cnt;
  }
  cout << ans; return 0;
  cerr << 1.0 * clock() / CLOCKS_PER_SEC;
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5744kb

input:

7 2
2 1

output:

720

result:

ok single line: '720'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5780kb

input:

8 5
2 3 4 5 8

output:

56

result:

wrong answer 1st lines differ - expected: '0', found: '56'