[C++] AtCoder Beginner Contest 187 C번 1-SAT

AtCoder Beginner Contest 187 C번 1-SAT

문제

https://atcoder.jp/contests/abc187/tasks/abc187_c abc187_c

풀이

set 자료형을 이용하여 손쉽게 해결 가능

loop를 돌다가 한가지 케이스라도 발견되면 바로 출력 후 빠져나오자

코드

#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll, ll, ll> tl3;
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define tc(t) while (t--)
// https://atcoder.jp/contests/abc187/tasks/abc187_c
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    unordered_set<string> h(all(s));
    rep(i,n){
        if(h.count('!' + s[i])){
            cout << s[i];
            return 0;
        }
    }
    cout << "satisfiable";

    return 0;
}