QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393557#8546. Min or Max 2XY_ElevenTL 2181ms32016kbC++233.9kb2024-04-18 19:48:052024-04-18 19:48:06

Judging History

你现在查看的是最新测评结果

  • [2024-04-18 19:48:06]
  • 评测
  • 测评结果:TL
  • 用时:2181ms
  • 内存:32016kb
  • [2024-04-18 19:48:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize(3)
#define DB double
#define LL long long
#define ULL unsigned long long
#define in128 __int128
#define cint const int
#define cLL const LL
#define For(z,e1,e2) for(int z=(e1);z<=(e2);z++)
#define Rof(z,e1,e2) for(int z=(e2);z>=(e1);z--)
#define For_(z,e1,e2) for(int z=(e1);z<(e2);z++)
#define Rof_(z,e1,e2) for(int z=(e2);z>(e1);z--)
#define inint(e) scanf("%d",&e)
#define inll(e) scanf("%lld",&e)
#define inpr(e1,e2) scanf("%d%d",&e1,&e2)
#define in3(e1,e2,e3) scanf("%d%d%d",&e1,&e2,&e3)
#define outint(e) printf("%d\n",e)
#define outint_(e) printf("%d%c",e," \n"[i==n])
#define outint2_(e,e1,e2) printf("%d%c",e," \n"[(e1)==(e2)])
#define outll(e) printf("%lld\n",e)
#define outll_(e) printf("%lld%c",e," \n"[i==n])
#define outll2_(e,e1,e2) printf("%lld%c",e," \n"[(e1)==(e2)])
#define exc(e) if(e) continue
#define stop(e) if(e) break
#define ret(e) if(e) return
#define ll(e) (1ll*(e))
#define pb push_back
#define ft first
#define sc second
#define clean(e) while(!e.empty()) e.pop()
#define all(ev) ev.begin(),ev.end()
#define sz(ev) ((int)ev.size())
#define debug(x) printf("%s=%d\n",#x,x)
#define x0 __xx00__
#define y1 __yy11__
#define ffo fflush(stdout)
cLL mod=998244353,G=404;
template <typename Type> void get_min(Type &w1,const Type w2) { if(w2<w1) w1=w2; } template <typename Type> void get_max(Type &w1,const Type w2) { if(w2>w1) w1=w2; }
template <typename Type> Type up_div(Type w1,Type w2) { return (w1/w2+(w1%w2?1:0)); }
template <typename Type> Type gcd(Type X_,Type Y_) { Type R_=X_%Y_; while(R_) { X_=Y_; Y_=R_; R_=X_%Y_; } return Y_; } template <typename Type> Type lcm(Type X_,Type Y_) { return (X_/gcd(X_,Y_)*Y_); }
template <typename Type> Type md(Type w1,const Type w2=mod) { w1%=w2; if(w1<0) w1+=w2; return w1; } template <typename Type> Type md_(Type w1,const Type w2=mod) { w1%=w2; if(w1<=0) w1+=w2; return w1; }
void ex_gcd(LL &X_,LL &Y_,LL A_,LL B_) { if(!B_) { X_=1ll; Y_=0ll; return ; } ex_gcd(Y_,X_,B_,A_%B_); X_=md(X_,B_); Y_=(1ll-X_*A_)/B_; } LL inv(LL A_,LL B_=mod) { LL X_=0ll,Y_=0ll; ex_gcd(X_,Y_,A_,B_); return X_; }
template <typename Type> void add(Type &w1,const Type w2,const Type M_=mod) { w1=md(w1+w2,M_); } void mul(LL &w1,cLL w2,cLL M_=mod) { w1=md(w1*md(w2,M_),M_); } template <typename Type> Type pw(Type X_,Type Y_,Type M_=mod) { Type S_=1; while(Y_) { if(Y_&1) mul(S_,X_,M_); Y_>>=1; mul(X_,X_,M_); } return S_; }
template <typename Type> Type bk(vector <Type> &V_) { auto T_=V_.back(); V_.pop_back(); return T_; } template <typename Type> Type tp(stack <Type> &V_) { auto T_=V_.top(); V_.pop(); return T_; } template <typename Type> Type frt(queue <Type> &V_) { auto T_=V_.front(); V_.pop(); return T_; }
template <typename Type> Type bg(set <Type> &V_) { auto T_=*V_.begin(); V_.erase(V_.begin()); return T_; } template <typename Type> Type bk(set <Type> &V_) { auto T_=*prev(V_.end()); V_.erase(*prev(V_.end())); return T_; }
mt19937 gen(time(NULL)); int rd() { return abs((int)gen()); }
cint N=5.01e5;
int n;
int a[N],b[N];
unordered_set <LL> st[N];
int cnt[N];
void dfs(int k,int x,int y)
{
    LL t=1ll*x*N+y;
    ret(st[k].find(t)!=st[k].end());
    st[k].insert(t);
    if(k==n)
    {
        cnt[abs(x-y)]++;
        return ;
    }
    dfs(k+1,max(x,a[k+1]),max(y,b[k+1]));
    dfs(k+1,min(x,a[k+1]),min(y,b[k+1]));
}
void main_solve()
{
    inint(n);
    For(i,1,n) inint(a[i]);
    For(i,1,n) inint(b[i]);
    For(i,1,n) st[i].clear();
    For(i,0,n) cnt[i]=0;
    dfs(1,a[1],b[1]);
    For_(i,0,n) outint2_(cnt[i],i,n-1);
}
int main()
{
    // ios::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt","r",stdin);
    // freopen("out1.txt","w",stdout);
    // srand(time(NULL));
    // main_init();
    int _; inint(_); For(__,1,_) // T>1 ?
        // printf("\n------------\n\n"),
        main_solve();
    return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 31272kb

input:

4
2
1 2
2 1
5
2 4 1 5 3
2 4 1 5 3
5
1 2 3 4 5
5 4 3 2 1
8
5 8 3 4 2 7 1 6
4 6 3 8 5 1 2 7

output:

2 0
5 0 0 0 0
2 2 2 2 0
5 5 2 2 1 0 0 0

result:

ok 20 numbers

Test #2:

score: 0
Accepted
time: 235ms
memory: 31360kb

input:

66664
7
4 2 6 5 7 1 3
6 5 3 1 4 7 2
10
6 8 10 7 5 1 4 3 9 2
5 10 3 8 6 7 2 9 1 4
9
3 2 4 8 7 6 9 1 5
8 1 2 9 6 7 4 3 5
10
4 3 9 6 7 2 10 1 8 5
3 5 4 1 2 7 10 9 6 8
5
3 4 1 2 5
5 1 3 2 4
5
2 4 3 5 1
2 3 1 4 5
6
2 6 1 3 4 5
6 4 5 1 3 2
10
10 1 2 7 5 8 4 3 9 6
9 4 2 3 6 1 7 8 5 10
5
1 2 4 5 3
4 1 2 5 3...

output:

4 4 2 2 1 0 0
5 6 3 2 2 1 0 0 0 0
5 6 3 2 1 0 0 0 0
4 4 4 3 2 1 0 0 0 0
5 3 0 0 0
2 2 2 2 0
3 3 3 1 0 0
5 7 4 2 1 0 0 0 0 0
5 2 0 0 0
6 3 0 0 0 0
3 3 2 0 0
5 4 2 1 0 0 0
3 2 3 1 0 0
4 6 3 0 0 0 0
3 4 3 2 1 0 0
3 2 2 2 2 2 2 1 0
4 5 3 1 0 0 0
3 4 3 2 3 3 1 0 0 0
8 5 0 0 0 0 0 0
7 8 3 1 0 0 0 0 0 0
5 ...

result:

ok 499999 numbers

Test #3:

score: 0
Accepted
time: 2181ms
memory: 32016kb

input:

6690
72
31 50 47 60 24 33 72 49 5 26 17 65 40 64 8 2 19 51 30 58 71 16 66 56 9 48 21 61 44 59 22 11 15 28 68 29 1 27 37 41 23 6 20 62 43 34 18 4 70 54 13 12 36 35 25 67 45 38 69 53 42 63 55 3 14 7 57 32 52 39 10 46
31 9 7 56 32 64 39 33 62 24 49 54 18 53 43 40 4 28 37 2 61 47 10 26 23 16 22 30 11 60...

output:

7 11 7 5 6 6 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 2 2 2 3 4 4 4 4 4 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 4 6 6 4 4 3 2 2 2 2 2 2 2 2 2 3 4 4 4 4 4 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 6 6 7 8 7 6 7 8 8 7 5 4 4 3 2 2 2 2...

result:

ok 499981 numbers

Test #4:

score: -100
Time Limit Exceeded

input:

666
775
98 357 198 407 409 200 454 585 319 622 366 264 710 91 765 78 32 528 335 101 469 204 312 382 276 613 231 342 327 324 441 544 413 299 494 393 349 611 211 702 165 297 320 284 401 530 317 567 142 742 447 482 662 126 506 273 362 328 555 416 206 604 589 305 99 114 291 131 386 75 670 280 704 189 43...

output:

11 20 20 20 19 18 18 18 18 18 18 18 18 18 18 18 18 17 16 16 16 16 16 16 16 16 16 16 16 16 16 15 14 14 14 14 13 12 12 12 12 12 12 12 12 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 9 8 8 8 8 7 6 6 6 6 6 6 6 6 6 6 6 6 ...

result: