QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#818378 | #8050. Random Permutation | Secret Sealing Club (Fei Pan, Jialong Li, Shiyang Xiong)# | WA | 865ms | 4428kb | C++17 | 1.5kb | 2024-12-17 19:39:24 | 2024-12-17 19:39:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define V vector
#define pb push_back
#define all0(x) (x).begin(), (x).end()
#define all1(x) (x).begin() + 1, (x).end()
#define fi first
#define se second
typedef long long LL;
typedef pair<int, int> pi;
const int INF = 2e9 + 10000;
mt19937 mrand(chrono::steady_clock().now().time_since_epoch().count());
void solve() {
int n;
cin >> n;
V<int> a(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
int base = n;
V<int> tab(base * 2 + 1);
const int T = 100;
LL ans = 0;
for (int i = 1; i <= n; i++) {
int len = T * (n / (abs(a[i] - n / 2) + 1));
int l = max(1, i - len), r = min(n, i + len);
int mn = INF, mx = -INF;
int cur = 0;
for (int j = i; j >= l; j--) {
mn = min(mn, cur), mx = max(mx, cur);
tab[base + cur]++;
if (j == l) break;
if (a[j - 1] > a[i]) cur++;
else cur--;
}
cur = 0;
for (int j = i; j <= r; j++) {
ans += 1LL * tab[base - cur] * a[i];
ans += 1LL * tab[base - cur + 1] * a[i];
if (j == r) break;
if (a[j + 1] > a[i]) cur++;
else cur--;
}
for (int i = mn; i <= mx; i++) {
tab[i + base] = 0;
}
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
// int t;
// cin >> t;
// while (t--)
solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3848kb
input:
4 1 4 2 3
output:
22
result:
ok 1 number(s): "22"
Test #2:
score: -100
Wrong Answer
time: 865ms
memory: 4428kb
input:
100000 56449 21738 74917 44834 36187 96576 37204 28451 3444 13029 66039 8955 51445 30706 27229 37159 66052 16691 70389 29935 44984 3648 75082 73600 76621 28345 5298 37940 49412 85260 92029 18185 84398 10233 79227 98312 96649 30680 65206 38879 75397 26951 11294 58085 37297 97167 59252 44104 4058 3796...
output:
241018531290580
result:
wrong answer 1st numbers differ - expected: '250202478701074', found: '241018531290580'