夢追い人

"It takes a dreamer to make a dream come true."―Vincent Willem van Gogh

PKUを通せば…

PKUをあと一問通せば64問、つまり8*8問。
TopCoderのレートは888
AOJの解いた問題数も88問
さぁ、あと一問PKU通さなきゃいけないんだけどな…

SRM516 Mid 復讐

コードを少し付け足すだけで復讐完了w

class NetworkXOneTimePad {
public:
	string sxor(string a, string b) {
		string res = "";
		for (int i=0; i<a.length(); i++) {
			if (a[i] == b[i]) res += '0';
			else res += '1';
		}
		return res;
	}
  int crack( vector <string> plaintexts, vector <string> ciphertexts ) {
		set<string> keys;
		for (int i=0; i<plaintexts.size(); i++) {
			for (int j=0; j<ciphertexts.size(); j++) {
				string key = sxor(plaintexts[i], ciphertexts[j]);
				bool flag = true;
				for (int k=0; k<ciphertexts.size(); k++) {
					if (find(plaintexts.begin(), plaintexts.end(), sxor(ciphertexts[k], key))==plaintexts.end()) {
						flag = false;
						break;
					}
				}
				if (flag) keys.insert(key);
			}
		}
		return keys.size();
	}
};

AOJ 0059

判定するだけの簡単な問題。
でも考えるのめんどくさかったからTopCoderのチュートリアル見て判定文引用したw

#include <cstdio>
#include <iostream>
using namespace std;

double max(double a, double b) {
	if (a > b) return a;
	return b;
}
double min(double a, double b) {
	if (a < b) return a;
	return b;
}

int main() {
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while (cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2) {
		if (max(xa1, xb1)<=min(xa2, xb2)&&max(ya1, yb1)<=min(ya2, yb2)) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
}

AOJ 0061

こういう系の問題苦手だったんだけどね。
ようやくできた。mapとvector組み合わせて。

#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef map<int, int> INTMAP;
int search(vector<int> vec, int n) {
	for (int i=0; i<vec.size(); i++) {
		if (vec[i] == n) return i+1;
	}
	return 0;
}
int main() {
	INTMAP nums;
	vector<int> pts;
	int num, pt;
	while (scanf("%d%*c%d", &num, &pt)) {
		if (num == 0 && pt == 0) break;
		nums.insert(INTMAP::value_type(num, pt));
		if (search(pts,pt) == 0) pts.push_back(pt);
	}
	sort(pts.begin(), pts.end());
	reverse(pts.begin(), pts.end());
	while (scanf("%d", &num) != EOF) {
		printf("%d\n", search(pts, nums[num]));
	}
}

8まみれにしたい(あとがき)

そもそもあとがきいらないけどねw
PKUあと一問がどうしても・・・・
2407とかGCDでTLE、素数でMLE、じゃあどんな解き方が正しいんだってね(;・∀・)

ういっっす。たぶん明日にはいってるでしょう。