QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#108521 | #3836. So I'll Max Out My Constructive Algorithm Skills | woxiangbaile# | WA | 2ms | 3688kb | C++ | 799b | 2023-05-25 13:42:00 | 2023-05-25 13:42:02 |
Judging History
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