QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#288508 | #4898. 基础图论练习题 | Crysfly | 6 | 11ms | 5212kb | C++17 | 3.4kb | 2023-12-22 19:42:45 | 2023-12-22 19:42:45 |
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 500005
#define inf 0x3f3f3f3f
int n,a,b,now;
struct node{
int op,u,v,w;
};
vector<node>es;
modint res;
vi as;
void adda(int d){
as.pb(d);
sort(as.begin(),as.end(),greater<int>());
vi o=as,o2;
int n=::n,res=0;
while(o.size()){
int d=o.back(); o.pop_back();
if(d==0) continue;
if(d*2<=n){
while(o.size() && o.back()*2<=n){
d=__gcd(d,o.back());
o.pop_back();
}
}
if(d*2>n){
o2.pb(d);
res+=n-(n-d)*2;
n-=d;
for(auto &x:o) x-=d;
continue;
}
o2.pb(d);
int t=n/d-1;
if(o.size()) t=min(t,o.back()/d);
n-=t*d;
for(auto &x:o) x-=t*d;
if(o.size() && o.back()<d) swap(o.back(),d);
o.pb(d);
}
res+=n;
::now=res;
o=o2;
}
void addb(int u,int v){
}
signed main()
{
n=read(),a=read(),b=read();
now=n;
For(i,1,a){
int u,v,w,op=1;
u=read(),w=read(),es.pb({1,u,-1,w});
}
For(i,1,b){
int u,v,w,op=2;
u=read(),v=read(),w=read(),es.pb({2,u,v,w});
}
sort(es.begin(),es.end(),[&](node a,node b){
return a.w<b.w;
});
for(auto [op,u,v,w]:es){
int lst=now;
if(op==1) adda(u);
else addb(u,v);
res+=((lst-now)%mod)*(w%mod)%mod;
}
cout<<res.x;
return 0;
}
/*
13 2 0
4 16
5 17
*/
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 5212kb
input:
161199 9 46510 147335 540442844 159493 801351455 149342 821625305 128476 843250712 95524 275754315 139315 106523502 93575 680460786 155498 328812257 146020 410466645 79992 141967 50596784 152210 68644 268349216 72549 96959 42994091 93869 27394 945120577 2909 81886 270684270 12735 35026 871917997 974...
output:
751220930
result:
wrong answer 1st numbers differ - expected: '359714743', found: '751220930'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 6
Accepted
Test #11:
score: 6
Accepted
time: 0ms
memory: 3708kb
input:
569435269457904707 2 0 490445920091092693 772271583 144842828305643603 609043885
output:
884694794
result:
ok 1 number(s): "884694794"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
946929772456816659 2 0 589193907831915013 196301185 485768367910597533 207014034
output:
790540706
result:
ok 1 number(s): "790540706"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
693038683299151358 2 0 654733556025919068 724998910 450253521190874799 187460097
output:
122292064
result:
ok 1 number(s): "122292064"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
572269482188906358 2 0 545978502848607475 331750201 488577730099900109 477584735
output:
429885702
result:
ok 1 number(s): "429885702"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
984888155303961325 2 0 421568681423492040 823358650 324408005979881943 905919848
output:
551223124
result:
ok 1 number(s): "551223124"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
968068649251960108 2 0 932666179822285222 303897491 422068063538287737 405622211
output:
516717723
result:
ok 1 number(s): "516717723"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
973235486287221374 2 0 604729607242747292 566399250 440704799734330948 93237801
output:
772791524
result:
ok 1 number(s): "772791524"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
980842002786834388 2 0 921076927921054095 989436809 917078581302025088 354268450
output:
387335763
result:
ok 1 number(s): "387335763"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
584600268153835325 2 0 436736455094118542 788823700 379215887395241676 440751386
output:
178749302
result:
ok 1 number(s): "178749302"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
984888155303961325 2 0 421568681423492040 823358650 324408005979881943 905919848
output:
551223124
result:
ok 1 number(s): "551223124"
Subtask #4:
score: 0
Wrong Answer
Dependency #3:
100%
Accepted
Test #21:
score: 0
Wrong Answer
time: 11ms
memory: 5128kb
input:
569435269457904707 2 48002 490445920091092693 772271583 144842828305643603 609043885 71626464779726163 20936760728342582 933619218 254533877531926689 561120543297327423 444805145 102181371350776436 64807827761321835 63236550 442490347461393187 274703226312639148 379888813 153103619447430279 56932615...
output:
884694794
result:
wrong answer 1st numbers differ - expected: '264605976', found: '884694794'
Subtask #5:
score: 0
Time Limit Exceeded
Test #31:
score: 0
Time Limit Exceeded
input:
755526150476311190 942 0 492334667739348527 1 755523898623296976 1 532486636690994793 1 755526150476030559 1 755526150476249097 1 502164090270592200 1 657422656495814703 1 487200614853438190 1 311037325561173142 1 755526150475651155 1 125287404340238660 1 755524914808674090 1 755526150476177007 1 75...
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #3:
100%
Accepted
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #3:
100%
Accepted
Dependency #5:
0%
Subtask #8:
score: 0
Skipped
Dependency #5:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%