QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395777 | #8553. Exchanging Kubic | WrongAnswer_90 | TL | 42ms | 4096kb | C++20 | 5.7kb | 2024-04-21 18:46:00 | 2024-04-21 18:46:00 |
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 mp make_pair
//#define LOCALJUDGE
#define int ll
bool ST;
static const ll MOD=1e9+7,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,INF=4557430888798830399;
static const double eps=1e-10,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
using namespace std;
//#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
struct tup{int x,y,z;tup(int X=0,int Y=0,int Z=0){x=X,y=Y,z=Z;}};
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!=' ')s[++len]=st,st=getchar();
s[++len]='\0';
}
template<typename T> inline void read(T &s)
{
s=0;char ch=getchar();
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);
}
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...);}
}
using namespace FastIO;
namespace MTool
{
inline int Cadd(int a,int b){return a+b>=MOD?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=(a+b>=MOD?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;}
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,ll 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 T,n,top,c[2010];
tup a[2010];
void dfs()
{
if(top==2)return a[2].z=-INF,void();
if(top==1)return;
tup a1[2010];memcpy(a1,a,sizeof(a));
int v1,v2;
write("? ",1,' ',a[3].y,'\n'),fflush(stdout),read(v1);
if(v1>max(a[1].z,a[3].z))
{
a1[2].z=v1-a[1].z-a[3].z;
for(int i=1;i<top-1;++i)a[i]=a[i+2];
top-=2,a[1].x=1,a[1].z=v1,dfs();
for(int i=top+2;i>=3;--i)a[i]=a[i-2];
a[1]=a1[1],a[2]=a1[2],a[3]=a1[3],top+=2;
}
else
{
if(top==3)return a[2].z=-INF,void();
write("? ",a[3].x,' ',a[5].y,'\n'),fflush(stdout),read(v2);
if(v2>max(a[5].z,a[3].z))
{
a1[4].z=v2-a[3].z-a[5].z;
for(int i=3;i<top-1;++i)a[i]=a[i+2];
a[3].z=v2,a[3].x=a[2].y+1,top-=2,dfs();
for(int i=top+2;i>=5;--i)a[i]=a[i-2];
a[3]=a1[3],a[4]=a1[4],a[5]=a1[5],top+=2;
}
else
{
for(int i=2;i<top-1;++i)a[i]=a[i+2];
top-=2,a[2].x=a[1].y+1,dfs();
for(int i=top+2;i>=4;--i)a[i]=a[i-2];
a[2]=a1[2],a[3]=a1[3],a[4].x=a[3].y+1,top+=2;
if(a[4].z==-INF)a[2].z=-INF;
else a[4].z-=a[3].z,a[2].z=-min(a[1].z,a[3].z),a[4].z-=a[2].z;
assert(-a[4].z>=min(a[3].z,a[5].z));
}
}
}
inline void mian()
{
read(T);int x;
while(T--)
{
read(n),a[top=1]=tup(1,0,1);
for(int i=1;i<=n;++i)
{
write("? ",i,' ',i,'\n'),fflush(stdout);
read(x),c[i]=x;
if(x>0)
{
if(a[top].z>0)a[top].z+=x;
else a[top].y=i-1,a[++top]=tup(i,i,x);
}
else if(a[top].z>0)a[top].y=i-1,a[++top]=tup(i,i,0);
}
a[top].y=n,--a[1].z;
if(a[top].z==0)a[++top]=tup(n+1,n,inf);dfs();
write('!');
for(int i=1;i<=top;++i)
{
if(a[i].z>0)for(int j=a[i].x;j<=a[i].y;++j)write(c[j]);
else{if(a[i].x<=a[i].y)write(max((ll)-1e15,a[i].z));for(int j=a[i].x;j<a[i].y;++j)write(0);}
}
puts(""),fflush(stdout);
}
}
}
bool ED;
signed main()
{
#ifdef LOCALJUDGE
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
#endif
double st=clock();
WrongAnswer_90::mian();
double ed=clock();
#ifndef LOCALJUDGE
cerr<<endl;
#endif
cerr<<"Time: "<<ed-st<<" ms\n";
#ifdef LOCALJUDGE
cerr<<" ";
#endif
cerr<<"Memory: "<<abs(&ST-&ED)/1024.0/1024.0<<" MB\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4076kb
input:
2 3 1 0 1 1 5 2 0 3 0 5 4 5
output:
? 1 1 ? 2 2 ? 3 3 ? 1 3 ! 1 -1000000000000000 1 ? 1 1 ? 2 2 ? 3 3 ? 4 4 ? 5 5 ? 1 3 ? 1 5 ! 2 -1 3 -1000000000000000 5
result:
ok ok (2 test cases)
Test #2:
score: 0
Accepted
time: 42ms
memory: 4096kb
input:
10000 1 718876398 1 0 0 1 0 0 1 0 0 1 938356223 1 857157125 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 965894497 1 0 0 1 626061677 1 642094813 1 107398046 1 0 0 1 0 0 1 0 0 1 287188651 1 0 0 1 345108193 1 0 0 1 0 0 1 714952783 1 0 0 1 325760098 1 0 0 1 800487422 1 322806679 1 0 0 1 0 0 1 0 0 1 866952779 1 7414...
output:
? 1 1 ! 718876398 ? 1 1 ? 1 1 ! -1000000000000000 ? 1 1 ? 1 1 ! -1000000000000000 ? 1 1 ? 1 1 ! -1000000000000000 ? 1 1 ! 938356223 ? 1 1 ! 857157125 ? 1 1 ? 1 1 ! -1000000000000000 ? 1 1 ? 1 1 ! -1000000000000000 ? 1 1 ? 1 1 ! -1000000000000000 ? 1 1 ? 1 1 ! -1000000000000000 ? 1 1 ? 1 1 ...
result:
ok ok (10000 test cases)
Test #3:
score: -100
Time Limit Exceeded
input:
1052 9 167536100 0 373372185 0 427949326 442758705 102715118 0 0 373372185 973423149 973423149 973423149 973423149 9 248442934 306962195 570791475 593033322 0 582850731 559429390 0 120053133 2780526396 2780526396 10 785691778 0 981032824 0 0 592503870 0 0 0 0 981032824 1112480382 1112480382 11124803...
output:
? 1 1 ? 2 2 ? 3 3 ? 4 4 ? 5 5 ? 6 6 ? 7 7 ? 8 8 ? 9 9 ? 1 3 ? 3 7 ? 1 7 ? 5 9 ? 1 9 ! 167536100 -1000000000000000 373372185 -1000000000000000 427949326 442758705 102715118 -1000000000000000 0 ? 1 1 ? 2 2 ? 3 3 ? 4 4 ? 5 5 ? 6 6 ? 7 7 ? 8 8 ? 9 9 ? 1 7 ? 1 9 ! 248442934 306962195 570791475 593033322...