본문 바로가기

Algorithm

C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 1547번:공 답

반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int t, s=0,a[4= { 0,1,0,};
    cin >> t;
    while (t--)
    {
        int x, y;
        cin >> x >> y;
        swap(a[x], a[y]);
    }
    for (int i = 1; i <= 3; i++)
        if (a[i] == 1) { s = 1cout << i << '\n'; }
    if(s==0)
        cout << "-1" << '\n';
    
}
cs