From 4934d21620cca6365ef849c0a84a04b831c207f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=9C=A0=ED=99=98?= Date: Tue, 7 Oct 2025 10:06:49 +0900 Subject: [PATCH] =?UTF-8?q?15787=EB=B2=88=20=ED=92=80=EC=9D=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Appendix C/solutions/15787.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/Appendix C/solutions/15787.cpp b/Appendix C/solutions/15787.cpp index 6c991660..58401da6 100644 --- a/Appendix C/solutions/15787.cpp +++ b/Appendix C/solutions/15787.cpp @@ -1,11 +1,33 @@ -// Authored by : BaaaaaaaaaaarkingDog +// Authored by : uhwan0723 // Co-authored by : - -// http://boj.kr/**************** +// http://boj.kr/213d52a2b98146ccba8b80a28d3f2811 #include using namespace std; +int n, m; + int main(void){ ios::sync_with_stdio(0); cin.tie(0); - -} \ No newline at end of file + cin >> n >> m; + vector v(n, 0); + while(m--){ + int com, i, x; + // 0-index로 쓰기 위해 i는 i-1로, x는 x-1로 사용합니다. + cin >> com >> i; + if(com == 1){ + cin >> x; + v[i-1] |= (1 << (x-1)); + } + else if(com == 2){ + cin >> x; + v[i-1] &= ~(1 << (x-1)); + } + else if(com == 3) + v[i-1] = (v[i-1] << 1) & ((1 << 20) - 1); + else + v[i-1] = v[i-1] >> 1; + } + sort(v.begin(), v.end()); + cout << distance(v.begin(), unique(v.begin(), v.end())); +}