10865 - Brownie Points

All about problems in Volume 108. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
pipo
New poster
Posts: 47
Joined: Tue May 11, 2004 6:43 pm
Location: Republic of Korea

10865 - Brownie Points

Post by pipo » Wed Jun 15, 2005 3:18 am

Hi..

In my thought, I have solved this problem exactly...

But... I got Wrong Answer... why ???

The algorithm is following....

Let's set cx, cy which are given at the center of the input sequence of points for this case...

For All of points(x, y),
if ( cx - x ) * ( cy - y ) == 0 then no count;
else if that is large than 0, then increase score of Stan..
else increase score of Ollie...

and then, just print socre of Stan and Ollie...

why wrong answer ? help me...

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Wed Jun 15, 2005 3:52 am

There can be an overflow in (cx - x) * (cy - y). Use long long's or multiply just the signs of the operands.

pipo
New poster
Posts: 47
Joined: Tue May 11, 2004 6:43 pm
Location: Republic of Korea

Post by pipo » Wed Jun 15, 2005 5:21 am

Thanks a lot... mf..

Due to you, I got AC...

I didn't think about an overflow...

that's a trick for me..

Joarder
New poster
Posts: 3
Joined: Mon Nov 28, 2011 11:26 pm

Getting WA in 10865 - Brownie Points

Post by Joarder » Sat Aug 24, 2013 12:51 pm

Why my code getting WA...??? :roll: :roll: :roll:
Plz.... Someone Cheak it...
or Give me some test cases...
here is my code....

Code: Select all

/*
 * File: 10865 - Brownie Points I.cpp
 * Tag: 
 * http://uva.onlinejudge.org/external/108/10865.html


 * Runtime: WA
 * Author: Shoshi
 * Created on August , 2011, : M
 */

#pragma warning (disable : 4786)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define pi acos(-1.0)
#define N 1000000
#define LL long long

using namespace std;

typedef struct node {
	int r,c;
}node;

int main() {
	//freopen ("10865 - Brownie Points I_in.txt", "r", stdin);
	int t,a,b,n,i,s,o;
	node tmn;
	vector<node>v;
	LL m;
	while(cin>>t) 
	{
		if(t == 0)
			break;
		n=t;
		v.clear();
		while(t--) 
		{
			cin>>a>>b;
			tmn.r=a;
			tmn.c=b;
			v.push_back(tmn);
		}
		a=v[n/2].r;
		b=v[n/2].c;
		s=o=0;
		
		for(i=0;i<n;i++)
		{
			m = (a - v[i].r) * (b - v[i].c);
			if(m > 0)
				s++;
			else if(m < 0)
				o++;
		}
		cout<<s<<" "<<o<<endl;
	}
	return 0;
}


brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Getting WA in 10865 - Brownie Points

Post by brianfry713 » Tue Aug 27, 2013 3:20 am

Use long long instead of int.
Check input and AC output for thousands of problems on uDebug!

anacharsis
Learning poster
Posts: 69
Joined: Mon Feb 09, 2015 1:56 am

Re: 10865 - Brownie Points

Post by anacharsis » Sat May 28, 2016 10:59 pm

What in the problem statement allows us to assume that the lines are drawn through the middle point of the input sequence?

Post Reply

Return to “Volume 108 (10800-10899)”