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

I don't understand why WA / TLE

Posted by parenti at 2010-01-14 08:11:32 and last updated at 2010-01-14 08:23:48
//this code is funny, it gets WA on C++, but gets TLE on G++, can anyone explain me about this wierd (because of the difference) results?
// this is my code, if you find any flawed case on it, please e-mail me
// parenti.9@gmail.com I appreciate any help whatsoever :)
//p.s: the question is 1002 - 487-3279 (link: http://acm.pku.edu.cn/JudgeOnline/problem?id=1002 )

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <climits>
#include <cctype>
#include <cmath>
#include <cassert>
#include <ctime>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define eps 1e-10
#define inf 0x3f3f3f3f

#define console cout
#define dbg(x) console << #x << " == " << x << endl
#define print(x) console << x << endl

map<int, int> mp;
vector<string> vs;
char ct[1050];
int lines;
void process(){
	int nn;
	for(int i = 0; i < lines; i++){
		nn = 0;
		for(unsigned j = 0; j < vs[i].size(); j++){
			if(vs[i][j] != '-'){
				nn *= 10;
				if(vs[i][j] >= '0' && vs[i][j] <= '9'){
					nn += vs[i][j]-'0';
				}else{
					
					if(vs[i][j] > 'Q'){
						nn += (vs[i][j]-'A'-1)/3 + 2;
					}else{
						nn += (vs[i][j]-'A')/3 + 2;
					}
				}
			}
		}
		//cout << ct << endl;
		if(mp.count(nn) == 0)mp[nn] = 1;
		else mp[nn]++;
	}
	//dbg(mp.size());
	//for(map<int,int>::iterator it = mp.begin(); it != mp.end(); it++) cout << it->first << " " << it->second << endl;
	for(map<int,int>::iterator it = mp.begin(); it != mp.end(); it++)if(it->second > 1){
		int num = it->first;
		printf("%03d-%04d %d\n", num/10000, num%10000, it->second);
	}
}
// BEGIN CUT HERE
int main() {
	mp.clear();
	scanf("%d", &lines);
	vs.clear();
	for(int i = 0; i < lines; i++){
		scanf("%s", ct);
		vs.push_back(string(ct));
	}
	process();
	return 0;
}
// END CUT HERE 

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