QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#467874#8655. Game of ThrownsBahnasy#AC ✓1ms3820kbC++20901b2024-07-08 18:03:292024-07-08 18:03:32

Judging History

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

  • [2024-07-08 18:03:32]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3820kb
  • [2024-07-08 18:03:29]
  • 提交

answer

// #pragma GCC target("avx2,avx512f,avx512vl,avx512bw,avx512dq,avx512cd,avx512vbmi,avx512vbmi2,avx512vpopcntdq,avx512bitalg,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, k;
    cin >> n >> k;

    stack<int>st;
    int cur = 0;
    st.push(0);
    while (k--) {
        string s;
        cin >> s;
        if (s[0] == 'u') {
            int m;
            cin >> m;
            while (m-- && st.size()) {
                st.pop();
            }
            cur = st.top();
        }
        else {
            int p = stoi(s);
            int nw = (cur + p);
            while (nw < 0)nw += n;
            nw %= n;
            cur = nw;
            st.push(nw);

        }
    }

    cout << cur << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 4
8 -2 3 undo 2

output:

3

result:

ok single line: '3'

Test #2:

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

input:

5 10
7 -3 undo 1 4 3 -9 5 undo 2 undo 1 6

output:

2

result:

ok single line: '2'

Test #3:

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

input:

2 1
0

output:

0

result:

ok single line: '0'

Test #4:

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

input:

2 1
10000

output:

0

result:

ok single line: '0'

Test #5:

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

input:

2 1
-10000

output:

0

result:

ok single line: '0'

Test #6:

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

input:

7 2
10000 undo 1

output:

0

result:

ok single line: '0'

Test #7:

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

input:

7 5
10000 undo 1 10000 undo 1 10000

output:

4

result:

ok single line: '4'

Test #8:

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

input:

1 1
0

output:

0

result:

ok single line: '0'

Test #9:

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

input:

30 100
-8960 -8610 -8968 8277 -8955 8825 2367 undo 5 6439 -8444 -3677 3798 6159 undo 4 undo 1 589 8313 -4905 -4327 -6850 -6315 5169 -4495 6347 -2813 6228 2369 -7758 3164 9143 -3260 -7754 8835 8911 6881 -568 undo 6 498 5359 -1910 -4546 5022 4754 7603 -2885 6066 4830 5867 4857 3762 -5203 -7959 -5940 -...

output:

20

result:

ok single line: '20'

Test #10:

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

input:

30 100
-5700 9463 -6613 7331 -5341 -7462 -115 2741 139 1567 undo 4 -2090 9644 -3466 -5512 -2398 -2781 7511 -1802 -4821 1946 9200 -3915 -7030 -7094 -7281 undo 5 -6450 9011 1367 7894 5653 -4114 9491 -8047 -9414 -2136 -234 -2145 651 6311 undo 6 -8397 -5227 -4459 7156 8330 9100 5088 -1451 -9355 undo 1 7...

output:

25

result:

ok single line: '25'

Test #11:

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

input:

30 100
2849 697 -1637 -8358 -5077 5785 9141 -9328 4553 5225 -6813 undo 1 -5751 -625 8978 3620 3480 -960 -2838 5942 579 undo 9 -1494 undo 3 1058 7904 -1962 -8284 -2740 -2218 1590 5032 5708 -7148 -5856 -7719 undo 7 6811 -4990 9217 undo 8 1786 -7926 -903 2475 8066 -4804 -2880 -3033 -2194 9057 4593 8527...

output:

12

result:

ok single line: '12'

Test #12:

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

input:

30 100
-5566 243 -3016 -3342 9439 1548 7894 9356 2024 -8132 -3663 9 -7378 -3367 2928 9325 8963 -629 3611 -4113 6379 9631 3423 -535 -2916 -1246 6369 2676 -4741 -5795 5952 undo 5 3885 9816 -1022 -4136 -1058 4873 -6528 3546 -9074 8083 4644 undo 1 9754 -2819 1208 -1175 7813 undo 2 6406 8339 9648 -2431 -...

output:

3

result:

ok single line: '3'

Test #13:

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

input:

30 100
4338 -4854 -1570 undo 2 6501 -8111 -6428 -2466 -4534 -9120 undo 5 1117 -772 -6887 6269 8841 7469 -5431 -1791 7805 3039 -4417 -271 -6087 9960 -415 -5788 -6973 -2060 5986 7920 88 317 -3340 7742 2667 -8567 -1067 1930 1131 5194 -554 8042 -6665 2484 -5036 1445 312 853 -2375 -4654 9447 25 8253 7229...

output:

15

result:

ok single line: '15'

Test #14:

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

input:

30 100
5923 undo 1 -5316 undo 1 3758 undo 1 3912 undo 1 9097 undo 1 6908 undo 1 -7769 undo 1 -1229 undo 1 -293 undo 1 -2140 undo 1 -7484 undo 1 9396 undo 1 -9341 undo 1 9336 undo 1 3475 undo 1 -7148 undo 1 -1916 undo 1 3024 undo 1 -1336 undo 1 -5338 undo 1 -2906 undo 1 -9145 undo 1 -7369 undo 1 115 ...

output:

0

result:

ok single line: '0'

Test #15:

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

input:

30 100
-2005 -2263 -4591 7429 1175 8575 2854 3781 4361 5858 -2225 -1115 1376 -693 -4692 -9580 5048 -3173 -1935 7915 5389 -993 -9067 4262 -8616 -5186 -6761 -3741 -5334 1814 4787 -7622 2796 8457 -8689 8423 -2112 928 8180 -6082 1463 -5716 586 7474 7834 -3027 -1612 -6254 -8572 4490 -5495 6766 901 1710 5...

output:

0

result:

ok single line: '0'

Test #16:

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

input:

30 100
-9143 483 -8223 1682 -8830 -7119 6253 -6004 -267 -3187 -7944 6860 5118 8505 -7596 9154 4265 8888 -6740 9246 -4298 6650 -7203 -250 4781 -7240 -6534 -1574 -1931 1003 4385 8968 -8155 7033 3078 -7366 9900 6490 -1874 -8469 9398 7101 9406 -8662 4921 7105 -8890 1792 2107 4614 undo 1 undo 1 undo 1 un...

output:

0

result:

ok single line: '0'