QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108521#3836. So I'll Max Out My Constructive Algorithm Skillswoxiangbaile#WA 2ms3688kbC++799b2023-05-25 13:42:002023-05-25 13:42:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-25 13:42:02]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3688kb
  • [2023-05-25 13:42:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int mod=1e9+7;
#define inf 1e9
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}
const int N=105;
int T,n,m,a[maxn],stk[maxn],top;
inline void solve(){
	n=read();top=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)a[(i-1)*n+j]=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i&1)stk[++top]=(i-1)*n+j;
			else stk[++top]=(i-1)*n+n-j+1;
	int sum=0;
	for(int i=2;i<=top;i++)
		if(a[stk[i-1]]>a[stk[i]])++sum;
		else --sum;
	for(int i=1;i<=top;i++)
		printf("%d ",sum>=0?stk[i]:stk[top-i+1]);puts("");
}
int main(){
	T=read();
	while(T--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3688kb

input:

1
2
4 3
2 1

output:

1 2 4 3 

result:

wrong answer [case 1] Not lazy, up = 2, down = 1