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

poj的编译器我不想吐槽了

Posted by KatrineYang at 2016-09-12 08:28:14 on Problem 1314
对vector<string>用sort,竟然不能用默认的比较
好吧那我手写个compare吧
写成
bool compare(const string &s1, const string &s2){
	return s1 < s2;
}
,竟然还不行,非逼我改成这样:
bool compare(const string &s1, const string &s2){
	return strcmp(s1.c_str(), s2.c_str()) == -1;
}
你说这编译器是不是个智障啊!!!
附代妈
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;

bool compare(const string &s1, const string &s2){
	return strcmp(s1.c_str(), s2.c_str()) == -1;
}

int main() {
	int cnt = 0;
	int N;
	while(1){
		cin >> N;
		if(N == 0) break;
		cnt++;
		int has[60][60] = {0};
		char id[26];
		int x[26], y[26];
		for(int i = 0; i < N; i++){
			cin >> id[i] >> x[i] >> y[i];
			has[x[i]][y[i]] = id[i];
		}
		vector<string> vs;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(i == j) continue;
				if(x[i] >= x[j] || y[i] <= y[j]) continue;
				int id1 = id[i], id2 = has[x[j]][y[i]], id3 = id[j], id4 = has[x[i]][y[j]];
				if(id2 != 0 && id4 != 0){
					string temp = "";
					temp += (char) id1;
					temp += (char) id2;
					temp += (char) id3;
					temp += (char) id4;
					vs.push_back(temp);
				}
			}
		}
		sort(vs.begin(), vs.end(), compare);
		int sz = vs.size();
		printf("Point set %d:", cnt);
		if(!sz){
			printf(" No rectangles");
		}
		else{
			for(int i = 0; i < sz; i++){
				if(i%10 == 0) printf("\n");
				printf(" %s", vs[i].c_str());
			}
		}
		printf("\n");
	}
	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