rt,我写了一个暴力求解的程序,结果只有30分
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
bool a[10000001];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
int j, k, t;
for (int i = 1; i <= n; i++) {
j = 1; k = i;
while (j < k) {
t = a[j];
a[j] = a[k];
a[k] = t;
j++; k--;
}
for (int o = 1; o <= i; o++) {
if (a[o] == 1) a[o] = 0;
else a[o] = 1;
}
}
for (int i = 1; i <= n; i++) cout << a[i] << ' ';
return 0;
}