QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#87496 | #5741. Triterminant | xiaoyaowudi | WA | 7ms | 3612kb | C++14 | 602b | 2023-03-13 13:38:46 | 2023-03-13 13:38:48 |
Judging History
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'