QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#292002 | #6193. Junk Problem | Crysfly# | AC ✓ | 2ms | 8772kb | C++14 | 3.5kb | 2023-12-27 15:44:01 | 2023-12-27 15:44:01 |
Judging History
answer
// what is matter? never mind.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 998244353
struct modint{
int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
friend modint operator +(modint a,modint b){return a+=b;}
friend modint operator -(modint a,modint b){return a-=b;}
friend modint operator *(modint a,modint b){return a*=b;}
friend modint operator /(modint a,modint b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,int b){return a.x==b;}
friend bool operator !=(modint a,int b){return a.x!=b;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 200005
#define inf 0x3f3f3f3f
modint f[505][505];
modint det(modint a[505][505],int n)
{
modint res=1;
For(j,1,n){
For(i,j,n)
if(a[i][j].x){
if(i!=j)swap(a[i],a[j]),res=-res;
break;
}
if(!a[j][j].x)return 0;
res*=a[j][j];
modint iv=1/a[j][j];
For(i,j+1,n){
modint tmp=a[i][j]*iv;
For(k,j,n)a[i][k]-=a[j][k]*tmp;
}
}
return res;
}
int n,m,n1,n2;
int a[maxn],b[maxn];
int sx[maxn],sy[maxn],tx[maxn],ty[maxn];
/*
consider only one Special Edge.
the ans is: ( (0,a) -> (x,y+1) ) multiply ( (x,y) -> (n,b) ).
consider multiple edges.
the ans is a det.
*/
modint F(int x,int y){
if(x<0||y<0)return 0;
return C(x+y,y);
}
signed main()
{
n=read(),m=read(),n1=read(),n2=read();
For(i,1,n1)a[i]=read();
For(i,1,n1)b[i]=read();
For(i,1,n1)sx[i]=1,sy[i]=a[i],tx[i]=n,ty[i]=b[i];
For(i,1,n2){
int x=read(),y=read();
sx[i+n1]=x,sy[i+n1]=y;
tx[i+n1]=x,ty[i+n1]=y+1;
}
For(i,1,n1+n2)
For(j,1,n1+n2){
if(i==j && i>n1) continue;
f[i][j]=F(tx[j]-sx[i],ty[j]-sy[i]);
if(j>n1) f[i][j]=-f[i][j];
}
// For(i,1,n1+n2){
// For(j,1,n1+n2){
// cout<<f[i][j].x<<" \n"[j==n1+n2];
// }
// }
modint res=det(f,n1+n2);
cout<<res.x;
return 0;
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 8240kb
input:
2 2 1 2 2 1 1 1 2 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 6672kb
input:
3 4 2 1 1 4 1 4 2 2
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 2ms
memory: 8684kb
input:
10 10 3 4 1 2 3 8 9 10 2 3 2 5 4 6 7 8
output:
388035318
result:
ok 1 number(s): "388035318"
Test #4:
score: 0
Accepted
time: 2ms
memory: 8712kb
input:
10 10 5 0 1 2 3 4 8 4 6 8 9 10
output:
534075044
result:
ok 1 number(s): "534075044"
Test #5:
score: 0
Accepted
time: 0ms
memory: 8352kb
input:
10 10 5 10 1 2 3 6 9 6 7 8 9 10 5 7 1 7 8 8 8 1 9 2 9 7 10 1 7 2 6 7 6 1
output:
113105350
result:
ok 1 number(s): "113105350"
Test #6:
score: 0
Accepted
time: 2ms
memory: 8540kb
input:
10 10 5 20 1 2 4 6 8 1 3 4 6 8 9 6 6 5 9 8 2 9 7 6 9 3 8 3 5 4 3 8 4 5 5 9 3 3 4 2 4 8 8 5 10 7 1 8 7 3 5 2 1 5
output:
312012
result:
ok 1 number(s): "312012"
Test #7:
score: 0
Accepted
time: 0ms
memory: 8392kb
input:
10 10 5 30 1 3 5 6 8 6 7 8 9 10 9 9 8 7 4 8 10 6 3 9 9 6 7 1 1 5 5 4 2 9 7 5 3 3 8 2 2 5 1 9 6 2 8 5 6 5 8 9 3 7 3 1 10 2 4 3 2 2 6 9 7 3 7 8 1 7 4 1 4 6
output:
720108525
result:
ok 1 number(s): "720108525"
Test #8:
score: 0
Accepted
time: 2ms
memory: 6672kb
input:
10 10 1 0 1 3
output:
55
result:
ok 1 number(s): "55"
Test #9:
score: 0
Accepted
time: 0ms
memory: 8544kb
input:
10 10 2 10 2 6 5 6 8 1 9 3 3 7 9 8 7 8 7 1 2 4 8 7 5 5 6 9
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 2ms
memory: 8368kb
input:
10 10 3 20 3 4 5 4 6 9 2 3 3 2 1 9 7 5 10 7 6 9 3 4 5 1 1 6 5 6 8 4 10 1 5 3 7 7 4 7 9 6 10 5 3 6 5 8 8 8
output:
0
result:
ok 1 number(s): "0"
Test #11:
score: 0
Accepted
time: 1ms
memory: 6760kb
input:
10 10 4 30 1 2 3 4 5 6 7 9 10 1 8 1 1 2 5 7 2 3 10 8 7 9 5 3 6 2 9 9 9 1 2 7 10 4 4 4 4 8 7 7 6 7 7 1 4 2 5 1 9 6 9 3 2 9 3 9 3 7 3 5 7 4 1 4 1 9 8 5
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 2ms
memory: 7984kb
input:
10 10 6 30 3 4 5 6 7 8 5 6 7 8 9 10 3 4 10 8 9 6 6 5 6 9 1 9 2 4 10 6 7 4 7 6 6 7 3 8 7 2 5 5 1 1 2 1 8 1 4 3 8 6 5 9 2 6 8 4 1 7 5 2 3 2 1 4 2 8 8 9 6 1 4 5
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 2ms
memory: 8604kb
input:
10 10 7 30 1 2 3 4 5 9 10 2 3 4 7 8 9 10 9 3 10 4 2 3 2 8 5 3 2 6 1 4 7 1 6 4 3 5 6 9 10 2 4 6 5 6 7 6 4 3 8 7 6 6 9 5 8 4 7 4 1 8 5 8 3 7 9 8 7 8 8 1 3 3 10 6 8 9
output:
58415340
result:
ok 1 number(s): "58415340"
Test #14:
score: 0
Accepted
time: 0ms
memory: 7936kb
input:
10 10 4 20 1 2 5 7 5 7 8 10 10 3 3 2 10 6 9 7 9 4 1 4 8 6 6 3 7 5 3 8 2 3 4 6 6 8 7 8 3 6 8 8 6 6 4 2 4 9 1 1
output:
212921229
result:
ok 1 number(s): "212921229"
Test #15:
score: 0
Accepted
time: 0ms
memory: 8664kb
input:
10 10 6 20 1 2 4 7 8 9 3 4 5 8 9 10 3 5 6 5 4 5 6 1 1 8 8 8 2 5 4 9 6 3 4 2 4 7 5 2 9 7 3 8 2 2 9 4 7 6 1 4 8 5 2 7
output:
215578944
result:
ok 1 number(s): "215578944"
Test #16:
score: 0
Accepted
time: 0ms
memory: 8628kb
input:
100 10 6 20 1 2 3 4 6 7 2 4 5 6 7 9 17 6 46 9 76 2 75 4 27 6 22 4 5 1 33 7 78 1 38 7 83 9 32 5 97 3 25 8 90 3 50 7 87 1 61 3 39 1 28 9
output:
266132935
result:
ok 1 number(s): "266132935"
Test #17:
score: 0
Accepted
time: 2ms
memory: 8160kb
input:
100 10 5 20 1 2 3 4 5 2 5 6 8 9 73 2 56 8 57 9 60 3 5 8 74 3 92 2 72 9 17 4 61 8 41 7 88 8 91 4 52 7 50 4 94 9 64 7 27 6 14 7 4 2
output:
558957370
result:
ok 1 number(s): "558957370"
Test #18:
score: 0
Accepted
time: 0ms
memory: 8772kb
input:
100 10 3 20 6 7 9 6 9 10 90 4 72 2 19 1 19 9 64 3 85 3 66 7 66 5 19 6 84 5 16 1 55 6 74 4 31 3 73 4 52 2 32 9 87 2 4 8 70 2
output:
0
result:
ok 1 number(s): "0"
Test #19:
score: 0
Accepted
time: 2ms
memory: 8660kb
input:
100 10 4 30 2 5 6 7 2 6 8 9 52 1 26 6 39 8 44 9 38 5 11 9 47 3 46 5 42 9 14 2 65 7 68 5 44 1 20 2 42 7 12 4 6 8 73 5 87 2 17 2 28 8 100 4 25 1 3 1 8 2 12 6 36 3 3 3 86 1 95 7
output:
803776201
result:
ok 1 number(s): "803776201"
Test #20:
score: 0
Accepted
time: 0ms
memory: 8704kb
input:
100 10 5 50 1 2 3 4 5 2 3 8 9 10 8 1 45 7 69 9 85 6 51 8 40 2 85 4 67 7 65 3 28 7 98 7 94 3 47 5 50 3 44 3 76 8 50 9 48 7 81 9 16 4 70 5 22 3 80 3 22 6 33 3 57 2 4 5 6 5 18 9 74 5 11 5 14 2 3 4 3 1 68 4 37 5 93 7 42 8 78 6 71 2 27 7 57 7 96 6 69 1 30 2 9 6 39 8 54 8 2 3 78 4
output:
463426103
result:
ok 1 number(s): "463426103"
Test #21:
score: 0
Accepted
time: 0ms
memory: 8108kb
input:
100 10 6 50 3 4 5 6 8 9 5 6 7 8 9 10 56 1 39 8 84 6 4 4 66 6 88 8 95 8 24 9 78 2 54 5 85 1 3 4 81 5 36 6 69 9 47 1 60 2 26 9 68 9 8 3 13 2 31 3 25 2 72 3 88 3 81 9 97 1 67 1 90 4 86 6 74 8 56 7 50 6 94 5 67 5 49 3 42 7 42 5 53 7 87 1 80 3 12 6 96 6 58 7 15 9 46 7 89 3 17 6 71 6 6 5
output:
123434985
result:
ok 1 number(s): "123434985"
Test #22:
score: 0
Accepted
time: 1ms
memory: 6628kb
input:
10 100 3 50 14 20 52 44 57 68 1 24 8 43 2 26 6 57 5 56 3 85 2 3 10 80 4 18 9 30 6 6 5 3 4 91 5 50 9 37 4 66 10 10 9 7 7 15 7 46 4 15 2 68 9 50 8 39 5 5 8 64 9 4 5 79 8 59 9 19 10 23 7 19 8 6 5 38 8 92 6 93 5 94 1 21 6 85 5 71 4 60 9 23 3 61 2 76 4 21 8 82 6 99 9 55 3 96 9 64
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 0ms
memory: 8716kb
input:
10 100 5 50 12 14 45 50 54 20 24 68 80 88 5 37 10 43 5 86 1 18 6 40 2 83 8 64 6 97 4 31 2 59 3 63 6 17 1 57 5 92 4 9 3 96 9 88 6 71 8 93 10 32 2 32 2 3 6 60 5 57 8 86 4 23 4 40 7 84 10 51 8 83 5 10 8 75 5 44 7 43 1 65 10 20 1 15 3 71 1 30 2 98 8 14 1 92 5 69 10 53 8 48 4 43 3 92 6 74 5 41 3 67
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 1ms
memory: 6680kb
input:
10 100 7 50 11 13 21 32 35 67 89 41 56 70 75 90 91 92 3 49 8 39 5 39 1 66 7 15 5 73 8 22 6 24 7 40 1 87 6 28 6 30 3 14 9 40 2 77 5 24 1 63 7 29 6 73 4 19 8 63 10 88 6 56 7 70 7 79 4 56 3 96 2 79 5 85 3 39 7 35 3 35 6 87 1 48 10 38 1 42 3 53 4 60 1 12 9 94 9 4 8 50 9 62 10 60 4 50 7 23 3 81 4 98 2 57...
output:
0
result:
ok 1 number(s): "0"
Test #25:
score: 0
Accepted
time: 1ms
memory: 6768kb
input:
100 100 10 50 4 11 20 24 33 37 38 57 60 71 42 47 48 62 68 80 84 87 91 95 28 22 49 40 89 44 72 33 66 29 99 80 38 92 18 80 36 73 63 26 65 31 48 52 84 6 34 95 37 80 3 94 23 40 37 84 42 75 33 49 97 13 37 19 57 92 78 5 92 89 82 49 23 36 95 85 64 23 86 88 97 51 50 55 51 53 66 67 100 95 54 39 50 34 23 32 9...
output:
0
result:
ok 1 number(s): "0"
Test #26:
score: 0
Accepted
time: 0ms
memory: 6756kb
input:
100 100 20 50 1 2 9 11 12 15 17 18 20 22 25 34 45 52 56 59 67 71 78 83 23 25 29 35 37 38 53 61 67 68 69 77 80 81 82 85 87 91 95 96 100 15 13 38 42 54 11 31 28 31 14 56 17 5 51 46 59 40 5 72 24 41 100 77 42 70 81 96 3 27 60 9 21 36 40 90 99 51 59 57 51 63 96 29 6 17 23 41 3 45 5 4 84 22 21 63 19 6 59...
output:
0
result:
ok 1 number(s): "0"
Test #27:
score: 0
Accepted
time: 2ms
memory: 8652kb
input:
100 100 30 50 6 9 10 11 14 16 17 18 19 20 21 22 24 25 26 28 30 31 32 39 48 51 58 63 64 65 67 73 78 82 33 34 38 40 42 50 52 53 54 56 60 62 64 68 70 71 74 80 81 84 86 87 88 89 90 95 97 98 99 100 77 7 74 44 83 60 58 21 91 40 30 37 97 9 84 19 78 11 46 23 90 54 40 94 3 46 24 93 65 73 16 34 24 36 40 88 57...
output:
0
result:
ok 1 number(s): "0"
Test #28:
score: 0
Accepted
time: 2ms
memory: 6696kb
input:
100 100 40 50 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 22 26 27 30 33 34 37 38 39 44 45 50 53 54 56 57 62 63 65 66 67 71 77 78 16 19 20 32 33 35 39 41 47 48 52 53 56 61 62 64 65 66 69 70 72 74 75 76 77 78 81 82 83 84 86 87 88 89 90 96 97 98 99 100 57 4 43 42 36 70 93 11 49 46 41 17 76 14 4 92 92 88 7...
output:
696316238
result:
ok 1 number(s): "696316238"
Test #29:
score: 0
Accepted
time: 0ms
memory: 8552kb
input:
100 100 50 50 4 5 6 7 9 10 11 12 13 14 15 16 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 35 39 40 41 44 45 46 49 50 51 52 53 57 60 64 66 73 77 78 80 82 92 98 23 26 29 33 35 36 39 41 42 47 48 49 54 55 56 57 58 59 60 61 62 63 64 66 68 70 71 72 73 74 76 77 79 81 82 83 84 88 89 90 91 92 93 94 95 96 97 ...
output:
0
result:
ok 1 number(s): "0"
Test #30:
score: 0
Accepted
time: 2ms
memory: 8288kb
input:
100 100 50 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 17 18 19 20 21 22 25 26 28 29 31 32 33 36 37 38 39 40 41 42 43 44 45 46 47 50 57 59 62 63 64 65 70 71 77 78 4 6 10 13 29 32 37 41 43 44 46 47 52 53 55 58 62 63 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 83 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...
output:
55822359
result:
ok 1 number(s): "55822359"
Test #31:
score: 0
Accepted
time: 0ms
memory: 7988kb
input:
100 100 50 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 29 31 32 34 35 36 37 38 39 40 41 47 48 49 50 51 52 53 55 60 65 67 68 20 24 28 31 33 35 40 45 46 54 55 56 57 58 59 61 62 63 66 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
268820259
result:
ok 1 number(s): "268820259"
Test #32:
score: 0
Accepted
time: 2ms
memory: 8276kb
input:
100 100 50 50 1 2 3 4 5 6 7 8 9 10 11 12 13 15 16 20 21 22 23 24 25 27 28 29 30 31 32 33 34 35 36 37 38 41 42 43 46 51 52 55 56 57 58 59 60 63 66 69 80 91 7 18 23 25 26 36 37 38 40 44 47 48 51 54 55 60 63 64 65 66 67 69 70 71 72 73 75 77 78 79 80 81 82 83 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...
output:
252789512
result:
ok 1 number(s): "252789512"
Test #33:
score: 0
Accepted
time: 2ms
memory: 6628kb
input:
100 100 50 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 19 20 21 22 23 25 26 27 28 29 30 31 32 35 39 40 41 42 44 46 47 51 52 53 57 58 59 64 66 69 78 79 85 86 18 23 28 30 31 32 33 34 35 38 42 43 47 49 53 55 58 61 63 64 65 66 68 70 71 74 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
604525399
result:
ok 1 number(s): "604525399"