QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#828993#8050. Random PermutationNightskyWA 2892ms9724kbC++20930b2024-12-23 23:39:012024-12-23 23:39:02

Judging History

你现在查看的是最新测评结果

  • [2024-12-23 23:39:02]
  • 评测
  • 测评结果:WA
  • 用时:2892ms
  • 内存:9724kb
  • [2024-12-23 23:39:01]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 3e5 + 5;
const int M = 900;
int A[MAXN],pos[MAXN],cnt[(MAXN << 1) + 10],n,v[MAXN];
ll res;
int main()
{
    scanf("%d",&n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d",&A[i]);
        pos[A[i]] = i;
        v[i] = -1;
    }


    for(int i = n; i >= 1; --i)
    {
        int cur = M;
        for(int j = 0; j <= M * 2; ++j) cnt[j] = 0;
        cnt[M] = 1; v[pos[i]] = 1;
        for(int j = pos[i] - 1; j >= 1; --j)
        {
            cur += v[j];
            if(cur > (M << 1) || cur < 0) break;
            cnt[cur]++;
        }
        cur = M;
        for(int j = pos[i]; j <= n; ++j)
        {
            cur += v[j];
            if(cur > (M << 1) || cur < 0) break;
            res += 1ll * i * (cnt[2 * M - cur + 1] + cnt[2 * M - cur + 2]);
        }
    }
    printf("%lld\n",res);
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7976kb

input:

4
1 4 2 3

output:

22

result:

ok 1 number(s): "22"

Test #2:

score: 0
Accepted
time: 788ms
memory: 8648kb

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:

250202478701074

result:

ok 1 number(s): "250202478701074"

Test #3:

score: 0
Accepted
time: 1795ms
memory: 6624kb

input:

200000
70900 189146 39056 135530 191967 133789 108558 81993 132081 113826 54456 127761 27836 64897 87159 105191 109446 81230 75525 90396 75756 50200 43091 151358 100791 193998 157161 119352 176873 120724 134471 155040 138534 182263 161855 4577 124893 199710 60764 146460 75314 43696 129155 64816 1390...

output:

1998651699409551

result:

ok 1 number(s): "1998651699409551"

Test #4:

score: 0
Accepted
time: 2892ms
memory: 9128kb

input:

300000
291335 150122 292004 129126 26666 242892 124454 146198 257953 17400 245611 108131 68345 266915 44851 146376 110324 211968 251982 127849 152791 204625 213884 144643 137727 113838 115018 225220 169217 151 284989 29747 37230 110534 124886 224954 253706 175150 103605 289983 165895 113248 32809 28...

output:

6755672893227829

result:

ok 1 number(s): "6755672893227829"

Test #5:

score: 0
Accepted
time: 2874ms
memory: 9724kb

input:

300000
135644 13106 249143 129835 242825 74615 166757 71595 226579 131061 189926 40413 77323 17706 196799 169583 219200 209681 151434 49233 129178 224147 186722 191982 220492 56613 175968 271850 218400 184533 71674 154830 181350 255732 62120 226122 154464 226934 60637 136046 167000 92035 262614 9832...

output:

6746554421237129

result:

ok 1 number(s): "6746554421237129"

Test #6:

score: -100
Wrong Answer
time: 2867ms
memory: 9724kb

input:

300000
189478 283852 258947 31348 224765 203671 261674 251940 297781 47729 264024 140556 64712 65329 33007 217376 256454 7108 193648 207448 30334 55505 233835 169783 122652 8287 221157 294162 28017 123578 182903 111273 256282 221382 226523 102597 92176 289023 194843 176331 146753 109909 203621 23653...

output:

6744405737212719

result:

wrong answer 1st numbers differ - expected: '6744650229539119', found: '6744405737212719'