QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#233995#7072. PhotographstcmuyiWA 1ms3772kbC++201.7kb2023-11-01 12:21:462023-11-01 12:21:47

Judging History

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

  • [2023-11-01 12:21:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3772kb
  • [2023-11-01 12:21:46]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define i64 long long
#define endl '\n'
#define lb(x) ((x) & (-x))
using namespace std;
const i64 mod = 1e9+7;
const int maxn = 1e4+10;
signed main()
{
    IOS;
    int n,q; cin >> n >> q;
    vector<i64> h(n+1);
    for(int i = 1; i <= n; ++i) cin >> h[i];
    vector<int> p(n+1);
    for(int i = 1; i <= n; ++i)  cin >> p[i];
    auto ck = [&](int x) -> i64
    {
        set<int> st;
        i64 ans = 0,sum = 0;
        vector<int> id(n+1);
        int idx = 0;
        for(int i = x; i <= n; ++i) id[++idx] = p[i];
        for(int i = 1; i < x; ++i) id[++idx] = p[i];
        for(int i = 1; i <= n; ++i)
        {
            st.insert(id[i]);
            auto it = st.lower_bound(id[i]);
            if(it != st.begin())
            {
                int l = *prev(it);
                ans = (ans + (h[l] - h[id[i]]) * (h[l] - h[id[i]])) % mod;
            }
            if(next(it) != st.end())
            {
                int r = *next(it);
                ans = (ans + (h[r] - h[id[i]]) * (h[r] - h[id[i]])) % mod;
            }
            if(it != st.begin() && next(it) != st.end())
            {
                int l = *prev(it);
                int r = *next(it);
                ans = (ans - (h[r] - h[l]) * (h[r] - h[l]) + mod) % mod;
            }
            sum = (sum + ans) % mod;
        }
        return sum;
    };
    i64 ans = ck(1);
    cout << ans << endl;
    int top = 1;
    while(q--)
    {
        int k; cin >> k;
        top = (top - 1 + k + ans) % n + 1;
        ans = ck(top);
        cout << ans << endl;
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3476kb

input:

5 4
1 2 3 4 5
1 2 3 4 5
6
6
8
10

output:

10
10
13
21
36

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

1 100
9139
1
815121916
455099013
31761433
46418945
11466871
709189476
658667824
977821005
511405192
843598992
501074199
638564514
680433292
994431111
584582554
452689372
642414314
863578235
135133204
438404803
67246919
492858783
447116205
723252212
948645336
191050463
326944894
685212650
828613990
1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 101 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

2 100
9859 8096
2 1
692572036
546897526
810778144
630776743
411450468
47253421
344401774
898201838
853758724
613913038
441359030
921437570
855535818
106915566
108572797
533697405
315571976
503278469
849317884
327448764
867873746
718830950
808828124
547579134
751502930
595486247
629024078
79153124
34...

output:

3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108169
3108...

result:

ok 101 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

3 100
5987 4237 8891
3 1 2
760669141
361439344
393719043
515372386
379329282
704177992
446687639
688441074
939269095
570763162
492018656
161714447
596461367
384092911
304150759
54574629
350079205
804917425
296791887
311704304
120533843
281070757
787668201
311851357
243944555
860970785
463288414
9962...

output:

33155432
33155432
33155432
46381932
33155432
46381932
33155432
27784716
27784716
46381932
33155432
27784716
33155432
27784716
46381932
33155432
46381932
33155432
33155432
46381932
27784716
33155432
33155432
46381932
33155432
27784716
33155432
33155432
46381932
46381932
46381932
46381932
46381932
277...

result:

ok 101 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

4 100
9411 3081 2149 9907
2 4 1 3
890272966
654059361
166090080
333233666
911989359
541813943
232020213
717913040
277628991
24281180
424608385
453986387
234435555
940076771
584737344
285922050
322027160
55417534
219258279
944530197
902531317
204963356
159347669
59389769
496952588
412286058
62840111
...

output:

234381540
194798256
163047900
163047900
214293312
234381540
163047900
234381540
234381540
163047900
163047900
234381540
163047900
194798256
214293312
214293312
163047900
163047900
214293312
234381540
214293312
194798256
194798256
163047900
234381540
234381540
194798256
214293312
194798256
234381540
...

result:

ok 101 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

5 100
5539 9221 6895 2089 8673
1 2 3 5 4
77109657
780837560
486885376
754808995
539371459
829908259
461093031
358202421
812475269
330167945
420738799
449755992
974016054
893157388
911184149
27096064
544888624
181378986
949932667
679253230
633194309
392611044
893327579
740816578
390443961
911660892
1...

output:

140067300
223307496
291786308
223307496
291786308
140067300
203804176
171252896
291786308
140067300
140067300
203804176
223307496
223307496
171252896
171252896
171252896
171252896
291786308
291786308
171252896
171252896
171252896
171252896
140067300
171252896
203804176
140067300
140067300
140067300
...

result:

ok 101 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

6 100
6259 770 7448 3054 7926 1667
2 1 5 3 6 4
322065559
589340392
229869162
513690899
994467050
633820414
856590056
742301205
94367267
935173705
269614273
371228927
648897289
275136359
947994032
14652900
375199561
962516208
27020002
91805311
784722753
914752052
789918299
362845589
71976266
81221521...

output:

457491743
457491743
373376971
301534488
373376971
457491743
373376971
457491743
405608641
405608641
301534488
374356525
374356525
285814308
457491743
285814308
285814308
405608641
373376971
405608641
301534488
285814308
373376971
373376971
373376971
457491743
301534488
374356525
457491743
373376971
...

result:

ok 101 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

7 100
2387 5422 4898 2532 2988 4636 9872
7 6 4 1 5 2 3
989301423
726738333
762016619
720019121
224386186
389607162
105343720
162417396
185295808
598490187
99799082
648854654
536061877
114509431
283693326
282358088
275870967
913068064
614906460
852055446
91973668
194752801
390559107
461675312
2011715...

output:

214808460
176848801
221076979
177842834
214808460
141417382
177842834
177842834
183113350
177842834
183113350
177842834
176848801
95737577
214808460
221076979
95737577
214808460
183113350
183113350
141417382
221076979
95737577
214808460
221076979
221076979
95737577
176848801
221076979
177842834
1768...

result:

ok 101 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

8 100
8515 1563 5451 4713 9537 709 3343 1819
6 3 5 4 7 2 8 1
836830783
902424840
284979127
688898930
59994023
808377077
930879146
894119069
821284022
790534164
228245558
799101331
178643742
437272706
727533806
775447721
24262953
878651956
922486099
872583248
662851066
537459716
952308815
516311556
5...

output:

751938476
437536532
772628520
652581904
751938476
437536532
557787696
652581904
437536532
686111272
562017712
772628520
695734860
557787696
652581904
557787696
686111272
652581904
695734860
562017712
562017712
437536532
437536532
652581904
695734860
652581904
686111272
686111272
695734860
652581904
...

result:

ok 101 lines

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3596kb

input:

9 100
1939 407 197 4191 8791 9486 8030 5807 11
3 6 9 1 8 7 5 2 4
315381698
90569951
966739056
839050299
904095993
625868334
181495123
11473484
460154086
971398763
979097531
680974958
656252706
241084925
897974527
468605657
884412240
443130759
588996224
238053542
114337251
472276082
321394542
8344271...

output:

23923916
605498323
799677263
23923916
674262593
799677263
403693374
373588111
799677263
799677263
561924404
605498313
561924404
373588111
373588111
23923916
799677263
23923916
674262593
605498313
476117235
476117235
605498323
674262593
605498313
799677263
605498313
23923916
476117235
605498323
23923...

result:

wrong answer 1st lines differ - expected: '1023923923', found: '23923916'