Beispiel #1
0
int main() {
	int cs;
	for(int i = 0; i < 9; ++i) {
		int msk = 0;
		for(int j = 0; j < 3; ++j) {
			int id = bm.getId(make_pair(tri[i][j][0], tri[i][j][1]));
			msk = (msk | (1 << id));
		}
		tri_msk.push_back(msk);
	}
	memset(win, -1, sizeof(win));
	scanf("%d", &cs);
	//cs = 1;
	while(cs--) {
		int n;
		scanf("%d", &n);
		for(int i = 0; i < n; ++i) {
			int m;
			scanf("%d", &m);
			int msk = 0;
			int turn = 1;
			int tria = 0, trib = 0;
			for(int j = 0; j < m; ++j) {
				int u, v;
				scanf("%d%d", &u, &v);
				int id = bm.getId(make_pair(u, v));
				bool occur = false;
				for(int k = 0; k < tri_msk.size(); ++k) {
					if((tri_msk[k] & (1 << id)) && (tri_msk[k] & (msk | (1 << id))) == tri_msk[k]) {
						if(turn)
							++tria;
						else
							++trib;
						occur = true;
					}
				}
				if(!occur)
					turn = !turn;
				msk = (msk | (1 << id));
			}
			int res;
			if(turn) {
				//printf("aturn:%d %d %d\n", msk, tria, trib);
				res = solve(msk, tria, trib);
			}
			else {
				//printf("bturn:%d %d %d\n", msk, trib, tria);
				res = solve(msk, trib, tria);
				res = !res;
			}
			printf("Game %d: %c wins.\n", i + 1, (res ? 'A' : 'B'));
		}
		if(cs != 0)
			putchar('\n');
	}
	return 0;
}
Beispiel #2
0
void write_batch_file(const string& batch_file_name, bimap<string, string>& hash_file) {
    ofstream batch(batch_file_name, ios_base::app);

    for (recursive_directory_iterator i(initial_path()), end; i != end; ++i) {
        const string f = i->path().string().substr(initial_path().string().size() + 1);

        if (!is_regular_file(i->path()) || f == batch_file_name || hash_file.right.find(f) != hash_file.right.end()) {
            continue;
        }

        const string h = hexify(sha256(read_file(f)));

        const bimap<string, string>::left_const_iterator j = hash_file.left.find(h);

        if (j == hash_file.left.end()) {
            hash_file.insert(bimap<string, string>::value_type(h, f));

            batch << "@REM " << h << " " << f << endl;
        } else {
            cout << "del \"" << f << "\"" << endl;

            batch << "@copy \"" << j->second << "\" \"" << f << "\"" << endl;
        }
    }

    batch << "@REM **********" << endl;
}
Beispiel #3
0
	//functions
	InputLayer(const string& name, size_t numSeqDims, size_t size, const bimap<int, string>& labels):
		Layer(name, numSeqDims, 0, size)
	{
		const bimap<int, string>* labelPtr = labels.empty() ? 0 : &labels;
		display(this->outputActivations, "activations", labelPtr);
		display(this->outputErrors, "errors", labelPtr);
	}
Beispiel #4
0
void read_batch_file(const string& batch_file_name, bimap<string, string>& hash_file) {
    ifstream batch(batch_file_name);

    const regex r("@REM ([[:xdigit:]]{64}) (.+)");

    for (string s; getline(batch, s); ) {
        smatch m;

        if (regex_match(s, m, r)) {
            hash_file.insert(bimap<string, string>::value_type(m[1], m[2]));
        }
    }
}
	void emplace(WordId id, std::wstring word){	id_word_.insert(bimap::value_type(id, std::make_shared<std::wstring>(word))); }
	void emplace(WordId id, C_WStrPtr word){ id_word_.insert(bimap::value_type(id, word)); }
	uint size() const{ return id_word_.size(); }
	bool hasElement(WordId id) const{ return id < id_word_.size(); }
	void emplace(WordId id, std::wstring word){
		auto wp = std::make_shared<std::wstring>(word);
		id_word_.push_back(wp);
		word_id_.emplace(wp, id);
	}
	void emplace(WordId id, C_WStrPtr word){
		id_word_.push_back(word);
		word_id_.emplace(word, id);
	}