File tree Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Original file line number Diff line number Diff line change 1
- // Authored by : BaaaaaaaaaaarkingDog
1
+ // Authored by : heheHwang
2
2
// Co-authored by : -
3
- // http://boj.kr/****************
3
+ // http://boj.kr/98c1742e07124ec0a3731f5e891a7651
4
4
#include < bits/stdc++.h>
5
5
using namespace std ;
6
6
7
- int main (void ){
7
+ int main (void ) {
8
8
ios::sync_with_stdio (0 );
9
9
cin.tie (0 );
10
-
10
+
11
+ set<int > hu; // 홍익대학교의 명소들 위치
12
+ int N, Q, t, curr = 1 ;
13
+ cin >> N >> Q;
14
+ for (int i = 1 ; i <= N; i++) {
15
+ cin >> t;
16
+ if (t) hu.insert (i);
17
+ }
18
+ while (Q--) {
19
+ cin >> t;
20
+ switch (t) {
21
+ case 1 :
22
+ cin >> t;
23
+ if (hu.find (t) != hu.end ())
24
+ hu.erase (t);
25
+ else
26
+ hu.insert (t);
27
+ break ;
28
+ case 2 :
29
+ cin >> t;
30
+ curr = (curr + t - 1 ) % N + 1 ;
31
+ break ;
32
+ case 3 :
33
+ if (hu.empty ()) cout << -1 << ' \n ' ;
34
+ else {
35
+ auto it = hu.lower_bound (curr);
36
+ if (it != hu.end ())
37
+ cout << *it - curr << ' \n ' ;
38
+ else
39
+ cout << N - curr + *hu.begin () << ' \n ' ;
40
+ }
41
+ }
42
+ }
11
43
}
You can’t perform that action at this time.
0 commit comments