QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#39838 | #4356. Giraffes | ZeinDaner# | 0 | 653ms | 3840kb | C++ | 712b | 2022-07-14 04:44:04 | 2024-05-26 01:00:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n; cin>>n;
vector<int> x;
for(int i=0;i<n;i++){
int a; cin>>a;
x.push_back(a);
}
vector<int> rp;
for(int i=1;i<=n;i++) rp.push_back(i);
int ans=1e9;
do{
bool ok=1;
for(int i=0;i<n;i++){
for(int j=i+4;j<n;j++){
bool ma,mi;
ma=mi=0;
for(int k=i;k<=j;k++){
if(rp[k]>rp[i] && rp[k]>rp[j]) ma=1;
if(rp[k]<rp[i] && rp[k]<rp[j]) mi=1;
}
if(mi && ma) ok=0;
}
}
if(ok){
int c=0;
for(int i=0;i<n;i++){
c+=(rp[i]!=x[i]);
}
ans=min(ans,c);
}
}while(next_permutation(rp.begin(),rp.end()));
cout<<ans<<endl;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 3492kb
input:
1 1
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
2 2 1
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
3 1 2 3
output:
0
result:
ok single line: '0'
Test #4:
score: -10
Wrong Answer
time: 0ms
memory: 3604kb
input:
4 3 1 4 2
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'
Subtask #2:
score: 0
Time Limit Exceeded
Test #11:
score: 22
Accepted
time: 4ms
memory: 3780kb
input:
8 7 2 1 8 3 5 4 6
output:
3
result:
ok single line: '3'
Test #12:
score: 0
Accepted
time: 50ms
memory: 3608kb
input:
9 3 1 5 6 8 4 7 9 2
output:
3
result:
ok single line: '3'
Test #13:
score: 0
Accepted
time: 653ms
memory: 3492kb
input:
10 4 6 5 7 1 2 3 8 9 10
output:
2
result:
ok single line: '2'
Test #14:
score: -22
Time Limit Exceeded
input:
11 2 10 3 11 1 5 8 6 4 7 9
output:
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #21:
score: 0
Time Limit Exceeded
input:
29 7 22 11 16 27 1 24 12 6 21 13 2 10 8 25 15 4 19 17 9 23 5 14 20 18 28 26 29 3
output:
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #31:
score: 0
Time Limit Exceeded
input:
2317 1841 533 998 38 1358 1204 1174 176 581 1719 550 906 35 101 442 1068 1781 601 1368 2190 2095 919 2186 1134 1814 625 90 2007 653 186 204 997 1607 1675 45 806 483 299 27 935 1070 1425 1822 1712 2074 2259 264 840 1960 1045 1742 1185 577 142 980 151 2136 2143 955 462 1373 395 1300 185 637 734 803 13...