QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#64529#3090. Inverse ProblemTenshiWA 2ms5432kbC++17931b2022-11-24 23:12:082022-11-24 23:12:11

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-24 23:12:11]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5432kb
  • [2022-11-24 23:12:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << ": " << (x) << endl
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dwn(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()
#define ma 350005
#define mo 998244353
#define x first
#define y second
using pii = pair<int, int>;
using ll = long long;
 
inline void read(int &x){
    int s=0; x=1;
    char ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-')x=-1;ch=getchar();}
    while(ch>='0' && ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
    x*=s;
}
int a[ma],p[ma],ct[ma];
signed main(){
	int n,m,an=1,t1=0,t2=0,err;read(n);read(m);err=m;
	for(int i=1;i<=m;i++)
	{
		read(a[i]);p[a[i]]=1;
		if(a[i]<a[i-1])err=i-1;
		if(err==m)ct[a[i]]++;
	}
	ct[a[err]]++;
	for(int i=1;i<=n;i++)if(p[i])t1+=ct[i];else an=an*(t1+t2)%mo,t2++;
	cout<<an;return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5432kb

input:

7 2
2 1

output:

720

result:

ok single line: '720'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5328kb

input:

8 5
2 3 4 5 8

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 5232kb

input:

498 121
20 35 40 72 79 92 113 117 154 231 243 244 264 268 304 337 362 378 463 477 56 494 495 1 342 395 183 423 291 475 82 422 96 265 83 283 242 34 187 75 74 47 208 380 400 17 202 50 418 73 233 307 181 344 48 149 107 435 365 459 280 55 375 391 403 241 64 374 10 386 322 308 186 136 277 497 332 262 165...

output:

0

result:

ok single line: '0'

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3324kb

input:

499 396
2 3 6 8 11 13 14 15 16 19 22 23 24 32 36 37 40 41 44 51 53 56 57 58 61 62 66 68 74 75 76 79 80 85 86 87 89 90 91 92 96 98 101 102 109 110 111 113 114 115 117 119 122 123 127 129 130 135 140 141 145 149 150 160 163 166 167 171 173 176 177 183 185 195 197 200 204 207 210 216 217 229 230 235 23...

output:

537079739

result:

wrong answer 1st lines differ - expected: '824443602', found: '537079739'