QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#120004 | #4356. Giraffes | lmeowdn# | 0 | 150ms | 3840kb | C++14 | 2.1kb | 2023-07-06 10:40:45 | 2024-07-04 00:21:00 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=8005;
int n,a[N],p[N],ans,S;
signed main() {
n=read(); ans=n; S=(1<<n)-1;
rep(i,1,n) a[i]=read();
rep(s,0,S) {
int tot=0;
rep(i,1,n) if(s&(1<<i-1)) p[++tot]=i;
per(i,n,1) if(!(s&(1<<i-1))) p[++tot]=i;
int res=0;
rep(i,1,n) res+=(a[i]!=p[i]);
chmin(ans,res);
tot=res=0;
rep(i,1,n) if(s&(1<<i-1)) p[++tot]=i;
rep(i,1,n) if(!(s&(1<<i-1))) p[++tot]=i;
rep(i,1,n) res+=(a[i]!=p[i]);
chmin(ans,res);
tot=res=0;
per(i,n,1) if(s&(1<<i-1)) p[++tot]=i;
rep(i,1,n) if(!(s&(1<<i-1))) p[++tot]=i;
rep(i,1,n) res+=(a[i]!=p[i]);
chmin(ans,res);
tot=res=0;
per(i,n,1) if(s&(1<<i-1)) p[++tot]=i;
per(i,n,1) if(!(s&(1<<i-1))) p[++tot]=i;
rep(i,1,n) res+=(a[i]!=p[i]);
chmin(ans,res);
}
printf("%d\n",ans);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 3744kb
input:
1 1
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
2 2 1
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
3 1 2 3
output:
0
result:
ok single line: '0'
Test #4:
score: -10
Wrong Answer
time: 0ms
memory: 3748kb
input:
4 3 1 4 2
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 3740kb
input:
8 7 2 1 8 3 5 4 6
output:
2
result:
wrong answer 1st lines differ - expected: '3', found: '2'
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
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 150ms
memory: 3764kb
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...
output:
2312
result:
wrong answer 1st lines differ - expected: '2188', found: '2312'