QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87496#5741. TriterminantxiaoyaowudiWA 7ms3612kbC++14602b2023-03-13 13:38:462023-03-13 13:38:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-13 13:38:48]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3612kb
  • [2023-03-13 13:38:46]
  • 提交

answer

#include <iostream>
#include <algorithm>
constexpr int N(1e5+10);
int main()
{
	int T;std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);std::cin>>T;
	while(T--)
	{
		int n;std::cin>>n;
		static int a[N];
		for(int i(1);i<=n;++i) std::cin>>a[i];
		int ans(0);for(int i(3);i<n;i+=2) ans+=(a[i]==a[i+1]);
		int mn(1e9);
		for(int c:{-1,1})
		{
			int cur(0);
			for(int i(1),j(c);i<=n;i+=4,j=-j)
			{
				cur+=(a[i]!=j);
				if(i<n) cur+=(a[i+1]!=(-j));
			}
			// std::cerr<<c<<" "<<cur<<std::endl;
			mn=std::min(mn,cur);
		}
		std::cout<<ans+mn<<"\n";
	}
	return 0;
}

詳細信息

Test #1:

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

input:

3
4
1 1 1 1
2
1 -1
5
-1 1 1 1 -1

output:

2
0
2

result:

ok 3 number(s): "2 0 2"

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 3612kb

input:

3
27354
-1 -1 1 -1 1 1 1 1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 ...

output:

13645
28063
7251

result:

wrong answer 1st numbers differ - expected: '13567', found: '13645'