QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#152666 | #6382. LaLa and Spirit Summoning | Crysfly | WA | 3ms | 8504kb | C++17 | 3.1kb | 2023-08-28 16:36:18 | 2023-08-28 16:36:20 |
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 ull unsigned long long
#define i128 __int128
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
/*
no circle : v > e
rigid : 2v - 2 > e
*/
int n,m;
modint v1[205],v2[205];
modint tmp[205],bs[205][205];
vector<pii>e[maxn];
bool ins(){
Rep(i,n*2,1){
if(!tmp[i].x)continue;
if(bs[i][i].x){
For(j,1,i-1) tmp[j]-=bs[i][j]*tmp[i];
tmp[i]=0;
continue;
}
modint inv=1/tmp[i];
For(j,1,i) bs[i][j]=tmp[j]*inv;
return 1;
}
return 0;
}
mt19937_64 rnd(time(0));
signed main()
{
n=read(),m=read();
For(i,1,n)v1[i]=rnd()%(mod-1)+1,v2[i]=rnd()%(mod-1)+1;
For(i,1,m){
int u=read()+1,v=read()+1,w=read();
e[w].pb(mkp(u,v));
}
int res=0;
For(i,0,m-1){
memset(tmp,0,sizeof tmp);
for(auto [u,v]:e[i]){
modint w=rnd()%(mod-1)+1;
memset(tmp,0,sizeof tmp);
tmp[u*2-1]+=w*(v1[u]-v1[v]);
tmp[u*2]+=w*(v2[u]-v2[v]);
tmp[v*2-1]+=w*(v1[v]-v1[u]);
tmp[v*2]+=w*(v2[v]-v2[u]);
}
res+=ins();
}
cout<<n*2-res;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 8284kb
input:
3 3 0 1 0 0 2 0 1 2 0
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 1ms
memory: 8368kb
input:
3 3 0 1 0 0 2 1 1 2 2
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 0ms
memory: 8320kb
input:
4 4 0 1 0 1 2 1 2 3 2 0 3 3
output:
4
result:
ok 1 number(s): "4"
Test #4:
score: 0
Accepted
time: 3ms
memory: 8504kb
input:
5 4 0 1 0 1 2 1 2 3 2 3 4 3
output:
6
result:
ok 1 number(s): "6"
Test #5:
score: 0
Accepted
time: 2ms
memory: 8368kb
input:
2 0
output:
4
result:
ok 1 number(s): "4"
Test #6:
score: 0
Accepted
time: 3ms
memory: 8352kb
input:
2 1 0 1 0
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 2ms
memory: 8260kb
input:
2 2 0 1 0 0 1 1
output:
3
result:
ok 1 number(s): "3"
Test #8:
score: 0
Accepted
time: 3ms
memory: 8416kb
input:
2 3 0 1 0 0 1 2 0 1 0
output:
3
result:
ok 1 number(s): "3"
Test #9:
score: 0
Accepted
time: 3ms
memory: 8280kb
input:
2 4 0 1 2 0 1 3 0 1 2 0 1 3
output:
3
result:
ok 1 number(s): "3"
Test #10:
score: 0
Accepted
time: 3ms
memory: 8344kb
input:
2 5 0 1 2 0 1 4 0 1 3 0 1 4 0 1 3
output:
3
result:
ok 1 number(s): "3"
Test #11:
score: 0
Accepted
time: 3ms
memory: 8364kb
input:
2 6 0 1 3 0 1 3 0 1 1 0 1 0 0 1 3 0 1 4
output:
3
result:
ok 1 number(s): "3"
Test #12:
score: 0
Accepted
time: 1ms
memory: 8504kb
input:
2 7 0 1 1 0 1 5 0 1 6 0 1 4 0 1 1 0 1 2 0 1 3
output:
3
result:
ok 1 number(s): "3"
Test #13:
score: 0
Accepted
time: 3ms
memory: 8220kb
input:
2 8 0 1 2 0 1 5 0 1 1 0 1 4 0 1 2 0 1 1 0 1 1 0 1 1
output:
3
result:
ok 1 number(s): "3"
Test #14:
score: 0
Accepted
time: 3ms
memory: 8336kb
input:
2 9 0 1 8 0 1 7 0 1 0 0 1 7 0 1 4 0 1 1 0 1 2 0 1 8 0 1 5
output:
3
result:
ok 1 number(s): "3"
Test #15:
score: 0
Accepted
time: 1ms
memory: 8376kb
input:
2 10 0 1 0 0 1 7 0 1 8 0 1 5 0 1 8 0 1 7 0 1 8 0 1 3 0 1 4 0 1 3
output:
3
result:
ok 1 number(s): "3"
Test #16:
score: 0
Accepted
time: 3ms
memory: 8420kb
input:
3 0
output:
6
result:
ok 1 number(s): "6"
Test #17:
score: 0
Accepted
time: 0ms
memory: 8368kb
input:
3 1 1 2 0
output:
5
result:
ok 1 number(s): "5"
Test #18:
score: 0
Accepted
time: 0ms
memory: 8372kb
input:
3 2 1 2 1 1 2 1
output:
5
result:
ok 1 number(s): "5"
Test #19:
score: 0
Accepted
time: 3ms
memory: 8416kb
input:
3 3 1 2 2 1 2 1 0 1 1
output:
4
result:
ok 1 number(s): "4"
Test #20:
score: 0
Accepted
time: 3ms
memory: 8360kb
input:
3 4 1 2 3 0 2 1 1 2 0 1 2 3
output:
4
result:
ok 1 number(s): "4"
Test #21:
score: -100
Wrong Answer
time: 1ms
memory: 8372kb
input:
3 5 1 2 0 1 2 2 0 1 4 0 2 0 0 1 0
output:
4
result:
wrong answer 1st numbers differ - expected: '3', found: '4'