QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#129050#5095. 九王唱starrylasky0 1ms5744kbC++142.0kb2023-07-21 20:06:072023-07-21 20:06:17

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-21 20:06:17]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:5744kb
  • [2023-07-21 20:06:07]
  • 提交

answer

///yl/hs/bx/yl
#include<bits/stdc++.h>
#define fep(i,l,r) for(int i=l;i<=r;++i)
#define feb(i,r,l) for(int i=r;i>=l;--i)
#define For(i,u) for(int i=head[u];i;i=e[i].nxt)
#define LL long long
// #define int long long
#define ld long double
#define pr pair<int,int>
#define mpr make_pair
using namespace std;
inline int read()
{
   int s=0,w=1; char ch=getchar();
   while(!(ch>='0'&&ch<='9')) {if(ch=='-') w=-1; ch=getchar();}
   while(  ch>='0'&&ch<='9')  {s=(s<<1)+(s<<3)+ch-'0'; ch=getchar();}
   return s*w;
}

namespace starrylasky
{
    const int N=5010;
    int n,seed,a[N][N],c[N][N],p[N],b[N];
    inline void getans() {fep(i,1,n+1) if(!b[i]) printf("%d ",i);}
    inline void gen(int n,int seed){
        std::mt19937 rnd(seed);
        for(int i=1;i<=n;++i){
            for(int j=1;j<=n+1;++j){
                a[i][j]=j;
                std::swap(a[i][j],a[i][rnd()%j+1]);
            }
        }
    }

    inline void Main()
    {
        n=read(),seed=read();
        if(!seed) fep(i,1,n) fep(j,1,n+1) a[i][j]=read();
        else gen(n,seed);
        fep(i,1,n)
        {
            fep(j,1,n+1) c[i][j]=j,b[j]=a[i][j];
            sort(c[i]+1,c[i]+2+n,[](const int x,const int y) {return b[x]>b[y];});
        }
        memset(b,0,sizeof(b));
        feb(i,n,1)
        {
            p[i]=n+1;
            while(b[c[i][p[i]]]) --p[i];
            b[c[i][p[i]]]=i;
        }
        // fep(i,1,n) cerr<<p[i]<<" "; cerr<<"\n";
        getans();
        fep(i,2,n)
        {
            int u=b[c[i-1][n+1]];
            b[c[i-1][p[i-1]]]=0,p[i-1]=n+1,b[c[i-1][n+1]]=i-1;
            while(u)
            {
                --p[u];
                while(b[c[u][p[u]]]&&!(i<=b[c[u][p[u]]]&&b[c[u][p[u]]]<u)) --p[u];
                int to=b[c[u][p[u]]]; b[c[u][p[u]]]=u; u=to; 
            }
            getans();
        }
    }
}

signed main()
{
    int _T=1;
    while(_T--) starrylasky::Main();
    return 0;
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 8
Accepted
time: 1ms
memory: 5744kb

input:

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

output:

5 5 5 5 5 5 5 5 

result:

ok 8 numbers

Test #2:

score: -8
Runtime Error

input:

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

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%