QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#55387 | #1171. Integer Array Shuffle | feecle6418 | WA | 2ms | 3624kb | C++20 | 703b | 2022-10-13 15:08:10 | 2022-10-13 15:08:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,cnt=0,a[300005];
string my;
string norm(string s){
string t;
for(int i=0,j;i<s.size();i=j+1){
j=i;
while(j+1<s.size()&&s[j+1]==s[j])j++;
t.push_back(s[i]);
}
return t;
}
bool Check(string s){
string u=norm(s),v=my;
for(int i=0,j=0;i<v.size();i++){
while(j<u.size()&&u[j]!=v[i])j++;
if(j==u.size())return 0;
j++;
}
return 1;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<n;i++)my.push_back(a[i]<=a[i+1]?'0':'1');
my=norm(my);
string s="0";
int cnt=0;
while(!Check(s)){
s=s+s,cnt++;
for(int i=s.size()/2;i<s.size();i++)s[i]^=1;
}
cout<<cnt;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3620kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
6 1 5 8 10 3 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
8 14253630 18210471 431833031 681754868 791250850 811241570 837112104 858531105
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
3 2 2 5
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3620kb
input:
7 4 2 4 2 5 3 4
output:
4
result:
wrong answer 1st numbers differ - expected: '3', found: '4'