UVa10865 - Brownie Points

本文深入探讨了游戏开发领域的关键技术,包括游戏引擎、编程语言、硬件优化等,并重点阐述了AI音视频处理的应用场景和实现方法,如语义识别、物体检测、语音变声等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Problem A: Brownie Points I

Stan and Ollie play the game of Odd Brownie Points. Some browniepoints are located in the plane, at integer coordinates. Stan playsfirst and places a vertical line in the plane. The line must gothrough a brownie point and may cross many (with the samex-coordinate). Then Ollie places a horizontal line that must crossa brownie point already crossed by the vertical line.

Those lines divide the plane into four quadrants. The quadrantcontaining points with arbitrarily large positive coordinates is thetop-right quadrant.

The players score according to the number of brownie points in thequadrants. If a brownie point is crossed by a line, it doesn'tcount. Stan gets a point for each (uncrossed) brownie point in thetop-right and bottom-left quadrants. Ollie gets a point for each(uncrossed) brownie point in the top-left and bottom-right quadrants.

Your task is to compute the scores of Stan and Ollie given the pointthrough which they draw their lines.

Input contains a number of test cases. The data of each test caseappear on a sequence of input lines. The first line of each test casecontains a positive odd integer1 < n < 200000 which is the numberof brownie points. Each of the following n lines containstwo integers, the horizontal (x) and vertical (y)coordinates of a brownie point. No two brownie points occupy the sameplace. The input ends with a line containing 0 (instead of then of a test).

For each test case of input, print a line with two numbers separatedby a single space. The first number is Stan's score, the second is the score of Ollie when their lines cross the point whose coordinatesare given at the center of the input sequence of points for this case.

Sample input

11
3 2
3 3
3 4
3 6
2 -2
1 -3
0 0
-3 -3
-3 -2
-3 -4
3 -7
0

Output for sample input

6 3
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class Main 
{
	public static final boolean DEBUG = false;
	public StreamTokenizer tokenizer;
	public BufferedReader cin;
	public PrintWriter cout;
	public int n;
	public Point[] point;
	
	static class Point
	{
		int x, y;
	}
	
	public void init() 
	{
		try {
			if (DEBUG) {
				cin = new BufferedReader(new InputStreamReader(
						new FileInputStream("d:\\OJ\\uva_in.txt")));
			} else {
				cin = new BufferedReader(new InputStreamReader(System.in));
			}
			cout = new PrintWriter(new OutputStreamWriter(System.out));
			tokenizer = new StreamTokenizer(cin);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String next()
	{
		try {
			tokenizer.nextToken();
			if (tokenizer.ttype == StreamTokenizer.TT_EOF) return null;
			else if (tokenizer.ttype == StreamTokenizer.TT_NUMBER) return String.valueOf((int)tokenizer.nval);
			else if (tokenizer.ttype == StreamTokenizer.TT_WORD) return tokenizer.sval;
			else return null;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public boolean input() 
	{
		n = Integer.parseInt(next());
		
		if (n == 0) return false;
		
		point = new Point[n];
		
		for (int i = 0; i < n; i++) {
			point[i] = new Point();
			point[i].x = Integer.parseInt(next());
			point[i].y = Integer.parseInt(next());
		}
		return true;
	}

	
	public void solve() 
	{
		int x = point[n / 2].x, y = point[n / 2].y;
		
		int s = 0, o = 0;
		
		for (int i = 0; i < n; i++) {
			if ((point[i].x > x && point[i].y > y) || (point[i].x < x && point[i].y < y)) s++;
			
			if ((point[i].x < x && point[i].y > y) || (point[i].x > x && point[i].y < y)) o++;
		}
		
		cout.println(s + " " + o);
		cout.flush();
	}

	public static void main(String[] args) 
	{
		Main solver = new Main();
		solver.init();
		
		while (solver.input()) {
			solver.solve();
		}
	}
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值