(SPOJ) 3244 - Divisão da Nlogônia - Solução
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
static int leitor(BufferedReader br) throws NumberFormatException, IOException {
int n;
int resp = 0;
int sinal = 1;
while (true) {
n = br.read();
if (n >= '0' && n <= '9') break;
if (n == '-') sinal = -1;
if (n == '+') sinal = 1;
}
while (true) {
resp = resp*10 + n-'0';
n = br.read();
if (n < '0' || n > '9') break;
}
return resp*sinal;
}
void processa() throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int qteConsultas;
while((qteConsultas = leitor(br)) != 0) {
int meioX = leitor(br);
int meioY = leitor(br);
for (int i = 0; i < qteConsultas; i++) {
int x = leitor(br);
int y = leitor(br);
if (x == meioX || y == meioY) {
bw.write("divisa");
}
else if (x < meioX) {
if (y < meioY) {
bw.write("SO");
}
else {
bw.write("NO");
}
}
else if (x > meioX) {
if (y > meioY) {
bw.write("NE");
}
else {
bw.write("SE");
}
}
bw.write("\n");
}
bw.flush();
}
bw.close();
return;
}
}
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
static int leitor(BufferedReader br) throws NumberFormatException, IOException {
int n;
int resp = 0;
int sinal = 1;
while (true) {
n = br.read();
if (n >= '0' && n <= '9') break;
if (n == '-') sinal = -1;
if (n == '+') sinal = 1;
}
while (true) {
resp = resp*10 + n-'0';
n = br.read();
if (n < '0' || n > '9') break;
}
return resp*sinal;
}
void processa() throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int qteConsultas;
while((qteConsultas = leitor(br)) != 0) {
int meioX = leitor(br);
int meioY = leitor(br);
for (int i = 0; i < qteConsultas; i++) {
int x = leitor(br);
int y = leitor(br);
if (x == meioX || y == meioY) {
bw.write("divisa");
}
else if (x < meioX) {
if (y < meioY) {
bw.write("SO");
}
else {
bw.write("NO");
}
}
else if (x > meioX) {
if (y > meioY) {
bw.write("NE");
}
else {
bw.write("SE");
}
}
bw.write("\n");
}
bw.flush();
}
bw.close();
return;
}
}
Comments
Post a Comment