QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#566532#9308. World Cupstcmuyi#WA 50ms3876kbC++201.5kb2024-09-16 00:24:142024-09-16 00:24:15

Judging History

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

  • [2024-09-16 00:24:15]
  • 评测
  • 测评结果:WA
  • 用时:50ms
  • 内存:3876kb
  • [2024-09-16 00:24:14]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
#define int long long
using namespace std;
signed main()
{
	IOS;
	int t; cin >> t;
	while(t--)  
	{
		vector<int> a(33),id(33);
		for(int i = 1; i <= 32; ++i) 
		{
			cin >> a[i];
			id[i] = i;
		}
		int now = 32;
		sort(id.begin() + 1,id.end(),[&](int x,int y){return a[x] > a[y];});
		for(int i = 1; i <= 32; ++i) 
		{
			if(id[i] == 1 && (i % 4 == 3 || i % 4 == 0) && i < 29) 
			{
				swap(id[i],id[i+2]);
				break;
			}
		}
		vector<array<int,2>> v(9);
		for(int i = 1; i <= 32; i += 4) 
		{
			sort(id.begin() + i,id.begin() + i + 4,[&](int x,int y) { return a[x] > a[y];});
			v[(i + 3) / 4] = {id[i],id[i+1]};
			if(id[i] == 1 || id[i+1] == 1) now = 16;
		}
		vector<int> z(9);
		for(int i = 1; i <= 8; ++i) z[i] = i;
		do
		{
			vector<int> g(9);
			for(int i = 1; i <= 8; i += 2) 
			{
				if(a[v[z[i]][0]] > a[v[z[i+1]][1]]) g[(i+1)/2] = v[z[i]][0];
				else g[(i+1)/2] = v[z[i+1]][1];

				if(a[v[z[i]][1]] > a[v[z[i+1]][0]]) g[4 + (i+1)/2] = v[z[i]][1];
				else g[4 + (i+1) / 2] = v[z[i+1]][0];
			}
			int len = 8;
			while(len >= 1) 
			{
				for(int i = 1; i <= len; ++i) if(g[i] == 1) now = min(now,len);
				for(int i = 1; i <= len; i += 2) 
				{
					if(a[g[i]] > a[g[i+1]]) g[(i+1)/2] = g[i];
					else g[(i+1) / 2] = g[i+1];
				}
				len /= 2;
			}
		}while(next_permutation(z.begin() + 1,z.end()));
		cout << now << endl;
	}	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3576kb

input:

1
32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: -100
Wrong Answer
time: 50ms
memory: 3876kb

input:

32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
3 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
4 1 2 3 5 6 7 8 9 10 11 12 13 14 15 ...

output:

32
32
16
16
16
16
8
8
8
8
8
8
8
8
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
2
1

result:

wrong answer 14th numbers differ - expected: '4', found: '8'