QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#203293 | #4646. Photos | yiyiyi# | WA | 236ms | 5248kb | C++14 | 1.6kb | 2023-10-06 16:38:00 | 2023-10-06 16:38:00 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define re register
#define N 120203
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int mod=998244353;
struct node{
int a[3][3],n,m;
void init(int x,int nn,int mm){
n=nn,m=mm;
for (int i=1;i<=n;++i)
for (int j=1;j<=m;++j)
a[i][j]=x?i==j:0;
}
friend node operator *(node a,node b){
node res;res.init(0,a.n,b.m);
for (int i=1;i<=a.n;++i)
for (int j=1;j<=b.m;++j)
for (int k=1;k<=b.n;++k)
res.a[i][j]=(res.a[i][j]+1ll*a.a[i][k]*b.a[k][j])%mod;
return res;
}
friend node operator ^(node x,int p){
node res;res.init(1,x.n,x.m);
for (;p;x=x*x,p>>=1)if (p&1)res=res*x;
return res;
}
}x,y,z;
inline int read(){
int x=0,w=0;char ch=getchar();
while (!isdigit(ch))w|=ch=='-',ch=getchar();
while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
return w?-x:x;
}
pii a[N],b[N];
void solve(){
int n=read(),m=read(),k=0;
for (int i=1;i<=m;++i){
int x=read(),y=read();
a[i]={min(x,y),max(x,y)};
}
sort(a+1,a+1+m);
for (int i=1;i<=m;++i)
if (a[i].fi>b[k].se+1)
b[++k]={a[i].fi,a[i].se};
else b[k].se=max(b[k].se,a[i].se);
x.init(0,1,2);
x.a[1][1]=1;
x.a[1][2]=1;
y.init(0,2,2);
y.a[1][1]=0,y.a[1][2]=-1;
y.a[2][1]=1,y.a[2][2]=3;
z.init(0,2,2);
z.a[1][1]=0,z.a[1][2]=-1;
z.a[2][1]=0,z.a[2][2]=2;
for (int i=1;i<=k;++i){
x=x*(y^(b[i].fi-b[i-1].se-1));
x=x*z;
}
x=x*(y^(n-b[k].se));
cout<<(x.a[1][2]+mod)%mod<<endl;
}
signed main(){
int T=read();
while (T--)solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 236ms
memory: 5248kb
input:
1408 999999987 100000 793040645 793040645 405719679 405719686 109446201 109446201 966244831 966244831 649934379 649934388 270235074 270235080 475603749 475603754 517746359 517746359 692479018 692479026 620056281 620056289 479316573 479316580 99301874 99301874 197649180 197649188 266341447 266341449 ...
output:
633638224 918618569 376801663 774532549 263051780 82690092 131084460 239778094 709347248 326810262 294182113 972258718 740886273 876778123 908531500 401101074 43928585 129509578 494010178 667853498 702904367 522176720 720297418 956798992 931058784 227927814 489184304 815395422 760542660 383948722 13...
result:
wrong answer 1st lines differ - expected: '991600316', found: '633638224'