QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68149#5095. 九王唱lmeowdn0 2ms3860kbC++201.5kb2022-12-14 19:53:582022-12-14 19:54:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-14 19:54:01]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:3860kb
  • [2022-12-14 19:53:58]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define fi first
#define se second
#define eb emplace_back
#define bp __builtin_parity
#define y1 yyl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef bitset<1009> bset;

int read() {
	int x=0,w=1; char c=getchar();
	while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
	while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
	return x*w;
}

const int N=5009;
int b[N][N],a[N][N],n,seed;

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]);
        }
    }
}

void work(int p) {
	for(int x=p;;x=x%n+1) {
		int p1=0, p2=0, rc=0;
		rep(i,1,n+1) {
			if(b[x][i]==1) p1=i;
			else if(b[x][i]==2) p2=i;
		}
		bool flag=0;
		for(int y=x%n+1;y!=p;y=y%n+1) {
			if(b[y][p1]==1) {flag=1; break;}
		}
		if(flag) rc=p2;
		else rc=p1;
		for(int y=x%n+1;y!=p;y=y%n+1) {
			rep(j,1,n+1) {
				if(b[y][j]>b[y][rc]) b[y][j]--;
			}
			b[y][rc]=0;
		}
		if(x%n+1==p) {
			printf("%d ",p2);
			return;
		}
	}
}

signed main() {
	n=read(), seed=read();
	if(seed) gen(n,seed);
	else rep(i,1,n) rep(j,1,n+1) a[i][j]=read();
	rep(i,1,n) {
		rep(j,1,n) rep(k,1,n+1) b[j][k]=a[j][k];
		work(i);
	} putchar('\n');
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 8
Accepted
time: 2ms
memory: 3860kb

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: 0
Accepted
time: 2ms
memory: 3620kb

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:

7 7 7 7 7 7 7 7 

result:

ok 8 numbers

Test #3:

score: 0
Accepted
time: 2ms
memory: 3860kb

input:

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

output:

6 6 6 6 6 6 6 6 

result:

ok 8 numbers

Test #4:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

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

output:

3 3 3 3 3 3 3 3 

result:

ok 8 numbers

Test #5:

score: 0
Accepted
time: 2ms
memory: 3744kb

input:

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

output:

1 1 1 1 1 1 1 

result:

ok 7 numbers

Test #6:

score: -8
Wrong Answer
time: 2ms
memory: 3744kb

input:

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

output:

3 3 3 3 3 6 6 3 

result:

wrong answer 4th numbers differ - expected: '6', found: '3'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%