QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#823992 | #9877. Segment Tree | WrongAnswer_90 | WA | 12ms | 20948kb | C++23 | 5.9kb | 2024-12-21 11:28:32 | 2024-12-21 11:28:32 |
Judging History
answer
#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define vt vector<tup>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define FastI
#define FastO
//#define Print
#define int ll
bool ST,dbg;
static const ll MOD=998244353,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,INF=4611686018427387903;
static const ld eps=1e-9,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
char out[1<<20],*p3=out;
using namespace std;
struct tup
{
int x,y,z;
tup(int X=0,int Y=0,int Z=0)
{x=X,y=Y,z=Z;}
bool operator <(const tup nd)const
{return x<nd.x;}
};
#ifdef FastI
#ifdef Print
#define getchar() ((p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1),(dbg?cerr<<(char)(*p1),0:0),*p1++)
#else
#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#endif
#endif
#ifdef FastO
#define putchar(x) (p3-out==1<<20?fwrite(out,1,1<<20,stdout),p3=out,0:0,*p3++=x)
#define puts(x) write(x,'\n')
#endif
namespace FastIO
{
template<typename T> inline void write(T x,char ch=' ')
{
if(is_same<char,T>::value)putchar(x);
else
{
if(x<0)x=-x,putchar('-');
static char st[25];
int top=0;
do st[top++]=x%10+'0',x/=10;while(x);
while(top)putchar(st[--top]);
}
ch!='~'?putchar(ch):0;
}
inline void write(const char*x,char ch=' ')
{
for(int i=0;x[i]!='\0';++i)putchar(x[i]);
ch!='~'?putchar(ch):0;
}
inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
inline void read(char s[])
{
int len=0;char st;
do st=getchar();while(st=='\n'||st==' ');
s[++len]=st,st=getchar();
while(st!='\n'&&st!=' '&&st!='\r')s[++len]=st,st=getchar();
s[++len]='\0';
}
template<typename T> inline void read(T &s)
{
char ch=getchar();s=0;
while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
bool tf=(ch=='-'&&(ch=getchar()));
while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
s=tf?-s:s;
}
inline void edl(){putchar('\n');}
template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
#ifdef FastO
struct Writer{~Writer(){fwrite(out,1,p3-out,stdout);}}Writ;
#endif
}
using namespace FastIO;
namespace MTool
{
inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
inline int sqr(int a){return 1ll*a*a%MOD;}
inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
inline int Cmod(int x){return (x%MOD+MOD)%MOD;}
inline void Mmod(int&x){x=(x%MOD+MOD)%MOD;}
template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
int n,m;
int f[1<<19],g[1<<19];
int a[2][1<<19],L[1<<19],R[1<<19];
int upd(int x,int l,int r,int id)
{
int ans=INF;
Mmin(a[id][L[x]],l),Mmin(a[id][R[x]],r);
while(x)
{
Mmin(a[id][L[x]],a[id][R[x]]+g[x]);
Mmin(a[id][R[x]],a[id][L[x]]+g[x]);
Mmin(ans,a[id][L[x]]+a[id^1][L[x]]);
Mmin(ans,a[id][R[x]]+a[id^1][R[x]]);
x>>=1;
}
return ans;
}
void clr(int x,int id){while(x)a[id][L[x]]=a[id][R[x]]=INF,x>>=1;}
void mian()
{
int opt,x,y;
read(n);
for(int i=1;i<(1<<(n+1));++i)
read(f[i]),g[i]=f[i];
for(int i=(1<<n);i<(1<<(n+1));++i)
L[i]=i-(1<<n),R[i]=i-(1<<n)+1;
for(int i=(1<<n)-1;i>=1;--i)
{
Mmin(g[i],g[i<<1]+g[i<<1|1]);
L[i]=L[i<<1],R[i]=R[i<<1|1];
}
memset(a,127,sizeof(a));
read(m);
cerr<<m<<endl;
while(m--)
{
read(opt,x,y);
if(opt==1)
{
f[x]=y;
if(x>=(1<<n))g[x]=f[x],x>>=1;
while(x)
{
g[x]=min(f[x],g[x<<1]+g[x<<1|1]);
x>>=1;
}
}
else
{
int ans=INF;
if(x<(1<<n))upd((1<<n)+x,0,INF,0);
if(x>0)upd((1<<n)+x-1,INF,0,0);
if(y<(1<<n))Mmin(ans,upd((1<<n)+y,0,INF,1));
if(y>0)Mmin(ans,upd((1<<n)+y-1,INF,0,1));
if(x<(1<<n))clr((1<<n)+x,0);
if(x>0)clr((1<<n)+x-1,0);
if(y<(1<<n))clr((1<<n)+y,1);
if(y>0)clr((1<<n)+y-1,1);
write(ans,'\n');
}
}
}
inline void Mian()
{
int T=1,C;
// read(T);
for(int _T=1;_T<=T;++_T)
{
// dbg=_T==1;
mian();
}
}
}
bool ED;
signed main()
{
// ios::sync_with_stdio(0);
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
WrongAnswer_90::Mian();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 19944kb
input:
3 7 1 14 3 9 4 8 2 6 5 5 13 8 2 3 10 2 0 1 2 0 4 2 4 6 2 4 8 2 3 5 1 6 30 2 3 5 2 4 6 1 1 10000000 2 0 8
output:
2 1 4 8 17 18 13 15
result:
ok 8 tokens
Test #2:
score: 0
Accepted
time: 8ms
memory: 20424kb
input:
1 7914575 2436426 4979445 199989 1 1 6190629 1 1 1407775 1 1 2804784 1 2 2631932 1 1 3078537 1 3 286918 1 2 3238506 1 3 3361868 1 2 9296263 1 3 4836991 1 3 2177068 1 3 4291757 1 1 594328 1 2 8996221 1 1 5531545 1 3 3575467 1 3 3206504 1 1 8344965 1 3 6045895 2 0 2 1 2 6248153 1 1 5797489 1 1 9766466...
output:
8344965 5684734 2756417 2512448 130126 7091295 7834895 6363152 6668726 4380822 8809904 4042733 8566868 8653391 3654574 7617913 8583126 4470761 4099069 2539201 7188565 8465921 4517278 1913351 7400947 5104744 1759308 6081288 3559555 3409112 3714298 8937580 4704960 5280672 9424416 1622556 2599805 18330...
result:
ok 1899 tokens
Test #3:
score: 0
Accepted
time: 5ms
memory: 20768kb
input:
1 3080713 6130142 8931932 199954 1 3 3859793 1 2 8302798 1 1 1363993 1 2 2817427 1 1 6031503 1 1 4197608 1 1 3453017 1 3 3258277 1 2 1243375 1 3 7997018 1 1 8659259 1 1 545422 1 1 1213295 1 2 9318329 1 2 1165990 1 1 3910911 1 2 9639614 1 2 3166127 1 1 2556789 1 1 2505213 2 1 2 1 1 8837030 1 1 996138...
output:
5671340 4103158 2278869 1251419 702774 1634200 9066441 3444042 4761391 1317349 996556 3444042 996556 996556 4884903 6746567 6746567 1389661 4920459 230651 935263 2028823 680623 1093324 1093324 680623 680623 369391 6136723 5192803 5192803 6136723 4301516 4578392 3566336 3566336 7599310 4756965 378391...
result:
ok 29717 tokens
Test #4:
score: 0
Accepted
time: 12ms
memory: 20524kb
input:
1 6313638 363583 8248153 199989 2 1 2 1 1 155990 1 2 4430056 2 0 2 2 1 2 1 1 6771887 1 1 9001299 2 0 1 1 3 2051074 2 1 2 2 0 1 1 1 3829876 2 0 1 1 3 8940076 2 1 2 2 0 1 2 0 2 2 0 2 1 1 2321211 1 2 8057327 2 0 2 1 1 553338 1 2 7877801 2 0 2 1 2 2505976 1 3 1153207 2 0 2 1 2 4561192 1 2 4540078 1 1 90...
output:
6677221 155990 4586046 4430056 2051074 4430056 4430056 8259932 4430056 3829876 3829876 2321211 553338 553338 5693285 4540078 4547501 5088001 1153207 3934794 1153207 3934794 3934794 3934794 7085662 3658305 3147631 3658305 6805936 3147631 3147631 853551 2267606 3727767 3727767 2645926 3727767 2645926 ...
result:
ok 100061 tokens
Test #5:
score: -100
Wrong Answer
time: 4ms
memory: 20948kb
input:
2 4716625 8732769 4896438 9294402 7273885 4137152 2249944 199996 1 1 5186587 1 4 7722585 1 5 3539426 1 5 1298070 1 6 8806800 1 1 4206062 1 6 6971489 1 5 8825000 1 5 3448517 1 6 9944200 1 1 3672387 1 2 1617483 1 5 8197902 1 6 4298339 1 5 6260453 1 2 3666548 1 3 9334704 1 3 5244559 1 3 2160729 1 6 944...
output:
5334226 9572097 4807948 733673 8100027 6139742 6091424 5926345 8623714 12325259 6201853 1162428 2792985 6816822 9147939 8703527 5455802 2767961 4607887 7567091 1326121 3115123 3452276 7483661 3901199 2876292 3890889 78252 9798360 2638886 8164525 6562024 7215100 4673524 5977628 9171516 5178543 904555...
result:
wrong answer 35th words differ - expected: '5294603', found: '5977628'