QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#395448 | #3090. Inverse Problem | SamponYW | WA | 1ms | 5780kb | C++14 | 1.5kb | 2024-04-21 14:45:43 | 2024-04-21 14:45:45 |
Judging History
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'