The subject at first glance thought it was 2-sat. Actually very water, O (n) on the solution. Enumerate everyone, assuming it's a murderer. Observe whether the condition is met.
Then, the number of satisfied numbers are discussed and solved.
1 /*156B*/2#include <iostream>3#include <string>4#include <map>5#include <queue>6#include <Set>7#include <stack>8#include <vector>9#include <deque>Ten#include <algorithm> One#include <cstdio> A#include <cmath> -#include <ctime> -#include <cstring> the#include <climits> -#include <cctype> -#include <cassert> -#include <functional> +#include <iterator> -#include <iomanip> + using namespacestd; A //#pragma COMMENT (linker, "/stack:102400000,1024000") at - #defineSTI set<int> - #defineStpii Set<pair<int, int> > - #defineMpii map<int,int> - #defineVI vector<int> - #definePII pair<int,int> in #defineVpii vector<pair<int,int> > - #defineRep (I, A, n) for (int i=a;i<n;++i) to #definePer (i, a, n) for (int i=n-1;i>=a;--i) + #defineCLR Clear - #definePB Push_back the #defineMP Make_pair * #defineFIR First $ #defineSEC SecondPanax Notoginseng #defineAll (x) (x). Begin (), (x). End () - #defineSZ (x) ((int) (x). Size ()) the #defineLson L, Mid, rt<<1 + #defineRson mid+1, R, rt<<1|1 A the Const intMAXN = 1e5+5; + intPOS[MAXN], NEG[MAXN]; - VI P[MAXN]; $ VI N[MAXN]; $ intANS[MAXN]; - intST[MAXN]; - Chars[3][ -] = { the "Not defined", - "Truth",Wuyi "Lie" the }; - Wu intMain () { -Ios::sync_with_stdio (false); About #ifndef Online_judge $Freopen ("data.in","R", stdin); -Freopen ("Data.out","W", stdout); - #endif - A intN, m, X; + intPN =0, nn =0; the -scanf"%d%d", &n, &m); $Rep (I,1, n+1) { thescanf"%d", &x); the if(X >0) { the++Pos[x]; the P[X].PB (i); -++PN; in}Else { thex =-x; the++Neg[x]; About N[X].PB (i); the++nn; the } the } + - inttmp; the vi VC;Bayi theRep (I,1, n+1) { the //i is Murder -TMP = Pos[i] + nn-Neg[i]; - if(TMP = =m) the VC.PB (i); the } the the intSZ =SZ (VC); - if(SZ = =1) { thex = vc[0]; theRep (I,1, n+1) theSt[i] =-1;94ST[X] =1; the}Else { theRep (I,1, n+1) theSt[i] =-1;98Rep (I,0, SZ) AboutSt[vc[i]] =0; - }101Rep (I,1, n+1) {102SZ =SZ (P[i]);103 if(SZ &&St[i]) {104x = st[i]>0?1:2; theRep (J,0, SZ)106ANS[P[I][J]] =x;107 }108SZ =SZ (N[i]);109 if(SZ &&St[i]) { thex = st[i]<0?1:2;111Rep (J,0, SZ) theANS[N[I][J]] =x;113 } the } the theRep (I,1, n+1)117 puts (s[ans[i]);118 119 #ifndef Online_judge -printf"Time =%d.\n", (int) clock ());121 #endif122 123 return 0;124}
"CF" Div.1 B. Suspects