QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#798512#3836. So I'll Max Out My Constructive Algorithm SkillsWilliamHu#WA 1ms3712kbC++171.4kb2024-12-04 14:20:052024-12-04 14:20:06

Judging History

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

  • [2024-12-04 14:20:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2024-12-04 14:20:05]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while(c != EOF and !isdigit(c))
	{
		if(c == '-')f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int n, m;
int tree1[1000010], tree[1000010];
int lowbit(int x){return x & (-x);}
void update(int x, int k)
{
	for(int i = x;i <= n;i += lowbit(i))tree[i] += k;
}
int query(int x)
{
	if(x == 0)return 0;
	int ans = 0;
	for(int i = x;i;i -= lowbit(i))ans += tree[i];
	return ans;
}
void update1(int x, int k)
{
	for(int i = x;i <= n;i += lowbit(i))tree1[i] += k;
}
int query1(int x)
{
	if(x == 0)return 0;
	int ans = 0;
	for(int i = x;i;i -= lowbit(i))ans += tree1[i];
	return ans;
}
int a[1010][1010];
vector<int>l;
signed main()
{
	int T = read();
	while(T --)
	{
		l.clear();
		n = read();
		for(int i = 1;i<= n;i ++)
		{
			for(int j = 1;j <= n;j ++)
			{
				a[i][j] = read();
			}
			if(i % 2 == 1)for(int j = 1;j <= n;j ++)l.push_back(a[i][j]);
			if(i % 2 == 0)for(int j = 1;j <= n;j ++)l.push_back(a[i][n-j+1]);
		}
		int ans = 0;
		for(int i = 1;i < n*n;i ++)
		{
			if(l[i] > l[i - 1])ans ++;
		}
		if(ans <= n*n - ans)
		{
			for(int i = 0;i < n*n;i ++)cout<<l[i]<<' ';
			cout<<endl;
		}
		else{
			for(int i = 0;i < n*n;i ++)cout<<l[n*n-i-1]<<' ';
			cout<<endl;
		}
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2
4 3
2 1

output:

4 3 1 2 

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3712kb

input:

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

output:

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

result:

wrong answer [case 15] Not lazy, up = 8, down = 7