Problem:
Problem E: SAT-EN-3
彼女は悩んでいた。成績が良くないのだ。両親に無理を言って全寮制の学校に入学したものの、彼女の才能は一向に開花することはなかった。あるいは才能など元々なかったのかもしれないが、それはできるだけ考えたくない可能性だった。
そこで彼女が頼ったのは、インターネット上で見つけた怪しげな脳力トレーニングの教材だった。SAT-EN-3 (SATisifiability problem for Enhancement of Neuron: version 3) と銘打つその学習メソッドによると、充足可能性問題のようなもののインスタンスをひたすら手で解くことによって、計算力が向上し、引いては論理的思考力・直感力・想像力も豊かになり、部活動でも活躍できて恋愛もうまくいくのだという。さすがに最後の2つは眉唾ものじゃないかな、と彼女は思ったが、ソロバンや百マス計算のような例もあることだ。暗算が得意になったら儲けものかな、ぐらいの気楽さで、彼女はこの教材に取り組んでみることにした。
SAT-EN-3では、加法標準形で表される論理式の各変数に適切に割り当て、論理式の値を真にすることができるかどうか判定しなければならない。ちなみに、1つ以上の変数 (または、その否定) の論理積を 節 (clause) と呼び、いくつかの節の論理和で表される論理式のみが加法標準形に従っている。一般に充足可能性問題といえば論理式は乗法標準形で表されるが、SAT-EN-3では加法標準形であることに注意せよ。
彼女はしばらく SAT-EN-3 の問題集に取り組もうとして、ふと思い直した。問題集にお金を払うぐらいなら、プログラミングが得意な親友にパフェでもご馳走して、 SAT-EN-3 の問題を生成し、解くプログラムを書いてもらおう。そうすれば問題も解答もいくらでも手にはいるじゃないか。
こうして彼女の親友であるあなたは、SAT-EN-3を解くプログラムを書くことになったのである。
Input
入力は複数のケースからなる。
各ケースは以下のフォーマットで与えられる。
expression
入力の終わりは
"#"
からなる行によって与えられる
expression
は以下のBNFに従う。
ここでは文字列リテラルを""を用いて囲んでいる。
実際の入力に""は含まれない。
また入力には余計な空白は含まれていない。
<expression> ::= "("<clause>")" | "("<clause>")|("<expression>")"
<clause> ::= <literal>"&"<literal>"&"<literal>
<literal> ::= <variable> | "~"<variable>
<variable> ::= [a-z]|[A-z]
expression
の長さは500文字を超えない。
テストケースの数は1100個を超えない。
Output
与えられた式を満たす変数の割り当てが存在するのならばyesを、そうでなければnoを出力せよ。
Sample input
(B&B&f)|(~d&~i&i)|(~v&i&~V)|(~g&~e&o)|(~f&d&~v)|(d&~i&o)|(g&i&~B)|(~i&f&d)|(e&~i&~V)|(~v&f&~d)
(S&X&~X)
#
Sample output
yes
no
The University of Aizu Programming Contest 2011 Summer
原案: Tomoya Sakai
問題文: Takashi Tayama

Submitted solutions:

code_snippet: #include <bits/stdc++.h>

std::map<std::string, std::string> anti_literal;

struct Parser {
    using CopyIter = std::string::const_iterator;
    using Iter = CopyIter&;
    std::string line;
    Parser(std::string s): line(s) {}
    void skip(Iter it, char c) {
        ++it;
    }
    std::vector<std::array<std::string, 3>> parse() {
        auto it = line.cbegin();
        return expr(it);
    }

    std::vector<std::array<std::string, 3>> expr(Iter it) {
        std::vector<std::array<std::string, 3>> res;
        res.push_back(clause(it));
        while (it != line.end()) {
            skip(it, '|');
            res.push_back(clause(it));
        }
        return res;
    }

    std::array<std::string, 3> clause(Iter it) {
        skip(it, '(');
        auto l = literal(it);
        skip(it, '&');
        auto m = literal(it);
        skip(it, '&');
        auto r = literal(it);
        skip(it, ')');
        return {l, m, r};
    }

    std::string literal(Iter it) {
        if (*it == '~') {
            std::string s(it, it + 2);
            it++;
            it++;
            return s;
        } else {
            std::string s(it, it + 1);
            it++;
            return s;
        }
    }
};

int main() {
    constexpr int N = 26;
    for (int i = 0; i < N; i++) {
        {
            std::string s(1, (char)('a') + i);
            std::string t = "~" + s;
            anti_literal[s] = t;
            anti_literal[t] = s;
        }

        {
            std::string s(1, (char)('A') + i);
            std::string t = "~" + s;
            anti_literal[s] = t;
            anti_literal[t] = s;
        }
    }

    while (true) {
        std::string line;
        std::getline(std::cin, line);
        if (line == "#") break;
        Parser parser(line);
        auto clauses = parser.parse();

        bool ok = false;
        for (auto clause: clauses) {
            bool flag = true;
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    if (clause[i] == anti_literal[clause[j]]) {
                        flag = false;
                        break;
                    }
                }
            }
            ok |= flag;
        }

        std::cout << (ok ? "yes" : "no") << std::endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3456
final_rank: 18

code_snippet: #pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
// random_device rd;
// mt19937 mt(rd());
// #include <boost/numeric/interval.hpp>
// #include <boost/numeric/interval/io.hpp>
// #include <boost/intrusive/rbtree.hpp>
// #include <boost/geometry.hpp>
// #include <boost/geometry/geometries/linestring.hpp>
// #include <boost/geometry/geometries/polygon.hpp>
// #include <boost/geometry/geometries/point_xy.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cfloat;
// typedef mp::cpp_int cint;

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
template<typename T=long long>using pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T=long long>using pqueue =__gnu_pbds::priority_queue<T, less<T>,rc_binomial_heap_tag>;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
//#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define _output(v) do{bool f=0;rep(i,v.size()){cout<<(f?" ":"");if(v[i]>INF/2)cout<<"INF";else cout<<v[i];f=1;}cout<<"\n";}while(0)
#define _output2(v) rep(j,v.size()){_output(v[j]);}
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define LINF 9223372036854775807
#define MOD 998244353
#define endl "\n"
template<typename T=lint>T in(){return *istream_iterator<T>(cin);}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
template<typename T=lint>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<typename T=lint>inline T add(T a,T b){return a+b;}
template<typename T=lint>inline T minq(T a,T b){return min(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

bool j(string s){
    auto d=split(s,'&');
    set<string>v(all(d));
    for(string t:v){
        if(v.count("~"+t))return 0;
    }
    return 1;
}
int main(){
    while(1){
        bool f=0;
        string s;
        cin>>s;
        if(s=="#")break;
        svec d=split(s,'|');
        for(string l:d){
            if(j(l.substr(1,l.size()-2)))f=1;
        }
        if(f)cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}
accuracy: 1
time_ms: 40
memory_kb: 3228
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;

string s;

bool solve();

int main() {
  while(1) {
    cin >> s;
    if(s == "#") break;
    if(solve())
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

bool solve() {
  long long ssize = s.size();
  for(int i = 0; i < ssize; ++i) {
    vector<bool> large[2], small[2];
    for(int i = 0; i < 2; ++i) {
      large[i].assign(26, 0);
      small[i].assign(26, 0);
    }
    assert(s[i] == '(');
    ++i;
    for(int j = 0; j < 3; ++j) {
      bool ch = 0;
      if(s[i] == '~') ch = 1, ++i;
      if(s[i] >= 'a' && s[i] <= 'z')
        small[ch][s[i++] - 'a'] = 1;
      else
        large[ch][s[i++] - 'A'] = 1;
      if(j != 2)
        assert(s[i] == '&');
      else
        assert(s[i] == ')');
      ++i;
    }
    bool isok = 1;
    for(int j = 0; j < 26; ++j) {
      if(small[0][j] && small[1][j]) isok = 0;
      if(large[0][j] && large[1][j]) isok = 0;
    }
    if(isok) return 1;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3172
final_rank: 12

code_snippet: #pragma warning(disable:4996)
#include <bits/stdc++.h>
using namespace std;

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;

TPL<TNM T> inline bool chmin(T&a, T&b) { if (a > b) { a = b; return true; } return false; }
TPL<TNM T> inline bool chmax(T&a, T&b) { if (a < b) { a = b; return true; } return false; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

set<char> alphabets(string s) {
	set<char> st;
	for (char c : s) {
		if (isalpha(c)) {
			st.insert(c);
		}
	}
	return st;
}

bool solve(string s, set<char> st) {
	map<string, int> cnt;
	bool n = false;
	char v;
	for (char c : s) {
		if (c == '~') {
			n = true;
		}
		else if (c == '&' || c == ')') {
			//not?
			if (n) {
				cnt["~" + string{ v }]++;
			}
			else {
				cnt[string{ v }]++;
			}
			n = false;
		}
		else {
			v = c;
		}
	}
	for (char c : st) {
		if (cnt[string{ c }] && cnt["~" + string{ c }]) {
			return false;
		}
	}
	return true;
}

void solve2(vector<string>& vs) {
	for (int i = 0; i < vs.size(); ++i) {
		set<char> st = alphabets(vs[i]);
		if (solve(vs[i], st)) {
			cout << "yes" << endl;
			return;
		}
	}
	cout << "no" << endl;
	return;
}
int main(void) {
	while (1) {
		string S;
		cin >> S;
		if (S == "#")break;
		vector<string> vs = split(S, '|');
		solve2(vs);
	}
	
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3236
final_rank: 15

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

vector<string> parse(string &s, char dec) {
    int pos = 0;
    vector<string> res;
    s += dec;
    REP(i, 0, s.size()) {
        if (s[i] == dec) {
            res.push_back(s.substr(pos, i - pos));
            pos = i + 1;
        }
    }
    return res;
}

bool check(vector<int> &var) {
    set<int> s;
    for (auto &n : var) {
        if(s.count(-n)) {
            return false;
        }
        s.insert(n);
    }
    return true;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    while (cin >> s, s != "#") {
        vector<string> clauses = parse(s, '|');
        bool ans = false;
        for (auto clause : clauses) {
            clause = clause.substr(1, clause.size() - 2);
            vector<string> literals = parse(clause, '&');
            vector<int> var;
            for (auto literal : literals) {
                int sign = 2 * (literal[0] != '~') - 1;
                int num = literal[literal.size() - 1];
                var.push_back(sign * num);
            }
            ans |= check(var);
        }
        cout << (ans ? "yes" : "no") << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3196
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<string> split(const string &s, char delim){
	vector<string> ret;
	stringstream ss(s);
	string x;
	while(getline(ss, x, delim)) if(!x.empty()) ret.push_back(x);
	return ret;
};

bool f(string s){
	while(s.front() == '(') s = s.substr(1);
	while(s.back() == ')') s.pop_back();
	auto s1 = split(s, '&');
	bool check[256][2] = { 0 };
	for(auto t : s1){
		int j = 0;
		if(t.size() == 2) j = 1;
		if(check[t.back()][1 - j]) return false;
		check[t.back()][j] = 1;
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	while(cin >> s, s != "#"){
		auto s1 = split(s, '|');
		bool ok = false;
		for(auto v : s1){
			if(f(v)){
				ok = true;
				break;
			}
		}
		if(ok) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3176
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

vector<string> e(string s)
{
    int S = s.size();
    vector<string> ret;

    int st = 0;
    while(st<S)
    {
        int idx = st;
        while(idx<S && s[idx]!='|') ++idx;
        ret.pb(s.substr(st,idx-st));
        st = idx+1;
    }
    return ret;
}

int cv(char c)
{
    if('a'<=c && c<='z') return c-'a';
    return 26+c-'A';
}

bool c(string s)
{
    s = s.substr(1,s.size()-2);
    int S = s.size();

    vector<string> v;
    int st = 0;
    while(st<S)
    {
        int idx = st;
        while(idx<S && s[idx]!='&') ++idx;
        v.pb(s.substr(st,idx-st));
        st = idx+1;
    }

    bool t[52]={}, f[52]={};
    for(string a:v)
    {
        if(a[0]=='~') f[cv(a[1])] = true;
        else t[cv(a[0])] = true;
    }

    rep(i,52)if(t[i]&&f[i]) return false;
    return true;
}

string solve(string s)
{
    for(string a:e(s))if(c(a)) return "yes";
    return "no";
}

int main()
{
    string s;
    while(cin >>s,s!="#") cout << solve(s) << endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3160
final_rank: 10

code_snippet: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

// ?????????????????????????????§????????£???????????????
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
	
    while(getline(ss, buffer, sep)){
        v.push_back(buffer);
    }
	
    return v;
}

int main(){
	
	string str;
	
	while(true){
		
		cin >> str;
		
		if(str.size() == 1){
			break;
		}
		
		vector<string> v;
		
		v = split(str, '|');
		
		bool flag = false;
		
		for(int i = 0; i < v.size(); i++){
			string str_c = v[i];
			//cout << str_c << endl;
			bool flag2 = true;
			for(int j = 0; j < 26; j++){
				string str11 = "&A";
				string str12 = "(A";
				string str2 = "~A";
				str11[1] = str12[1] = str2[1] = 'A' + j;
				if(((int)str_c.find(str11) != string::npos || (int)str_c.find(str12) != string::npos) && (int)str_c.find(str2) != string::npos){
					//cout << str11 << endl;
					flag2 = false;
				}
			}
			for(int j = 0; j < 26; j++){
				string str11 = "&A";
				string str12 = "(A";
				string str2 = "~A";
				str11[1] = str12[1] = str2[1] = 'a' + j;
				if(((int)str_c.find(str11) != string::npos || (int)str_c.find(str12) != string::npos) && (int)str_c.find(str2) != string::npos){
					//cout << str11 << endl;
					flag2 = false;
				}
			}
			flag = flag || flag2;
		}
		
				if(flag){
					cout << "yes" << endl;
				}else{
					cout << "no" << endl;
				}
		
	}
	
	return 0;
}
accuracy: 1
time_ms: 190
memory_kb: 3068
final_rank: 20

code_snippet: #include <iostream>
#include <sstream>
#include <vector>

int main()
{
    std::string s;
    while (1) {
        std::cin >> s;
        if (s == "#") {
            break;
        }

        bool ok = 0;
        std::stringstream ss{s};        
        while (std::getline(ss, s, '|')) {
            std::string t = s.substr(1, s.size() - 2);
            std::stringstream tt{t};
            
            std::vector<int> v(256, 0);
            while (std::getline(tt, s, '&')) {
                if (s[0] == '~') {
                    v[s[1]] |= 2;
                } else {
                    v[s[0]] |= 1;
                }
            }
            
            bool f = 1;
            for (int i = 0; i < 256; i++) {
                if (v[i] == 3) {
                    f = 0;
                }
            }
            ok |= f;
        }
        std::cout << (ok ? "yes" : "no") << std::endl;
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3176
final_rank: 17

code_snippet: #include<iostream>
#include<string>
using namespace std;
string S;
bool search(string F) {
	string U[3]; F += '&'; string G = ""; int cnt = 0;
	for (int i = 0; i<F.size(); i++) {
		if (F[i] == '&') { U[cnt] = G; cnt++; G = ""; }
		else G += F[i];
	}
	if (U[0].size() == 1 && U[1].size() == 2 && U[0][0] == U[1][1])return false;
	if (U[0].size() == 1 && U[2].size() == 2 && U[0][0] == U[2][1])return false;
	if (U[1].size() == 1 && U[2].size() == 2 && U[1][0] == U[2][1])return false;
	if (U[0].size() == 2 && U[1].size() == 1 && U[0][1] == U[1][0])return false;
	if (U[0].size() == 2 && U[2].size() == 1 && U[0][1] == U[2][0])return false;
	if (U[1].size() == 2 && U[2].size() == 1 && U[1][1] == U[2][0])return false;
	return true;
}
int main() {
	while (true) {
		cin >> S; if (S == "#")break;
		S += '|'; string T = ""; bool OK = false;
		for (int i = 0; i<S.size(); i++) {
			if (S[i] == '|') { if (search(T) == true)OK = true; T = ""; }
			if (S[i] != '|' && S[i] != '(' && S[i] != ')')T += S[i];
		}
		if (OK == true)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3072
final_rank: 9

code_snippet: #include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
string s;
int main() {
	while (cin >> s, s != "#") {
		s += '|';
		int pre = -1; vector<string> v;
		for (int i = 1; i < s.size(); i++) {
			if (s[i] == '|') {
				v.push_back(s.substr(pre + 2, i - pre - 3));
				pre = i;
			}
		}
		bool flag = false;
		for (int i = 0; i < v.size(); i++) {
			v[i] += '&';
			int pre2 = -1; vector<bool> c(256, false);
			for (int j = 1; j < v[i].size(); j++) {
				if (v[i][j] == '&') {
					string w = v[i].substr(pre2 + 1, j - pre2 - 1);
					if (w[0] == '~') c[w[1] + 128] = true;
					else c[w[0]] = true;
					pre2 = j;
				}
			}
			bool ok = true;
			for (int j = 0; j < 128; j++) {
				if (c[j] && c[j + 128]) ok = false;
			}
			if (ok) flag = true;
		}
		cout << (flag ? "yes" : "no") << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3164
final_rank: 11

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {
	while(1){
		string st; cin >> st;
		if (st == "#")break;
		vector<string>exprs(split(st,'|'));
		bool ans = false;
		for (auto expr:exprs) {
			expr = expr.substr(1, expr.size() - 2);
			vector<string>lites(split(expr, '&'));
			set<char>trues, falses;
			for (auto lite : lites) {
				if (lite[0] == '~')falses.emplace(lite[1]);
				else trues.emplace(lite[0]);
			}
			bool ok = true;
			for (auto t : trues) {
				for (auto f : falses) {
					if (t == f)ok = false;
				}
			}
			if (ok)ans = true;
		}
		if (ans)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3112
final_rank: 16

code_snippet: #include <iostream>
#include <vector>
using namespace std;

vector<string> split(const string &str, const string &delim){
  vector<string> res;
  size_t current = 0, found, delimlen = delim.size();
  while((found = str.find(delim, current)) != string::npos){
    res.push_back(string(str, current, found - current));
    current = found + delimlen;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}


void solve(string expr)
{
  bool answer = false;

  vector<string> strings = split(expr, "|");

  for (int i = 0; i < strings.size(); i++) {
    strings[i] = strings[i].substr(1, strings[i].size() - 2);
    // cout << strings[i] << endl;
    vector<string> sstrings = split(strings[i], "&");

    bool t[3];
    char c[3];
    for (int i = 0; i < 3; i++)
    {
      if (sstrings[i].size() == 1)
      {
        c[i] = sstrings[i][0];
        t[i] = false;
      }
      else
      {
        c[i] = sstrings[i][1];
        t[i] = true;
      }

      // cout << c[i] << t[i] << endl;
    }

    if (!((c[0] == c[1] && t[0] != t[1]) || (c[0] == c[2] && t[0] != t[2]) || (c[1] == c[2] && t[1] != t[2])))
    {
      answer = true;
      // cout << "false" << endl;
      break;
    }
  }

  cout << (answer ? "yes" : "no") << endl;
}

int main()
{
  while (true)
  {
    string input;
    cin >> input;

    if (input == "#") { break; }
    solve(input);
  }
}
accuracy: 1
time_ms: 20
memory_kb: 1192
final_rank: 5

code_snippet: #include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

typedef pair<int,char> P;

int main()
{
	string s;
	while(cin>>s,s!="#"){
	
		//notじゃないのを入れる,notのを入れる
		set<char> sc1,sc2;
		bool ok=true;
		for(int i=0;i<s.size();i++){
			if(s[i]=='('){ok=true; sc1.clear(); sc2.clear();}
			if(s[i]==')' && ok) break;
			if('a'<=s[i] && s[i]<='z' || 'A'<=s[i] && s[i]<='Z'){
				if(s[i-1]=='~'){
				 if(sc1.find(s[i])!=sc1.end()) ok=false;
				 else sc2.insert(s[i]);
				}else{
					if(sc2.find(s[i])!=sc2.end()) ok=false;
					else sc1.insert(s[i]);
				}

			}
			
		}
	
		if(ok) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	
	}
	
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1188
final_rank: 2

code_snippet: #include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

typedef pair<int,char> P;

int main()
{
	string s;
	while(cin>>s,s!="#"){
	
		//notテ」ツ?佚」ツつε」ツ?ェテ」ツ??」ツ?ョテ」ツつ津・ツ?・テ」ツつ古」ツつ?notテ」ツ?ョテ」ツつ津・ツ?・テ」ツつ古」ツつ?
		set<char> sc1,sc2;
		bool ok=true;
		for(int i=0;i<s.size();i++){
			if(s[i]=='('){ok=true; sc1.clear(); sc2.clear();}
			if(s[i]==')' && ok) break;
			if('a'<=s[i] && s[i]<='z' || 'A'<=s[i] && s[i]<='Z'){
				if(s[i-1]=='~'){
				 if(sc1.find(s[i])!=sc1.end()) ok=false;
				 else sc2.insert(s[i]);
				}else{
					if(sc2.find(s[i])!=sc2.end()) ok=false;
					else sc1.insert(s[i]);
				}

			}
			
		}
	
		if(ok) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	
	}
	
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1184
final_rank: 1

code_snippet: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

bool expr(string str) {
	vector<string> cls;
	string s="";
	rep(i, str.length()) {
		if(str[i] == '|') {
			cls.push_back(s);
			s = "";
		}
		else {
			s += str[i];
		}
	}
	cls.push_back(s);
	rep(i, cls.size()) {
		vector<string> lit;
		string s="";
		for(int j=1; cls[i][j]!=')'; j++) {
			if( cls[i][j] == '&' ) {
				lit.push_back(s);
				s = "";
			} else {
				s += cls[i][j];
			}
		}
		lit.push_back(s);
		bool ok = true;
		rep(j, lit.size()) {
			for(int k=j+1; k<lit.size(); k++) {
				if(lit[j][lit[j].length()-1] == lit[k][lit[k].length()-1] &&
					lit[j].length() != lit[k].length() ) {
					ok = false;
				}
			}
		}
		if(ok) return true;
	}
	return false;
}

int main() {
	string in;
	while(cin >> in, in!="#") {
		if( expr(in) ) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1196
final_rank: 7

code_snippet: #include<bits/stdc++.h>
using namespace std;

vector<string> split(string s, char sp){
  vector<string> res;
  int prev_split_point = 0;
  for (int i = 0; i < s.length(); i++) {
    while(s[i] != sp && i < s.length())i++;
    res.push_back(s.substr(prev_split_point, i - prev_split_point));
    prev_split_point = i + 1;
  }
  return res;
}


int main(int argc, char *argv[]){
  string s;
  while(cin >> s){
    if(s == "#")break;
    bool ans = false;
    vector<string> clous = split(s, '|');
    for (int i = 0; i < clous.size(); i++) {
      clous[i] = clous[i].substr(1, clous[i].length() - 2);
      for (int j = 0; j < clous[i].length() - 1; j++) {
        if(clous[i][j + 1] == '~' &&
           clous[i][j] == '~') {
          clous[i].erase(clous[i].begin() + j);
          clous[i].erase(clous[i].begin() + j);
          j--;
        }
      }
    }
    for (int i = 0; i < clous.size() && ans == false; i++) {
      bool flag = true;
      vector<string> litral = split(clous[i], '&');
      for (int j = 0; j < litral.size(); j++) {
        for (int k = 0; k < litral.size(); k++) {
          if(litral[j] == '~' + litral[k]){
            flag = false;
            j = litral.size(), k = litral.size();
          }
        }
      }
      if(flag)ans = true;
    }
    if(ans) std::cout << "yes" << std::endl;
    else std::cout << "no" << std::endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1192
final_rank: 5

code_snippet: #include<iostream>
#include<vector>
#include<cctype>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;

int main(){
  string s;
  while(cin >> s){
    if(s == "#")break;

    bool SAT = false;
    rep(i,s.size()){
      if(s[i] == '('){
	i++;
	string clause;
	while(s[i]!=')')clause += s[i++];

	vector<char> pos, neg;
	rep(j,clause.size()){
	  if(isalpha(clause[j]))pos.push_back(clause[j]);
	  else neg.push_back(clause[++j]);
	  j++;
	}

	bool f = true;
	rep(x,pos.size()){
	  rep(y,neg.size()){
	    if(pos[x] == neg[y])f = false;
	  }
	}
	SAT |= f;
      }
      if(SAT)break;
    }

    if(SAT)cout << "yes" << endl;
    else cout << "no" << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 1208
final_rank: 4

code_snippet: #include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

bool check(string s){
  rep(i,s.size()) if( s[i] == '&' ) s[i] = ' ';
  stringstream ss;
  ss << s;
  vector<string> vec;
  while( !( ss >> s ).fail() ) vec.push_back(s);
  set<char> S;
  rep(i,vec.size()) REP(j,i+1,vec.size()){
    char a = ( (vec[i].size() == 2 ) ? vec[i][1] : vec[i][0] );
    char b = ( (vec[j].size() == 2 ) ? vec[j][1] : vec[j][0] );
    if( a == b ) {
      if( min(vec[i].size(),vec[j].size()) == 1 && max(vec[i].size(),vec[j].size()) == 2 ) return false;
    }
  }
  return true;
}

bool compute(string s){
  rep(i,s.size()) if( s[i] == '|' || s[i] == '(' || s[i] == ')' ) s[i] = ' ';
  stringstream ss;
  ss << s;
  vector<string> vec;
  while( !( ss >> s ).fail() ) vec.push_back(s);
  rep(i,vec.size()) if( check(vec[i]) ) return true;
  return false;
}

int main(){
  string s;
  while( cin >> s, s != "#" ){
    puts(compute(s)?"yes":"no");
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 1204
final_rank: 8

code_snippet: #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
bool check(string s){
    int nf = 0;
//    cout << s << endl;
    map<char, int> table;
    rep(i, s.size()){
        if(s[i] == '~') nf = 1;
        if((s[i] >= 'a' && s[i] <= 'z')||(s[i] >= 'A' && s[i] <= 'Z')){
            if(table.find(s[i]) != table.end() && table[s[i]] != nf) return false;
            table[s[i]] = nf;
            nf = 0;
        }
    }
    return true;
}

int main() {
    string s;
    while(cin >> s, s != "#"){
        int bf = -1;
        bool ans = false;
        rep(i, s.size()){
            if(s[i] == '|'){
                ans |= check(s.substr(bf+2, i-bf-3));
                bf = i;
            }
        }
        ans |= check(s.substr(bf+2, s.size()-bf-3));
        cout << (ans?"yes":"no") << endl;        
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1188
final_rank: 2