1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
#include <bits/stdc++.h> #define all(vec) vec.begin(),vec.end() #define lson(o) (o<<1) #define rson(o) (o<<1|1) #define SZ(a) ((long long) a.size()) #define debug(var) cerr << #var <<" = ["<<var<<"]"<<"\n"; #define debug1d(a) \ cerr << #a << " = ["; \ for (int i = 0; i < (int)(a).size(); i++) \ cerr << (i ? ", " : "") << a[i]; \ cerr << "]\n"; #define debug2d(a) \ cerr << #a << " = [\n"; \ for (int i = 0; i < (int)(a).size(); i++) \ { \ cerr << " ["; \ for (int j = 0; j < (int)(a[i]).size(); j++) \ cerr << (j ? ", " : "") << a[i][j]; \ cerr << "]\n"; \ } \ cerr << "]\n"; #define cend cerr<<"\n-----------\n" #define fsp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long; using ull = unsigned long long; using DB = double; using i128 = __int128; using CD = complex<double>;
static constexpr ll MAXN = (ll)1e6+10, INF = (1ll<<61)-1; static constexpr ll mod = 998244353; static constexpr double eps = 1e-8; const double pi = acos(-1.0);
ll lT,testcase;
struct A_b_c { ll a,b,c; auto operator<=>(const A_b_c&o) const = default; }; void Solve() { ll N; cin >> N; vector<A_b_c> A(N+2); vector<ll> cnt(10); for (int i=1;i<=N;++i) { ll a,b,c; cin>>a>>b>>c; A[i]={a,b,c}; if (A[i]==A_b_c{1,0,0}) { cnt[1]++; }else if (A[i]==A_b_c{0,1,0}) { cnt[2]++; }else if (A[i]==A_b_c{0,0,1}){ cnt[3]++; } } if (cnt[1] && cnt[2] && cnt[3]) { cout<<3<<"\n"; return; } for (int i=1;i<=N;++i) { if (A[i]==A_b_c{1,0,0}) {
}else if (A[i]==A_b_c{0,1,0}) {
}else if (A[i]==A_b_c{0,0,1}){
}else { if (A[i].a && cnt[1]) { ++cnt[1]; }else if (A[i].b && cnt[2]) { ++cnt[2]; }else if (A[i].c && cnt[3]) { ++cnt[3]; }else if (A[i]==A_b_c{1,1,0}) { ++cnt[4]; }else if (A[i]==A_b_c{1,0,1}) { ++cnt[5]; }else if (A[i]==A_b_c{0,1,1}) { ++cnt[6]; }else if (A[i]==A_b_c{1,1,1}) { ++cnt[7]; } } } ll ans1=ll(bool(cnt[1]))+ll(bool(cnt[2]))+ll(bool(cnt[3])); ll ans2=ll(bool(cnt[4]))+ll(bool(cnt[5]))+ll(bool(cnt[6])); ll ans=ans1; if (ans1) { if (ans2) { ++ans; } }else { if (ans2<=2) { ans=1; }else { ans=2; } } if (ans==0 && cnt[7]) { ++ans; } cout<<ans<<"\n"; }
signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef LOCAL cout.setf(ios::unitbuf); #endif
Solve(); return 0; }
|