Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

谁能告诉我怎么错了。。我过了样例了,真心求解答

Posted by 15331154 at 2016-07-07 01:57:31 on Problem 1021
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<vector>
using namespace std;
int main() {
	int num;
	int m[105][105];
	multiset<int> v1, v2;
	memset(m, 0, sizeof m);
	cin >> num;
	while (num--) {
		int w, h, t;
		cin >> w >> h >> t;
		multimap<int, int> M;

		int n = t;
		while (t--) {
			int x, y;
			cin >> x >> y;
			M.insert(make_pair(x, y));
			m[x][y] = 1;
		}
		
		for (std::multimap<int, int>::iterator it = M.begin(); it != M.end(); it++) {
			int x_2 = it->first;
			int y_2 = it->second;
			int x, y;
			int count = 0;
			for (x = x_2, y = y_2; m[x][y] && y < h; y++, count++);
			for (x = x_2, y = y_2; m[x][y] && y >= 0; y--, count++);
			for (x = x_2, y = y_2; m[x][y] && x < w; x++, count++);
			for (x = x_2, y = y_2; m[x][y] && x >= 0; x--, count++);
			v1.insert(count);
		}

		M.clear();
		memset(m, 0, sizeof m);
		while (n--) {
			int x, y;
			cin >> x >> y;
			M.insert(make_pair(x, y));
			m[x][y] = 1;
		}

		for (std::multimap<int, int>::iterator it = M.begin(); it != M.end(); it++) {
			int x_2 = it->first;
			int y_2 = it->second;
			int x, y;
			int count = 0;
			for (x = x_2, y = y_2; m[x][y] && y < h; y++, count++);
			for (x = x_2, y = y_2; m[x][y] && y >= 0; y--, count++);
			for (x = x_2, y = y_2; m[x][y] && x < w; x++, count++);
			for (x = x_2, y = y_2; m[x][y] && x >= 0; x--, count++);
			v2.insert(count);
		}
 
		if (v1 == v2) cout << "YES" << endl;
		else  cout << "NO" << endl;
		v1.clear();
		v2.clear();
	}

	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator