buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
def sol(a1,b1,a2,b2,a3,b3):
return (a3-a2)*b1-(b3-b2)*a1+a2*b3-a3*b2
while True:
try:
x1,y1,x2,y2,x3,y3,x4,y4=list(map(float,input().split()))
if sol(x1,y1,x2,y2,x4,y4)*sol(x3,y3,x2,y2,x4,y4)<0 and sol(x4,y4,x1,y1,x3,y3)*sol(x2,y2,x1,y1,x3,y3)<0:
print('YES')
else:
print('NO')
except:
break
|
def sol(a1,b1,a2,b2,a3,b3):
return (a3-a2)*b1-(b3-b2)*a1+a2*b3-a3*b2
while True:
try:
x1,y1,x2,y2,x3,y3,x4,y4=list(map(float,input().split(',')))
if sol(x1,y1,x2,y2,x4,y4)*sol(x3,y3,x2,y2,x4,y4)<0 and sol(x4,y4,x1,y1,x3,y3)*sol(x2,y2,x1,y1,x3,y3)<0:
print('YES')
else:
print('NO')
except:
break
|
[["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 655]]
| 5
| 158
| 3
|
import sys
for line in sys.stdin():
p = list(map(float, line.split(',')))
v = [p[i] - p[(i + 2) % 8] for i in range(8)]
ip = [v[j] * v[(j + 3) % 8] - v[j + 1] * v[(j + 2) % 8] > 0 for j in range(0,8,2)]
if sum(ip) == 0 or sum(ip) == 4:
print('YES')
else:
print('NO')
|
import sys
for line in sys.stdin:
try:
p = list(map(float, line.split(',')))
except:
break
v = [p[i] - p[(i + 2) % 8] for i in range(8)]
ip = [v[j] * v[(j + 3) % 8] - v[j + 1] * v[(j + 2) % 8] > 0 for j in range(0,8,2)]
if sum(ip) == 0 or sum(ip) == 4:
print('YES')
else:
print('NO')
|
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25], ["+", 0, 656, 0, 7, 8, 196, 0, 246, 0, 247], ["+", 0, 656, 0, 7, 8, 196, 0, 246, 0, 102], ["+", 0, 7, 8, 196, 0, 246, 0, 671, 0, 672], ["+", 0, 7, 8, 196, 0, 246, 0, 671, 0, 102], ["+", 0, 246, 0, 671, 0, 196, 0, 93, 0, 94]]
| 5
| 134
| 7
|
import java.util.*;
public class Main {
void doIt() {
Scanner stdIn = new Scanner(System.in);
while (stdIn.hasNext()) {
int[] input = new int[8];
for (int r = 0; r < 8; r++) {
input[r] = stdIn.nextInt();
}
int count = 0;
ArrayList<Integer> temp = new ArrayList<Integer>();
for (int r = 0; r < 8; r++) {
if (input[r] != 0) {
count++;
temp.add(input[r]);
}
}
switch (count) {
case 1:
System.out.println("C");
break;
case 2:
if (temp.get(0) - temp.get(1) == 0) {
System.out.println("A");
} else if (temp.get(0) > temp.get(1)) {
System.out.println("E");
} else if (temp.get(0) < temp.get(1)) {
System.out.println("G");
}
break;
case 3:
if (temp.get(0) > temp.get(2)) {
System.out.println("D");
} else if (temp.get(0) < temp.get(2)) {
System.out.println("F");
}
break;
case 4:
System.out.println("B");
break;
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Main().doIt();
}
}
|
import java.util.*;
public class Main {
void doIt() {
Scanner stdIn = new Scanner(System.in);
while (stdIn.hasNext()) {
int[] input = new int[8];
for (int r = 0; r < 8; r++) {
input[r] = stdIn.nextInt();
}
int count = 0;
ArrayList<Integer> temp = new ArrayList<Integer>();
for (int r = 0; r < 8; r++) {
if (input[r] != 0) {
count++;
temp.add(input[r]);
}
}
switch (count) {
case 1:
System.out.println("C");
break;
case 2:
if (temp.get(0) - temp.get(1) == 0) {
System.out.println("A");
} else if (temp.get(0) > temp.get(1)) {
System.out.println("E");
} else if (temp.get(0) < temp.get(1)) {
System.out.println("G");
}
break;
case 3:
if (temp.get(0) < temp.get(2)) {
System.out.println("D");
} else if (temp.get(0) > temp.get(2)) {
System.out.println("F");
}
break;
case 4:
System.out.println("B");
break;
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Main().doIt();
}
}
|
[["-", 0, 520, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 0, 520, 0, 57, 15, 15, 0, 16, 17, 18], ["-", 0, 57, 75, 57, 15, 15, 0, 16, 17, 18], ["+", 0, 57, 75, 57, 15, 15, 0, 16, 17, 47]]
| 3
| 356
| 4
|
import java.util.*;
public class Main {
private static final Scanner scan = new Scanner(System.in);
static String A = "1100000011";
static String B = "10000000100000001";
static String C = "1111";
static String D = "1000000110000001";
static String E = "11000000011";
static String F = "100000001100000001";
static String G = "110000011";
static String[] blocks = {A, B, C, D, E, F, G};
static String[] dic = {"A", "B", "C", "D", "E", "F", "G"};
public static void main(String[] args) {
while (scan.hasNext()) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 8; i++) {
sb.append(scan.next());
}
System.out.printf("%s\n", dic[solve(sb.toString())]);
}
}
public static int solve(String str) {
for (int i = 0; i < 8 * 8; i++) {
for (int j = 0; j < 7; j++) {
if (8 * 8 < i + blocks[j].length()) {
return -1;
}
String s = str.substring(i, i + blocks[j].length());
if (s.equals(blocks[j])) {
return j;
}
}
}
return -1;
}
}
|
import java.util.*;
public class Main {
private static final Scanner scan = new Scanner(System.in);
static String A = "1100000011";
static String B = "10000000100000001";
static String C = "1111";
static String D = "1000000110000001";
static String E = "11000000011";
static String F = "100000001100000001";
static String G = "110000011";
static String[] blocks = {A, B, C, D, E, F, G};
static String[] dic = {"A", "B", "C", "D", "E", "F", "G"};
public static void main(String[] args) {
while (scan.hasNext()) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 8; i++) {
sb.append(scan.next());
}
System.out.printf("%s\n", dic[solve(sb.toString())]);
}
}
public static int solve(String str) {
for (int i = 0; i < 8 * 8; i++) {
for (int j = 0; j < 7; j++) {
if (8 * 8 < i + blocks[j].length()) {
continue;
}
String s = str.substring(i, i + blocks[j].length());
if (s.equals(blocks[j])) {
return j;
}
}
}
return -1;
}
}
|
[["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 0, 57, 64, 196, 0, 37, 0, 91, 17, 33], ["-", 0, 57, 64, 196, 0, 37, 0, 91, 439, 499], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
| 3
| 330
| 4
|
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
private static Map<Integer, String> map = new HashMap<Integer, String>();
static {
map.put(77, "A");
map.put(16843009, "B");
map.put(15, "C");
map.put(33153, "D");
map.put(1539, "E");
map.put(131841, "F");
map.put(387, "G");
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in).useRadix(2);
int i = 0;
while (in.hasNext()) {
i <<= 8;
i |= in.nextInt();
if (Integer.bitCount(i) == 4) {
i >>= Integer.numberOfTrailingZeros(i);
System.out.println(map.get(i));
i = 0;
}
}
}
}
|
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
private static Map<Integer, String> map = new HashMap<Integer, String>();
static {
map.put(771, "A");
map.put(16843009, "B");
map.put(15, "C");
map.put(33153, "D");
map.put(1539, "E");
map.put(131841, "F");
map.put(387, "G");
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in).useRadix(2);
int i = 0;
while (in.hasNext()) {
i <<= 8;
i |= in.nextInt();
if (Integer.bitCount(i) == 4) {
i >>>= Integer.numberOfTrailingZeros(i);
System.out.println(map.get(i));
i = 0;
}
}
}
}
|
[["-", 0, 196, 0, 1, 0, 492, 3, 4, 0, 499], ["+", 0, 196, 0, 1, 0, 492, 3, 4, 0, 499], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 17, 176], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 17, 521]]
| 3
| 221
| 4
|
import java.util.Scanner;
public class Main {
public static void main(String aeg[]) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
char b[][] = new char[8][8];
for (int i = 0; i < 8; i++)
b[i] = in.next().toCharArray();
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (j < 7 && b[i][j] == '1' && b[i][j + 1] == '1')
if (i < 7 && b[i + 1][j] == '1' && b[i + 1][j + 1] == '1')
System.out.println("A");
if (i < 5 && b[i][j] == '1')
if (b[i + 1][j] == '1')
if (b[i + 2][j] == '1')
if (b[i + 3][j] == '1')
System.out.println("B");
if (j < 5 && b[i][j] == '1' && b[i][j + 1] == '1' &&
b[i][j + 2] == '1' && b[i][j + 3] == '1')
System.out.println("C");
if (i < 6 && b[i][j] == '1' && b[i + 1][j] == '1')
if (j > 0 && b[i + 1][j - 1] == '1' && b[i + 2][j - 1] == '1')
System.out.println("D");
if (j < 6 && b[i][j] == '1' && b[i][j + 1] == '1')
if (i < 7 && b[i + 1][j + 1] == '1' && b[i + 1][j + 2] == '1')
System.out.println("E");
if (i < 6 && b[i][j] == '1' && b[i + 1][j] == '1')
if (j < 7 && b[i + 1][j + 1] == '1' && b[i + 2][j + 1] == '1')
System.out.println("F");
if (j < 7 && b[i][j] == '1' && b[i][j + 1] == '1')
if (j > 0 && b[i + 1][j - 1] == '1' && b[i + 1][j] == '1')
System.out.println("G");
}
}
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String aeg[]) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
char b[][] = new char[8][8];
for (int i = 0; i < 8; i++)
b[i] = in.next().toCharArray();
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (j < 7 && b[i][j] == '1' && b[i][j + 1] == '1')
if (i < 7 && b[i + 1][j] == '1' && b[i + 1][j + 1] == '1')
System.out.println("A");
if (i < 5 && b[i][j] == '1')
if (b[i + 1][j] == '1')
if (b[i + 2][j] == '1')
if (b[i + 3][j] == '1')
System.out.println("B");
if (j < 5 && b[i][j] == '1' && b[i][j + 1] == '1' &&
b[i][j + 2] == '1' && b[i][j + 3] == '1')
System.out.println("C");
if (i < 6 && b[i][j] == '1' && b[i + 1][j] == '1')
if (j > 0 && b[i + 1][j - 1] == '1' && b[i + 2][j - 1] == '1')
System.out.println("D");
if (j < 6 && b[i][j] == '1' && b[i][j + 1] == '1')
if (i < 7 && b[i + 1][j + 1] == '1' && b[i + 1][j + 2] == '1')
System.out.println("E");
if (i < 6 && b[i][j] == '1' && b[i + 1][j] == '1')
if (j < 7 && b[i + 1][j + 1] == '1' && b[i + 2][j + 1] == '1')
System.out.println("F");
if (j < 7 && b[i][j] == '1' && b[i][j + 1] == '1')
if (j > 0 && i < 7 && b[i + 1][j - 1] == '1' && b[i + 1][j] == '1')
System.out.println("G");
}
}
}
}
}
|
[["+", 0, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 17, 18], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 12, 499], ["+", 64, 57, 15, 15, 0, 16, 31, 16, 17, 98]]
| 3
| 615
| 4
|
import java.awt.geom.*;
import java.io.*;
import java.util.*;
public class Main {
int[][] data;
int[][][] p = {
{{0, 1, 0, 1}, {0, 0, 1, 1}},
{{0, 0, 0, 0}, {0, 1, 2, 3}},
{{0, 1, 2, 3}, {0, 0, 0, 0}
},
{{0, 0, -1, -1}, {0, 1, 1, 2}
},
{{0, 1, 1, 2}, {0, 0, 1, 1}
},
{{0, 0, 1, 1}, {0, 1, 1, 2}
},
{{0, 0, 1, -1}, {0, 1, 0, 1}
},
};
private void doit() {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
data = new int[8][8];
int n = 8;
for (int i = 0; i < n; i++) {
String input = sc.next();
for (int j = 0; j < n; j++) {
data[i][j] = input.charAt(j) - '0';
}
}
int ind = -1;
EXIT:
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (data[i][j] == 1) {
for (int k = 0; k < p.length; k++) {
boolean res = isOK(i, j, k);
if (res) {
ind = k;
break EXIT;
}
}
}
}
}
char ans = (char)(ind + 'A');
System.out.println(ans);
}
}
private boolean isOK(int y, int x, int k) {
for (int i = 0; i < 4; i++) {
int xx = x + p[k][0][i];
int yy = y + p[k][1][i];
if (0 <= xx && xx < 8 && 0 <= yy && yy < 8) {
} else {
continue;
}
if (data[yy][xx] != 1) {
return false;
}
}
return true;
}
public static void main(String[] args) { new Main().doit(); }
}
|
import java.awt.geom.*;
import java.io.*;
import java.util.*;
public class Main {
int[][] data;
int[][][] p = {
{{0, 1, 0, 1}, {0, 0, 1, 1}},
{{0, 0, 0, 0}, {0, 1, 2, 3}},
{{0, 1, 2, 3}, {0, 0, 0, 0}
},
{{0, 0, -1, -1}, {0, 1, 1, 2}
},
{{0, 1, 1, 2}, {0, 0, 1, 1}
},
{{0, 0, 1, 1}, {0, 1, 1, 2}
},
{{0, 0, 1, -1}, {0, 1, 0, 1}
},
};
private void doit() {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
data = new int[8][8];
int n = 8;
for (int i = 0; i < n; i++) {
String input = sc.next();
for (int j = 0; j < n; j++) {
data[i][j] = input.charAt(j) - '0';
}
}
int ind = -1;
EXIT:
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (data[i][j] == 1) {
for (int k = 0; k < p.length; k++) {
boolean res = isOK(i, j, k);
if (res) {
ind = k;
break EXIT;
}
}
}
}
}
char ans = (char)(ind + 'A');
System.out.println(ans);
}
}
private boolean isOK(int y, int x, int k) {
for (int i = 0; i < 4; i++) {
int xx = x + p[k][0][i];
int yy = y + p[k][1][i];
if (0 <= xx && xx < 8 && 0 <= yy && yy < 8) {
} else {
return false;
}
if (data[yy][xx] != 1) {
return false;
}
}
return true;
}
public static void main(String[] args) { new Main().doit(); }
}
|
[["-", 8, 196, 0, 57, 75, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 75, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 75, 196, 0, 37, 0, 147]]
| 3
| 553
| 3
|
import java.util.*;
public class Main {
private static int board[][] = new int[8][8];
public static void main(String[] args) {
// input
Scanner sc = new Scanner(System.in);
char[] c;
char ret;
int call_cnt = 0;
while (sc.hasNext()) {
call_cnt++;
for (int i = 0; i < 8; i++) {
c = sc.next().toCharArray();
for (int j = 0; j < 8; j++) {
board[i][j] = Character.digit(c[j], 10);
}
}
ret = 'N';
loop:
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (board[i][j] == 1) {
ret = check(i, j);
if (!(ret == 'N')) {
break loop;
}
}
}
}
System.out.println(ret);
}
}
private static char check(int i, int j) {
char ret = 'N';
if (check_A(i, j)) {
ret = 'A';
} else if (check_B(i, j)) {
ret = 'B';
} else if (check_C(i, j)) {
ret = 'C';
} else if (check_D(i, j)) {
ret = 'D';
} else if (check_E(i, j)) {
ret = 'E';
} else if (check_F(i, j)) {
ret = 'F';
} else if (check_G(i, j)) {
ret = 'G';
}
return ret;
}
private static boolean check_A(int i, int j) {
boolean ret = false;
if (i + 1 != 8 && j + 1 != 8) {
if (board[i][j + 1] == 1 && board[i + 1][j] == 1 &&
board[i + 1][j + 1] == 1) {
ret = true;
}
}
return ret;
}
private static boolean check_B(int i, int j) {
boolean ret = false;
if (i + 3 < 8) {
ret = true;
for (int k = 1; k < 4; k++) {
if (board[i + k][j] != 1) {
ret = false;
}
}
}
return ret;
}
private static boolean check_C(int i, int j) {
boolean ret = false;
if (j + 3 < 8) {
ret = true;
for (int k = 1; k < 4; k++) {
if (board[i][j + k] != 1) {
ret = false;
}
}
}
return ret;
}
private static boolean check_D(int i, int j) {
boolean ret = false;
if (i + 2 < 8 && j - 1 != -1) {
if (board[i + 1][j] == 1 && board[i + 1][j - 1] == 1 &&
board[i + 2][j - 1] == 1) {
ret = true;
}
}
return ret;
}
private static boolean check_E(int i, int j) {
boolean ret = false;
if (i + 1 != 8 && j + 2 < 8) {
if (board[i][j + 1] == 1 && board[i + 1][j + 1] == 1 &&
board[i + 1][j + 2] == 1) {
ret = true;
}
}
return ret;
}
private static boolean check_F(int i, int j) {
boolean ret = false;
if (i + 2 < 8 && j + 1 != 8) {
if (board[i + 1][j] == 1 && board[i + 1][j + 1] == 1 &&
board[i + 2][j + 1] == 1) {
ret = true;
}
}
return ret;
}
private static boolean check_G(int i, int j) {
boolean ret = false;
if (i + 1 != 8 && j + 1 != 8 && i - 1 != -1) {
if (board[i][j + 1] == 1 && board[i + 1][j] == 1 &&
board[i + 1][j - 1] == 1) {
ret = true;
}
}
return ret;
}
}
|
import java.util.*;
public class Main {
private static int board[][] = new int[8][8];
public static void main(String[] args) {
// input
Scanner sc = new Scanner(System.in);
char[] c;
char ret;
int call_cnt = 0;
while (sc.hasNext()) {
call_cnt++;
for (int i = 0; i < 8; i++) {
c = sc.next().toCharArray();
for (int j = 0; j < 8; j++) {
board[i][j] = Character.digit(c[j], 10);
}
}
ret = 'N';
loop:
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (board[i][j] == 1) {
ret = check(i, j);
if (!(ret == 'N')) {
break loop;
}
}
}
}
System.out.println(ret);
}
}
private static char check(int i, int j) {
char ret = 'N';
if (check_A(i, j)) {
ret = 'A';
} else if (check_B(i, j)) {
ret = 'B';
} else if (check_C(i, j)) {
ret = 'C';
} else if (check_D(i, j)) {
ret = 'D';
} else if (check_E(i, j)) {
ret = 'E';
} else if (check_F(i, j)) {
ret = 'F';
} else if (check_G(i, j)) {
ret = 'G';
}
return ret;
}
private static boolean check_A(int i, int j) {
boolean ret = false;
if (i + 1 != 8 && j + 1 != 8) {
if (board[i][j + 1] == 1 && board[i + 1][j] == 1 &&
board[i + 1][j + 1] == 1) {
ret = true;
}
}
return ret;
}
private static boolean check_B(int i, int j) {
boolean ret = false;
if (i + 3 < 8) {
ret = true;
for (int k = 1; k < 4; k++) {
if (board[i + k][j] != 1) {
ret = false;
}
}
}
return ret;
}
private static boolean check_C(int i, int j) {
boolean ret = false;
if (j + 3 < 8) {
ret = true;
for (int k = 1; k < 4; k++) {
if (board[i][j + k] != 1) {
ret = false;
}
}
}
return ret;
}
private static boolean check_D(int i, int j) {
boolean ret = false;
if (i + 2 < 8 && j - 1 != -1) {
if (board[i + 1][j] == 1 && board[i + 1][j - 1] == 1 &&
board[i + 2][j - 1] == 1) {
ret = true;
}
}
return ret;
}
private static boolean check_E(int i, int j) {
boolean ret = false;
if (i + 1 != 8 && j + 2 < 8) {
if (board[i][j + 1] == 1 && board[i + 1][j + 1] == 1 &&
board[i + 1][j + 2] == 1) {
ret = true;
}
}
return ret;
}
private static boolean check_F(int i, int j) {
boolean ret = false;
if (i + 2 < 8 && j + 1 != 8) {
if (board[i + 1][j] == 1 && board[i + 1][j + 1] == 1 &&
board[i + 2][j + 1] == 1) {
ret = true;
}
}
return ret;
}
private static boolean check_G(int i, int j) {
boolean ret = false;
if (i + 1 != 8 && j + 1 != 8 && j - 1 != -1) {
if (board[i][j + 1] == 1 && board[i + 1][j] == 1 &&
board[i + 1][j - 1] == 1) {
ret = true;
}
}
return ret;
}
}
|
[["-", 15, 15, 0, 16, 12, 16, 31, 16, 31, 22], ["+", 15, 15, 0, 16, 12, 16, 31, 16, 31, 22]]
| 3
| 931
| 2
|
#include <stdio.h>
#include <string.h>
int main() {
char d[8][10];
char s;
int x, y, p, i, j;
while (1) {
p = 0;
for (i = 0; i < 8; i++) {
if (scanf("%s", d[i]) == EOF)
break;
for (j = 0; j < 8; j++) {
if (p == 0 && d[i][j] == '1') {
p = 1;
x = j;
y = i;
}
}
}
if (p == 0)
break;
if (d[y][x + 3] == '1' && x + 3 < 8)
printf("C\n");
else if (d[y + 3][x] == '1' && y + 4 < 8)
printf("B\n");
else if (d[y + 2][x + 1] == '1' && y + 2 < 8 && x + 1 < 8)
printf("F\n");
else if (d[y + 2][x - 1] == '1' && y + 2 < 8 && x - 1 > -1)
printf("D\n");
else if (d[y + 1][x - 1] == '1' && y + 1 < 8 && x - 1 > -1)
printf("G\n");
else if (d[y + 1][x + 2] == '1' && y + 1 < 8 && x + 2 < 8)
printf("E\n");
else
printf("A\n");
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main() {
char d[8][10];
char s;
int x, y, p, i, j;
while (1) {
p = 0;
for (i = 0; i < 8; i++) {
if (scanf("%s", d[i]) == EOF)
break;
for (j = 0; j < 8; j++) {
if (p == 0 && d[i][j] == '1') {
p = 1;
x = j;
y = i;
}
}
}
if (p == 0)
break;
if (d[y][x + 3] == '1' && x + 3 < 8)
printf("C\n");
else if (d[y + 3][x] == '1' && y + 3 < 8)
printf("B\n");
else if (d[y + 2][x + 1] == '1' && y + 2 < 8 && x + 1 < 8)
printf("F\n");
else if (d[y + 2][x - 1] == '1' && y + 2 < 8 && x - 1 > -1)
printf("D\n");
else if (d[y + 1][x - 1] == '1' && y + 1 < 8 && x - 1 > -1)
printf("G\n");
else if (d[y + 1][x + 2] == '1' && y + 1 < 8 && x + 2 < 8)
printf("E\n");
else
printf("A\n");
}
return 0;
}
|
[["-", 15, 23, 0, 16, 12, 16, 31, 16, 12, 13], ["+", 15, 23, 0, 16, 12, 16, 31, 16, 12, 13]]
| 0
| 360
| 2
|
#include <stdio.h>
#include <string.h>
int main(void) {
char b[65];
char p[7][33] = {
"1100000011", "10000000100000001000000010000001",
"1111", "1000000110000001",
"11000000011", "100000001100000001",
"110000011",
};
char *bi;
int i, t = 0;
while (1) {
if (scanf("%s", b) == EOF) {
break;
}
for (i = 1; i < 8; i++) {
scanf("%s", b + i * 8);
}
bi = strchr(b, '1');
for (i = 0; i < 7; i++) {
if (memcmp(bi, p[i], strlen(p[i])) == 0) {
printf("%c\n", 'A' + i);
break;
}
}
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main(void) {
char b[65];
char p[7][33] = {
"1100000011", "1000000010000000100000001",
"1111", "1000000110000001",
"11000000011", "100000001100000001",
"110000011",
};
char *bi;
int i, t = 0;
while (1) {
if (scanf("%s", b) == EOF) {
break;
}
for (i = 1; i < 8; i++) {
scanf("%s", b + i * 8);
}
bi = strchr(b, '1');
for (i = 0; i < 7; i++) {
if (memcmp(bi, p[i], strlen(p[i])) == 0) {
printf("%c\n", 'A' + i);
break;
}
}
}
return 0;
}
|
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
| 0
| 188
| 2
|
#include <stdio.h>
int main(void) {
char a[8][8];
int i, j;
while (scanf("%s", a[0]) != EOF) {
for (i = 1; i < 8; i++) {
scanf("%s", a[i]);
}
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (a[i][j] == '1')
break;
}
if (a[i][j] == '1')
break;
}
if (i < 7 && j < 7 && a[i + 1][j] == '1' && a[i][j + 1] == '1' &&
a[i + 1][j + 1] == '1')
puts("A");
if (i < 5 && a[i + 1][j] == '1' && a[i + 2][j] == '1' && a[i + 3][j] == '1')
puts("B");
if (j < 5 && a[i][j + 1] == '1' && a[i][j + 2] == '1' && a[i][j + 3] == '1')
puts("C");
if (i < 6 && j > 0 && a[i + 1][j] == '1' && a[i + 1][j - 1] == '1' &&
a[i + 2][j - 1] == '1')
puts("D");
if (i < 7 && j < 6 && a[i][j + 1] == '1' && a[i + 1][j + 1] == '1' &&
a[i + 1][j + 2] == '1')
puts("E");
if (i < 6 && j < 7 && a[i + 1][j] == '1' && a[i + 1][j + 1] == '1' &&
a[i + 2][j + 1] == '1')
puts("F");
if (i < 7 && j < 7 && j > 0 && a[i][j + 1] == '1' && a[i + 1][j] == '1' &&
a[i + 1][j - 1] == '1')
puts("G");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
char a[9][9];
int i, j;
while (scanf("%s", a[0]) != EOF) {
for (i = 1; i < 8; i++) {
scanf("%s", a[i]);
}
// for(i=0;i<8;i++){
// for(j=0;j<8;j++){
// printf("%c",a[i][j]);
// if(j==7)puts("");
// }
//}
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (a[i][j] == '1')
break;
}
if (a[i][j] == '1')
break;
}
// printf("%d %d\n",i,j);
if (i < 7 && j < 7 && a[i + 1][j] == '1' && a[i][j + 1] == '1' &&
a[i + 1][j + 1] == '1')
puts("A");
if (i < 5 && a[i + 1][j] == '1' && a[i + 2][j] == '1' && a[i + 3][j] == '1')
puts("B");
if (j < 5 && a[i][j + 1] == '1' && a[i][j + 2] == '1' && a[i][j + 3] == '1')
puts("C");
if (i < 6 && j > 0 && a[i + 1][j] == '1' && a[i + 1][j - 1] == '1' &&
a[i + 2][j - 1] == '1')
puts("D");
if (i < 7 && j < 6 && a[i][j + 1] == '1' && a[i + 1][j + 1] == '1' &&
a[i + 1][j + 2] == '1')
puts("E");
if (i < 6 && j < 7 && a[i + 1][j] == '1' && a[i + 1][j + 1] == '1' &&
a[i + 2][j + 1] == '1')
puts("F");
if (i < 7 && j < 7 && j > 0 && a[i][j + 1] == '1' && a[i + 1][j] == '1' &&
a[i + 1][j - 1] == '1')
puts("G");
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
| 0
| 558
| 4
|
#include <math.h>
#include <stdio.h>
int main() {
char men[10][10], t;
int i, j;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
men[i][j] = 0;
}
}
while (0 <= scanf("%*c%s%*c", men[0])) {
for (i = 1; i < 8; i++) {
scanf("%*c%s%*c", men[i]);
}
t = '0';
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (men[i][j] == '1') {
t = '2';
break;
}
}
if (t == '2')
break;
}
if (men[i][j + 1] == '1' && men[i + 1][j] == '1' &&
men[i + 1][j + 1] == '1') {
printf("A\n");
} else if (men[i + 2][j] == '1') {
printf("B\n");
} else if (men[i][j + 2] == '1') {
printf("C\n");
} else if (men[i + 2][(j - 1) % 10] == '1') {
printf("D\n");
} else if (men[i + 1][(j + 2) % 10] == '1') {
printf("E\n");
} else if (men[(i + 2) % 10][(j + 1) % 10] == '1') {
printf("F\n");
} else {
printf("G\n");
}
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main() {
char men[10][10], t;
int i, j;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
men[i][j] = 0;
}
}
while (0 <= scanf("%s%*c", men[0])) {
for (i = 1; i < 8; i++) {
scanf("%s%*c", men[i]);
}
t = '0';
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (men[i][j] == '1') {
t = '2';
break;
}
}
if (t == '2')
break;
}
if (men[i][j + 1] == '1' && men[i + 1][j] == '1' &&
men[i + 1][j + 1] == '1') {
printf("A\n");
} else if (men[i + 2][j] == '1') {
printf("B\n");
} else if (men[i][j + 2] == '1') {
printf("C\n");
} else if (men[i + 2][(j - 1) % 10] == '1') {
printf("D\n");
} else if (men[i + 1][(j + 2) % 10] == '1') {
printf("E\n");
} else if (men[(i + 2) % 10][(j + 1) % 10] == '1') {
printf("F\n");
} else {
printf("G\n");
}
/* for(i=0;i<10;i++){
for(j=0;j<10;j++){
printf("%c",men[i][j]);
men[i][j]=0;
}
printf("\n");
}*/
}
return 0;
}
|
[["-", 0, 16, 12, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 12, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 408
| 4
|
#include <stdio.h>
#include <string.h>
int main() {
int i, type, j, x;
char str[9];
while (scanf("%s", str) != EOF) {
type = 0;
for (i = 0; i < 8; i++) {
if (str[i] == '1') {
x = i;
if (i + 1 < 8 && str[i + 1] == '1') {
if (i + 3 < 8 && str[i + 3] == '1') {
printf("C\n");
type = 3;
} else {
type = 2;
}
} else {
type = 1;
}
break;
}
}
for (i = 0; i < 7; i++) {
scanf("%s", str);
for (j = 0; j < 8; j++) {
if (str[j] == '1') {
if (type == 0) {
x = j;
if (j + 1 < 8 && str[j + 1] == '1') {
if (j + 3 < 8 && str[j + 3] == '1') {
printf("C\n");
type = 3;
} else {
type = 2;
}
} else {
type = 1;
}
} else if (type == 1) {
if (x == j - 1) {
printf("D\n");
type = 3;
} else if (x == j) {
if (x + 1 < 8 && str[x + 1] == '1') {
printf("F\n");
} else {
printf("B\n");
}
type = 3;
}
} else if (type == 2) {
if (x == j + 1) {
printf("G\n");
} else if (x == j) {
printf("A\n");
} else {
printf("E\n");
}
type = 3;
}
break;
}
}
}
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main() {
int i, type, j, x;
char str[9];
while (scanf("%s", str) != EOF) {
type = 0;
for (i = 0; i < 8; i++) {
if (str[i] == '1') {
x = i;
if (i + 1 < 8 && str[i + 1] == '1') {
if (i + 3 < 8 && str[i + 3] == '1') {
printf("C\n");
type = 3;
} else {
type = 2;
}
} else {
type = 1;
}
break;
}
}
for (i = 0; i < 7; i++) {
scanf("%s", str);
for (j = 0; j < 8; j++) {
if (str[j] == '1') {
if (type == 0) {
x = j;
if (j + 1 < 8 && str[j + 1] == '1') {
if (j + 3 < 8 && str[j + 3] == '1') {
printf("C\n");
type = 3;
} else {
type = 2;
}
} else {
type = 1;
}
} else if (type == 1) {
if (x == j + 1) {
printf("D\n");
type = 3;
} else if (x == j) {
if (x + 1 < 8 && str[x + 1] == '1') {
printf("F\n");
} else {
printf("B\n");
}
type = 3;
}
} else if (type == 2) {
if (x == j + 1) {
printf("G\n");
} else if (x == j) {
printf("A\n");
} else {
printf("E\n");
}
type = 3;
}
break;
}
}
}
}
return 0;
}
|
[["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 72]]
| 0
| 426
| 2
|
#include <stdio.h>
#define WIDTH 8
#define HEIGHT 8
char field[WIDTH + 3][HEIGHT + 2] = {};
int main(void) {
char type;
int x, y;
for (; ungetc(getchar(), stdin) != EOF; printf("%c\n", type)) {
for (y = 0; y < HEIGHT; y++)
for (x = 1; x <= WIDTH; x++)
scanf("%c ", field[x] + y);
for (y = 0; y < HEIGHT; y++)
for (x = 1; x <= WIDTH; x++)
if (field[x][y] == '1') {
if (field[x + 2][y] == '1')
type = 'C';
else if (field[x + 2][y + 1] == '1')
type = 'E';
else if (field[x + 1][y + 2] == '1')
type = 'F';
else if (field[x][y + 2] == '1')
type = 'B';
else if (field[x - 1][y + 2] == '1')
type = 'D';
else if (field[x - 1][y + 1] == '1')
type = 'G';
else
type = 'A';
break;
}
contin:;
}
return 0;
}
|
#include <stdio.h>
#define WIDTH 8
#define HEIGHT 8
char field[WIDTH + 3][HEIGHT + 2] = {};
int main(void) {
char type;
int x, y;
for (; ungetc(getchar(), stdin) != EOF; printf("%c\n", type)) {
for (y = 0; y < HEIGHT; y++)
for (x = 1; x <= WIDTH; x++)
scanf("%c ", field[x] + y);
for (y = 0; y < HEIGHT; y++)
for (x = 1; x <= WIDTH; x++)
if (field[x][y] == '1') {
if (field[x + 2][y] == '1')
type = 'C';
else if (field[x + 2][y + 1] == '1')
type = 'E';
else if (field[x + 1][y + 2] == '1')
type = 'F';
else if (field[x][y + 2] == '1')
type = 'B';
else if (field[x - 1][y + 2] == '1')
type = 'D';
else if (field[x - 1][y + 1] == '1')
type = 'G';
else
type = 'A';
goto contin;
}
contin:;
}
return 0;
}
|
[["-", 8, 7, 8, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 7, 8, 57, 64, 9, 0, 126, 0, 127], ["+", 8, 7, 8, 57, 64, 9, 0, 126, 128, 129]]
| 0
| 307
| 3
|
#include <stdio.h>
int main(void) {
int i, j;
char board[8][8];
while (scanf(" %s\n", board[0]) != EOF) {
for (i = 1; i < 8; i++)
scanf(" %s", board[i]);
for (i = 0;; i++) {
for (j = 0; j < 8; j++) {
if (board[i][j] == '1')
break;
}
if (board[i][j] == '1')
break;
}
if (i < 7 && j < 7 && board[i][j + 1] == '1' && board[i + 1][j] == '1' &&
board[i + 1][j + 1] == '1')
printf("A\n");
if (i < 5 && board[i + 1][j] == '1' && board[i + 2][j] == '1' &&
board[i + 3][j] == '1')
printf("B\n");
if (j < 5 && board[i][j + 1] == '1' && board[i][j + 2] == '1' &&
board[i][j + 3] == '1')
printf("C\n");
if (i < 6 && j > 0 && board[i + 1][j] == '1' &&
board[i + 1][j - 1] == '1' && board[i + 2][j - 1] == '1')
printf("D\n");
if (i < 7 && j < 6 && board[i][j + 1] == '1' &&
board[i + 1][j + 1] == '1' && board[i + 1][j + 2] == '1')
printf("E\n");
if (i < 6 && j < 7 && board[i + 1][j] == '1' &&
board[i + 1][j + 1] == '1' && board[i + 2][j + 1] == '1')
printf("F\n");
if (i < 7 && j > 0 && j < 7 && board[i][j + 1] == '1' &&
board[i + 1][j] == '1' && board[i + 1][j - 1] == '1')
printf("G\n");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int i, j;
char board[9][9];
while (scanf(" %s\n", board[0]) != EOF) {
for (i = 1; i < 8; i++)
scanf(" %s", board[i]);
for (i = 0;; i++) {
for (j = 0; j < 8; j++) {
if (board[i][j] == '1')
break;
}
if (board[i][j] == '1')
break;
}
if (i < 7 && j < 7 && board[i][j + 1] == '1' && board[i + 1][j] == '1' &&
board[i + 1][j + 1] == '1')
printf("A\n");
if (i < 5 && board[i + 1][j] == '1' && board[i + 2][j] == '1' &&
board[i + 3][j] == '1')
printf("B\n");
if (j < 5 && board[i][j + 1] == '1' && board[i][j + 2] == '1' &&
board[i][j + 3] == '1')
printf("C\n");
if (i < 6 && j > 0 && board[i + 1][j] == '1' &&
board[i + 1][j - 1] == '1' && board[i + 2][j - 1] == '1')
printf("D\n");
if (i < 7 && j < 6 && board[i][j + 1] == '1' &&
board[i + 1][j + 1] == '1' && board[i + 1][j + 2] == '1')
printf("E\n");
if (i < 6 && j < 7 && board[i + 1][j] == '1' &&
board[i + 1][j + 1] == '1' && board[i + 2][j + 1] == '1')
printf("F\n");
if (i < 7 && j > 0 && j < 7 && board[i][j + 1] == '1' &&
board[i + 1][j] == '1' && board[i + 1][j - 1] == '1')
printf("G\n");
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
| 0
| 561
| 4
|
import java.util.Arrays;
import java.util.Scanner;
public class Main {
private int num;
private int[] a;
final String[] rom = {"I", "V", "X", "L", "C", "D", "M"};
final int[] nrom = {1, 5, 10, 50, 100, 500, 1000};
public static void main(String[] args) { new Main().run(); }
private void run() {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
String str = scan.nextLine();
int n = str.length();
a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = number(str.substring(i, i + 1));
}
for (int i = 0; i < n - 1; i++) {
if (a[i] < a[i + 1]) {
a[i] = a[i + 1] - a[i];
neat(i + 1, n--);
}
}
debug();
num = 0;
for (int i = 0; i < n; i++) {
num += a[i];
}
System.out.println(num);
}
}
private int number(String s) {
int i = 0;
while (true) {
if (s.equals(rom[i]))
break;
i++;
}
return nrom[i];
}
private void neat(int b, int e) {
for (int i = b + 1; i < e; i++) {
a[i - 1] = a[i];
}
}
private void debug() { System.out.println(Arrays.toString(a)); }
}
|
import java.util.Arrays;
import java.util.Scanner;
public class Main {
private int num;
private int[] a;
final String[] rom = {"I", "V", "X", "L", "C", "D", "M"};
final int[] nrom = {1, 5, 10, 50, 100, 500, 1000};
public static void main(String[] args) { new Main().run(); }
private void run() {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
String str = scan.nextLine();
int n = str.length();
a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = number(str.substring(i, i + 1));
}
for (int i = 0; i < n - 1; i++) {
if (a[i] < a[i + 1]) {
a[i] = a[i + 1] - a[i];
neat(i + 1, n--);
}
}
// debug();
num = 0;
for (int i = 0; i < n; i++) {
num += a[i];
}
System.out.println(num);
}
}
private int number(String s) {
int i = 0;
while (true) {
if (s.equals(rom[i]))
break;
i++;
}
return nrom[i];
}
private void neat(int b, int e) {
for (int i = b + 1; i < e; i++) {
a[i - 1] = a[i];
}
}
private void debug() { System.out.println(Arrays.toString(a)); }
}
|
[["-", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 25], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 3
| 404
| 4
|
#include <stdio.h>
#include <string.h>
int main(void) {
char s[200];
int i, j, n, S[200], sum;
while (scanf("%s", s) != EOF) {
sum = 0;
for (i = 0; i < strlen(s); i++) {
if (s[i] == 'I')
S[i] = 1;
if (s[i] == 'V')
S[i] = 5;
if (s[i] == 'X')
S[i] = 10;
if (s[i] == 'L')
S[i] = 50;
if (s[i] == 'C')
S[i] = 100;
if (s[i] == 'D')
S[i] = 500;
if (s[i] == 'M')
S[i] = 10000;
}
S[i] = 0;
n = i;
for (i = 0; i < n; i++) {
if (S[i] < S[i + 1])
S[i] *= -1;
}
for (i = 0; i < n; i++)
sum += S[i];
printf("%d\n", sum);
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main(void) {
char s[200];
int i, j, n, S[200], sum;
while (scanf("%s", s) != EOF) {
sum = 0;
for (i = 0; i < strlen(s); i++) {
if (s[i] == 'I')
S[i] = 1;
if (s[i] == 'V')
S[i] = 5;
if (s[i] == 'X')
S[i] = 10;
if (s[i] == 'L')
S[i] = 50;
if (s[i] == 'C')
S[i] = 100;
if (s[i] == 'D')
S[i] = 500;
if (s[i] == 'M')
S[i] = 1000;
}
S[i] = 0;
n = i;
for (i = 0; i < n; i++) {
if (S[i] < S[i + 1])
S[i] *= -1;
}
for (i = 0; i < n; i++)
sum += S[i];
printf("%d\n", sum);
}
return 0;
}
|
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
| 0
| 274
| 2
|
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
main() {
map<char, int> kioku;
kioku['I'] = 1;
kioku['V'] = 5;
kioku['X'] = 10;
kioku['L'] = 50;
kioku['C'] = 100;
kioku['D'] = 500;
kioku['M'] = 1000;
char tmp[1000];
char c;
int num = 0;
int before = 0;
while (cin >> tmp) {
for (int i = 0; i < strlen(tmp); i++) {
if (i != strlen(tmp) - 1) {
if (kioku[tmp[i + 1]] > kioku[tmp[i]]) {
num += abs(kioku[tmp[i]] - kioku[tmp[i + 1]]);
i++;
} else {
num += kioku[tmp[i]];
}
} else {
num += kioku[tmp[i]];
}
}
cout << num;
num = 0;
}
}
|
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
main() {
map<char, int> kioku;
kioku['I'] = 1;
kioku['V'] = 5;
kioku['X'] = 10;
kioku['L'] = 50;
kioku['C'] = 100;
kioku['D'] = 500;
kioku['M'] = 1000;
char tmp[1000];
char c;
int num = 0;
int before = 0;
while (cin >> tmp) {
for (int i = 0; i < strlen(tmp); i++) {
if (i != strlen(tmp) - 1) {
if (kioku[tmp[i + 1]] > kioku[tmp[i]]) {
num += abs(kioku[tmp[i]] - kioku[tmp[i + 1]]);
i++;
} else {
num += kioku[tmp[i]];
}
} else {
num += kioku[tmp[i]];
}
}
cout << num << endl;
num = 0;
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 231
| 2
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
string s;
map<char, int> conv;
conv['I'] = 1;
conv['V'] = 5;
conv['X'] = 10;
conv['L'] = 50;
conv['C'] = 100;
conv['D'] = 500;
conv['M'] = 1000;
while (cin >> s) {
long ans = 0;
for (int i = 0; i < s.size() - 1; i++) {
if (conv[s[i]] < conv[s[i + 1]])
ans += conv[s[i]];
else
ans -= conv[s[i]];
}
ans += conv[s[s.size() - 1]];
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
string s;
map<char, int> conv;
conv['I'] = 1;
conv['V'] = 5;
conv['X'] = 10;
conv['L'] = 50;
conv['C'] = 100;
conv['D'] = 500;
conv['M'] = 1000;
while (cin >> s) {
long ans = 0;
for (int i = 0; i < s.size() - 1; i++) {
if (conv[s[i]] < conv[s[i + 1]])
ans -= conv[s[i]];
else
ans += conv[s[i]];
}
ans += conv[s[s.size() - 1]];
cout << ans << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 110], ["-", 0, 57, 75, 76, 0, 1, 0, 11, 17, 110], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 17, 107]]
| 1
| 207
| 4
|
#include <iostream>
#include <string>
using namespace std;
string S;
char T[8] = "IVXLCDM";
int X[7] = {1, 5, 10, 50, 100, 500, 1000}, l[10000];
int main() {
while (cin >> S) {
int cnt = 0;
for (int i = 0; i < S.size(); i++) {
for (int j = 0; j < 7; j++) {
if (S[i] == T[j]) {
l[i] = j;
cnt += X[j];
}
}
}
for (int i = 1; i < S.size(); i++) {
if (l[i - 1] > l[i]) {
cnt -= X[l[i - 1]];
}
}
cout << cnt << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
string S;
char T[8] = "IVXLCDM";
int X[7] = {1, 5, 10, 50, 100, 500, 1000}, l[10000];
int main() {
while (cin >> S) {
int cnt = 0;
for (int i = 0; i < S.size(); i++) {
for (int j = 0; j < 7; j++) {
if (S[i] == T[j]) {
l[i] = j;
cnt += X[j];
}
}
}
for (int i = 1; i < S.size(); i++) {
if (l[i - 1] < l[i]) {
cnt -= X[l[i - 1]] * 2;
}
}
cout << cnt << endl;
}
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
| 1
| 185
| 4
|
#include <iostream>
#include <math.h>
#include <stdio.h>
// I は1, V は5, X は10, L は50, C は100, D は500, M は1000,
#define I 1
#define V 5
#define X 10
#define L 50
#define C 100
#define D 500
#define M 1000
using namespace std;
int main() {
string str;
while (cin >> str) {
cin >> str;
int data[200];
int sum = 0;
//データの数値化
for (int i = 0; i < str.size(); i++) {
switch (str[i]) {
case 'I':
data[i] = I;
break;
case 'V':
data[i] = V;
break;
case 'X':
data[i] = X;
break;
case 'L':
data[i] = L;
break;
case 'C':
data[i] = C;
break;
case 'D':
data[i] = D;
break;
case 'M':
data[i] = M;
break;
}
}
for (int i = 0; i < str.size(); i++) {
if (i == str.size() - 1) {
sum += data[i];
} else {
if (data[i] < data[i + 1]) {
sum += (data[i + 1] - data[i]);
i++;
} else {
sum += data[i];
}
}
}
cout << sum << endl;
}
return 0;
}
/*
IV
CCCCLXXXXVIIII
CDXCIX
*/
|
#include <iostream>
#include <math.h>
#include <stdio.h>
// I は1, V は5, X は10, L は50, C は100, D は500, M は1000,
#define I 1
#define V 5
#define X 10
#define L 50
#define C 100
#define D 500
#define M 1000
using namespace std;
int main() {
string str;
while (cin >> str) {
int data[200];
int sum = 0;
//データの数値化
for (int i = 0; i < str.size(); i++) {
switch (str[i]) {
case 'I':
data[i] = I;
break;
case 'V':
data[i] = V;
break;
case 'X':
data[i] = X;
break;
case 'L':
data[i] = L;
break;
case 'C':
data[i] = C;
break;
case 'D':
data[i] = D;
break;
case 'M':
data[i] = M;
break;
}
}
for (int i = 0; i < str.size(); i++) {
if (i == str.size() - 1) {
sum += data[i];
} else {
if (data[i] < data[i + 1]) {
sum += (data[i + 1] - data[i]);
i++;
} else {
sum += data[i];
}
}
}
cout << sum << endl;
}
return 0;
}
/*
IV
CCCCLXXXXVIIII
CDXCIX
*/
|
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 291
| 4
|
// 0039
// include-------------------------------------
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define MP make_pair
// repetition-----------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
// constant-------------------------------------
const double PI = acos(-1.0);
// cout,cin-------------------------------------
#define COUT(x) cout << (x) << endl
#define CIN(x) cin >> (x)
int f(char c) {
if (c == 'I')
return 1;
else if (c == 'V')
return 5;
else if (c == 'X')
return 10;
else if (c == 'L')
return 50;
else if (c == 'C')
return 100;
else if (c == 'D')
return 500;
else if (c == 'M')
return 1000;
}
int main() {
int ans = 0;
string st;
while (CIN(st)) {
int now = f(st[0]);
if (st.size() == 1)
ans = now;
ans = now;
REP(i, st.size() - 1) {
now >= f(st[i + 1]) ? ans += f(st[i + 1])
: ans += f(st[i + 1]) - now - now;
now = f(st[i + 1]);
COUT(ans);
}
COUT(ans);
}
return 0;
}
|
// 0039
// include-------------------------------------
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define MP make_pair
// repetition-----------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
// constant-------------------------------------
const double PI = acos(-1.0);
// cout,cin-------------------------------------
#define COUT(x) cout << (x) << endl
#define CIN(x) cin >> (x)
int f(char c) {
if (c == 'I')
return 1;
else if (c == 'V')
return 5;
else if (c == 'X')
return 10;
else if (c == 'L')
return 50;
else if (c == 'C')
return 100;
else if (c == 'D')
return 500;
else if (c == 'M')
return 1000;
}
int main() {
int ans = 0;
string st;
while (CIN(st)) {
int now = f(st[0]);
if (st.size() == 1)
ans = now;
ans = now;
REP(i, st.size() - 1) {
now >= f(st[i + 1]) ? ans += f(st[i + 1])
: ans += f(st[i + 1]) - now - now;
now = f(st[i + 1]);
}
COUT(ans);
}
return 0;
}
|
[["-", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 52, 8, 9, 0, 9, 0, 1, 0, 35]]
| 1
| 317
| 5
|
char = {}
char["I"] = 1
char["V"] = 5
char["X"] = 10
char["L"] = 50
char["C"] = 100
char["D"] = 500
char["M"] = 500
while input = gets
chars = input.chomp.split("")
n = chars.size
n.times{|i|
chars[i] = char[chars[i]]
}
(n-1).downto(1){|i|
if chars[i] > chars[i-1]
chars[i] -= chars[i-1]
chars[i-1] = 0
end
}
p chars.inject(:+)
end
|
char = {}
char["I"] = 1
char["V"] = 5
char["X"] = 10
char["L"] = 50
char["C"] = 100
char["D"] = 500
char["M"] = 1000
while input = gets
chars = input.chomp.split("")
n = chars.size
n.times{|i|
chars[i] = char[chars[i]]
}
(n-1).downto(1){|i|
if chars[i] > chars[i-1]
chars[i] -= chars[i-1]
chars[i-1] = 0
end
}
p chars.inject(:+)
end
|
[["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612]]
| 4
| 155
| 2
|
import sys
def dec_num(x):
for i in range(len(x)):
if x[i] == 2:
x[i] = 5
elif x[i] == 3:
x[i] = 10
elif x[i] == 4:
x[i] = 50
elif x[i] == 5:
x[i] = 100
elif x[i] == 6:
x[i] = 500
elif x[i] == 7:
x[i] = 1000
def to_index(x):
if x == 1:
return 1
elif x == 5:
return 2
elif x == 10:
return 3
elif x == 50:
return 4
elif x == 100:
return 5
elif x == 500:
return 6
elif x == 1000:
return 7
def toNum(x):
result = 0
tmp = x[0]
for i in range(len(x)):
if tmp < x[i]:
result += x[i]-tmp
elif i <= len(x) and x[i] < x[i+1]:
result += 0
else:
result += x[i]
tmp = x[i]
return result
for line in sys.stdin.readlines():
line = line.translate(str.maketrans('IVXLCDM', '1234567'))
num = list(map(int, (' '.join(line)).split()))
dec_num(num)
print(toNum(num))
|
import sys
def dec_num(x):
for i in range(len(x)):
if x[i] == 2:
x[i] = 5
elif x[i] == 3:
x[i] = 10
elif x[i] == 4:
x[i] = 50
elif x[i] == 5:
x[i] = 100
elif x[i] == 6:
x[i] = 500
elif x[i] == 7:
x[i] = 1000
def to_index(x):
if x == 1:
return 1
elif x == 5:
return 2
elif x == 10:
return 3
elif x == 50:
return 4
elif x == 100:
return 5
elif x == 500:
return 6
elif x == 1000:
return 7
def toNum(x):
result = 0
tmp = x[0]
for i in range(len(x)):
if tmp < x[i]:
result += x[i]-tmp
elif i < len(x)-1 and x[i] < x[i+1]:
result += 0
else:
result += x[i]
tmp = x[i]
return result
for line in sys.stdin.readlines():
line = line.translate(str.maketrans('IVXLCDM', '1234567'))
num = list(map(int, (' '.join(line)).split()))
dec_num(num)
print(toNum(num))
|
[["-", 0, 57, 75, 665, 15, 679, 31, 666, 667, 19], ["+", 0, 57, 75, 665, 15, 679, 31, 666, 667, 18], ["+", 75, 665, 15, 679, 31, 666, 0, 657, 17, 33], ["+", 75, 665, 15, 679, 31, 666, 0, 657, 12, 612]]
| 5
| 304
| 4
|
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);
int main() {
VS s(10);
while (cin >> s[0]) {
s[0] += "00000";
FOR(i, 1, 8) {
cin >> s[i];
s[i] += "00000";
}
s[8] = string(15, '0');
s[9] = string(15, '0');
int x = -1, y = -1;
rep(i, 8) rep(j, 8) {
if (x == -1 && y == -1 && s[i][j] == '1') {
x = j;
y = i;
break;
}
}
bool f2 = s[y + 1][x] == '1';
bool f1 = s[y][x + 1] == '1';
bool f3 = s[y + 1][x + 1] == '1';
char ans = '#';
if (f1 && f2) { // A G
ans = f3 ? 'A' : 'G';
} else if (f1 && !f2) { // C E
ans = f3 ? 'E' : 'C';
} else if (!f1 && f2) { // B D F
if (f3)
ans = 'F';
else
ans = s[x][y + 2] == '1' ? 'B' : 'D';
}
Cout(ans);
}
}
|
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);
int main() {
VS s(10);
while (cin >> s[0]) {
s[0] += "00000";
FOR(i, 1, 8) {
cin >> s[i];
s[i] += "00000";
}
s[8] = string(15, '0');
s[9] = string(15, '0');
int x = -1, y = -1;
rep(i, 8) rep(j, 8) {
if (x == -1 && y == -1 && s[i][j] == '1') {
x = j;
y = i;
break;
}
}
bool f2 = s[y + 1][x] == '1';
bool f1 = s[y][x + 1] == '1';
bool f3 = s[y + 1][x + 1] == '1';
char ans = '#';
if (f1 && f2) { // A G
ans = f3 ? 'A' : 'G';
} else if (f1 && !f2) { // C E
ans = f3 ? 'E' : 'C';
} else if (!f1 && f2) { // B D F
if (f3)
ans = 'F';
else
ans = s[y + 2][x] == '1' ? 'B' : 'D';
}
Cout(ans);
}
}
|
[["-", 15, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 15, 16, 31, 69, 28, 69, 341, 342, 0, 73], ["-", 12, 41, 15, 16, 31, 69, 341, 342, 0, 70], ["+", 15, 16, 31, 69, 28, 69, 341, 342, 0, 73], ["+", 12, 41, 15, 16, 31, 69, 341, 342, 0, 70], ["+", 12, 41, 15, 16, 31, 69, 341, 342, 0, 22]]
| 1
| 436
| 6
|
#include <algorithm>
#include <stdio.h>
using namespace std;
int pow(int a, int n) {
if (n <= 0) {
return 1;
}
return a * pow(a, n - 1);
}
int main() {
char a[8][9];
int ans = 0;
while (1) {
for (int i = 0; i < 8; i++) {
if (scanf("%s", &a[i]) == EOF) {
return 0;
}
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (a[i][j] == '1') {
if (i < 7 && j < 7) {
if (a[i + 1][j] == '1' && a[i][j + 1] == '1' &&
a[i + 1][j + 1] == '1') {
printf("A\n");
}
}
if (i < 5) {
if (a[i + 1][j] == '1' && a[i + 2][j] == '1' &&
a[i + 3][j] == '1') {
printf("B\n");
}
}
if (j < 5) {
if (a[i][j + 1] == '1' && a[i][j + 2] == '1' &&
a[i][j + 3] == '1') {
printf("C\n");
}
}
if (i < 6 && j < 5) {
if (a[i][j + 1] == '1' && a[i + 1][j + 1] == '1' &&
a[i + 1][j + 2] == '1') {
printf("E\n");
}
}
if (i < 5 && j < 7) {
if (a[i + 1][j] == '1' && a[i + 1][j + 1] == '1' &&
a[i + 2][j + 1] == '1') {
printf("F\n");
}
}
if (j > 0 && i < 5) {
if (a[i + 1][j] == '1' && a[i + 1][j - 1] == '1' &&
a[i + 2][j - 1] == '1') {
printf("D\n");
}
}
if (j > 0 && j < 7 && i < 7) {
if (a[i + 1][j] == '1' && a[i][j + 1] == '1' &&
a[i + 1][j - 1] == '1') {
printf("G\n");
}
}
}
}
}
}
///////////////////////////////////
// Sleep(200000);///////////////////// 提出するときは必ず外す!
///////////////////////////////////
return 0;
}
|
#include <algorithm>
#include <stdio.h>
using namespace std;
int pow(int a, int n) {
if (n <= 0) {
return 1;
}
return a * pow(a, n - 1);
}
int main() {
char a[8][9];
int ans = 0;
while (1) {
for (int i = 0; i < 8; i++) {
if (scanf("%s", &a[i]) == EOF) {
return 0;
}
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (a[i][j] == '1') {
if (i < 7 && j < 7) {
if (a[i + 1][j] == '1' && a[i][j + 1] == '1' &&
a[i + 1][j + 1] == '1') {
printf("A\n");
}
}
if (i < 5) {
if (a[i + 1][j] == '1' && a[i + 2][j] == '1' &&
a[i + 3][j] == '1') {
printf("B\n");
}
}
if (j < 5) {
if (a[i][j + 1] == '1' && a[i][j + 2] == '1' &&
a[i][j + 3] == '1') {
printf("C\n");
}
}
if (i < 7 && j < 6) {
if (a[i][j + 1] == '1' && a[i + 1][j + 1] == '1' &&
a[i + 1][j + 2] == '1') {
printf("E\n");
}
}
if (i < 6 && j < 7) {
if (a[i + 1][j] == '1' && a[i + 1][j + 1] == '1' &&
a[i + 2][j + 1] == '1') {
printf("F\n");
}
}
if (j > 0 && i < 6) {
if (a[i + 1][j] == '1' && a[i + 1][j - 1] == '1' &&
a[i + 2][j - 1] == '1') {
printf("D\n");
}
}
if (j > 0 && j < 7 && i < 7) {
if (a[i + 1][j] == '1' && a[i][j + 1] == '1' &&
a[i + 1][j - 1] == '1') {
printf("G\n");
}
}
}
}
}
}
///////////////////////////////////
// Sleep(200000);///////////////////// 提出するときは必ず外す!
///////////////////////////////////
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 634
| 8
|
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long Int;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPS(a, i, n) for (int i = a; i < n; ++i)
using namespace std;
int tile[20][20];
int main() {
while (true) {
string a;
if (cin.eof())
break;
/*
for (size_t c = a.find_first_of(" "); c != string::npos; c =
a.find_first_of(" ")){ a.erase(c, 1);
}
*/
getline(cin, a);
if (a.empty())
continue;
REP(j, 8) { tile[3][7 + 3 - j] = '0' - a[7 - j]; }
REP(i, 7) {
getline(cin, a);
/*for (size_t c = a.find_first_of(" "); c != string::npos; c =
a.find_first_of(" ")){ a.erase(c, 1);
}*/
REP(j, 8) { tile[i + 3 + 1][7 + 3 - j] = '0' - a[7 - j]; }
}
REP(i, 15) {
REP(j, 15) {
if (tile[i][j]) {
if (tile[i + 1][j] && tile[i][j + 1] && tile[i + 1][j + 1]) {
cout << "A" << endl;
goto END;
}
if (tile[i][j + 1] && tile[i + 1][j + 1] && tile[i + 1][j + 2]) {
cout << "E" << endl;
goto END;
}
if (tile[i + 1][j] && tile[i + 1][j + 1] && tile[i + 2][j + 1]) {
cout << "F" << endl;
goto END;
}
if (tile[i + 1][j] && tile[i][j + 1] && tile[i + 1][j - 1]) {
cout << "G" << endl;
goto END;
}
if (tile[i + 1][j] && tile[i + 2][j] && tile[i + 3][j]) {
cout << "B" << endl;
goto END;
}
if (tile[i][j + 1] && tile[i][j + 2] && tile[i][j + 3]) {
cout << "C" << endl;
goto END;
}
if (tile[i + 1][j] && tile[i + 1][j - 1] && tile[i + 2][j - 1]) {
cout << "A" << endl;
goto END;
}
}
}
}
END:;
}
return 0;
}
|
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long Int;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPS(a, i, n) for (int i = a; i < n; ++i)
using namespace std;
int tile[20][20];
int main() {
while (true) {
string a;
if (cin.eof())
break;
/*
for (size_t c = a.find_first_of(" "); c != string::npos; c =
a.find_first_of(" ")){ a.erase(c, 1);
}
*/
getline(cin, a);
if (a.empty())
continue;
REP(j, 8) { tile[3][7 + 3 - j] = '0' - a[7 - j]; }
REP(i, 7) {
getline(cin, a);
/*for (size_t c = a.find_first_of(" "); c != string::npos; c =
a.find_first_of(" ")){ a.erase(c, 1);
}*/
REP(j, 8) { tile[i + 3 + 1][7 + 3 - j] = '0' - a[7 - j]; }
}
REP(i, 15) {
REP(j, 15) {
if (tile[i][j]) {
if (tile[i + 1][j] && tile[i][j + 1] && tile[i + 1][j + 1]) {
cout << "A" << endl;
goto END;
}
if (tile[i][j + 1] && tile[i + 1][j + 1] && tile[i + 1][j + 2]) {
cout << "E" << endl;
goto END;
}
if (tile[i + 1][j] && tile[i + 1][j + 1] && tile[i + 2][j + 1]) {
cout << "F" << endl;
goto END;
}
if (tile[i + 1][j] && tile[i][j + 1] && tile[i + 1][j - 1]) {
cout << "G" << endl;
goto END;
}
if (tile[i + 1][j] && tile[i + 2][j] && tile[i + 3][j]) {
cout << "B" << endl;
goto END;
}
if (tile[i][j + 1] && tile[i][j + 2] && tile[i][j + 3]) {
cout << "C" << endl;
goto END;
}
if (tile[i + 1][j] && tile[i + 1][j - 1] && tile[i + 2][j - 1]) {
cout << "D" << endl;
goto END;
}
}
}
}
END:;
}
return 0;
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 554
| 2
|
#include <iostream>
using namespace std;
#define rep(i, a) for (int i = 0; i < a; i++)
int main(void) {
char maze[9][9];
while (true) {
rep(i, 8) rep(j, 8) cin >> maze[i][j];
if (cin.eof())
break;
bool used = false;
rep(y, 8) {
rep(x, 8) {
if (maze[y][x] == '1') {
if (maze[y][x + 1] == '1' && maze[y + 1][x] == '1' &&
maze[y + 1][x + 1] == '1')
cout << "A" << endl;
else if (maze[y + 1][x] == '1' && maze[y + 2][x] == '1' &&
maze[y + 3][x] == '1')
cout << "B" << endl;
else if (maze[y][x + 3] == '1' && maze[y][x + 2] == '1' &&
maze[y][x + 1] == '1')
cout << "C" << endl;
else if (maze[y + 1][x] == '1' && maze[y + 1][x - 1] == '1' &&
maze[y + 2][x - 1] == '1')
cout << "D" << endl;
else if (maze[y][x + 1] == '1' && maze[y + 1][x + 1] == '1' &&
maze[y + 1][x + 2] == '1')
cout << "E" << endl;
else if (maze[y + 1][x] == '1' && maze[y + 1][+1] == '1' &&
maze[y + 2][x + 1] == '1')
cout << "F" << endl;
else
cout << "G" << endl;
used = true;
}
if (used)
break;
}
if (used)
break;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
#define rep(i, a) for (int i = 0; i < a; i++)
int main(void) {
char maze[9][9];
while (true) {
rep(i, 8) rep(j, 8) cin >> maze[i][j];
if (cin.eof())
break;
bool used = false;
rep(y, 8) {
rep(x, 8) {
if (maze[y][x] == '1') {
if (maze[y][x + 1] == '1' && maze[y + 1][x] == '1' &&
maze[y + 1][x + 1] == '1')
cout << "A" << endl;
else if (maze[y + 1][x] == '1' && maze[y + 2][x] == '1' &&
maze[y + 3][x] == '1')
cout << "B" << endl;
else if (maze[y][x + 1] == '1' && maze[y][x + 2] == '1' &&
maze[y][x + 3] == '1')
cout << "C" << endl;
else if (maze[y + 1][x] == '1' && maze[y + 1][x - 1] == '1' &&
maze[y + 2][x - 1] == '1')
cout << "D" << endl;
else if (maze[y][x + 1] == '1' && maze[y + 1][x + 1] == '1' &&
maze[y + 1][x + 2] == '1')
cout << "E" << endl;
else if (maze[y + 1][x] == '1' && maze[y + 1][x + 1] == '1' &&
maze[y + 2][x + 1] == '1')
cout << "F" << endl;
else
cout << "G" << endl;
used = true;
}
if (used)
break;
}
if (used)
break;
}
}
return 0;
}
|
[["-", 31, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 31, 16, 12, 16, 31, 69, 341, 342, 0, 13], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72]]
| 1
| 463
| 8
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
#define rrep(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define erep(i, m, n) for (int(i) = (m); (i) <= (n); (i)++)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rev(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define vrep(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
template <class T1, class T2> inline void minup(T1 &m, T2 x) {
if (m > x)
m = static_cast<T2>(x);
}
template <class T1, class T2> inline void maxup(T1 &m, T2 x) {
if (m < x)
m = static_cast<T2>(x);
}
#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12
const int N = 8;
char m[N][N];
inline bool check(int x, int y) { return 0 <= x && x < N && 0 <= y && y < N; }
int main() {
while (true) {
rep(i, N) rep(j, N) if (!(cin >> m[i][j])) return 0;
rep(i, N) rep(j, N) if (m[i][j] == '1') {
if (check(i + 1, j + 1) && m[i + 1][j] == '1' && m[i][j + 1] == '1' &&
m[i + 1][j + 1] == '1')
cout << "A" << endl;
if (check(i + 3, j) && m[i + 1][j] == '1' && m[i + 2][j] == '1' &&
m[i + 3][j] == '1')
cout << "B" << endl;
if (check(i, j + 3) && m[i][j + 1] == '1' && m[i][j + 2] == '1' &&
m[i][j + 3] == '1')
cout << "C" << endl;
if (check(i + 2, j - 1) && m[i + 1][j] == '1' && m[i + 1][j - 1] == '1' &&
m[i + 2][j - 1] == '1')
cout << "D" << endl;
if (check(i + 1, j + 2) && m[i][j + 1] == '1' && m[i + 1][j + 1] == '1' &&
m[i + 1][j + 2] == '1')
cout << "E" << endl;
if (check(i + 2, j + 1) && m[i + 1][j] == '1' && m[i + 1][j + 1] == '1' &&
m[i + 2][j + 1] == '1')
cout << "F" << endl;
if (check(i + 1, j + 2) && check(i - 1, j + 2) && m[i][j + 1] == '1' &&
m[i + 1][j - 1] == '1' && m[i + 1][j] == '1')
cout << "G" << endl;
break;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
#define rrep(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define erep(i, m, n) for (int(i) = (m); (i) <= (n); (i)++)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rev(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define vrep(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
template <class T1, class T2> inline void minup(T1 &m, T2 x) {
if (m > x)
m = static_cast<T2>(x);
}
template <class T1, class T2> inline void maxup(T1 &m, T2 x) {
if (m < x)
m = static_cast<T2>(x);
}
#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12
const int N = 8;
char m[N][N];
inline bool check(int x, int y) { return 0 <= x && x < N && 0 <= y && y < N; }
int main() {
while (true) {
rep(i, N) rep(j, N) if (!(cin >> m[i][j])) return 0;
rep(i, N) rep(j, N) if (m[i][j] == '1') {
if (check(i + 1, j + 1) && m[i + 1][j] == '1' && m[i][j + 1] == '1' &&
m[i + 1][j + 1] == '1')
cout << "A" << endl;
if (check(i + 3, j) && m[i + 1][j] == '1' && m[i + 2][j] == '1' &&
m[i + 3][j] == '1')
cout << "B" << endl;
if (check(i, j + 3) && m[i][j + 1] == '1' && m[i][j + 2] == '1' &&
m[i][j + 3] == '1')
cout << "C" << endl;
if (check(i + 2, j - 1) && m[i + 1][j] == '1' && m[i + 1][j - 1] == '1' &&
m[i + 2][j - 1] == '1')
cout << "D" << endl;
if (check(i + 1, j + 2) && m[i][j + 1] == '1' && m[i + 1][j + 1] == '1' &&
m[i + 1][j + 2] == '1')
cout << "E" << endl;
if (check(i + 2, j + 1) && m[i + 1][j] == '1' && m[i + 1][j + 1] == '1' &&
m[i + 2][j + 1] == '1')
cout << "F" << endl;
if (check(i + 1, j + 1) && check(i + 1, j - 1) && m[i][j + 1] == '1' &&
m[i + 1][j - 1] == '1' && m[i + 1][j] == '1')
cout << "G" << endl;
break;
}
}
return 0;
}
|
[["-", 31, 16, 31, 2, 3, 4, 0, 16, 12, 13], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 12, 13], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 12, 13], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 763
| 8
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
char f[9][9];
while (1) {
bool flag = false;
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (scanf(" %c", &f[i][j]) == EOF) {
flag = true;
break;
}
}
if (flag)
break;
}
if (flag)
break;
bool ans = false;
char c = '1';
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (f[j][i] == c) {
if (i <= 6 && j <= 6 && f[j + 1][i] == c && f[j][i + 1] == c &&
f[j + 1][i + 1] == c) {
printf("A\n");
ans = true;
break;
} else if (j <= 4 && f[j + 1][i] == c && f[j + 2][i] == c &&
f[j + 3][i] == c) {
printf("B\n");
ans = true;
break;
} else if (i <= 4 && f[j][i + 1] == c && f[j][i + 2] == c &&
f[j][i + 3] == c) {
printf("C\n");
ans = true;
break;
} else if (1 <= j && j <= 6 && i <= 6 && f[j + 1][i] == c &&
f[j][i + 1] == c && f[j - 1][i + 1] == c) {
printf("D\n");
ans = true;
break;
} else if (j <= 5 && i <= 6 && f[j][i + 1] == c &&
f[j + 1][i + 1] == c && f[j + 1][i + 2] == c) {
printf("E\n");
ans = true;
break;
} else if (j <= 5 && i <= 6 && f[j + 1][i] == c &&
f[j + 1][i + 1] == c && f[j + 2][i + 1] == c) {
printf("F\n");
ans = true;
break;
} else if (1 <= j && i <= 5 && f[j][i + 1] == c &&
f[j - 1][i + 1] == c && f[j - 1][i + 2] == c) {
printf("G\n");
ans = true;
break;
}
}
}
if (ans)
break;
}
}
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
char f[9][9];
while (1) {
bool flag = false;
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (scanf(" %c", &f[i][j]) == EOF) {
flag = true;
break;
}
}
if (flag)
break;
}
if (flag)
break;
bool ans = false;
char c = '1';
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (f[j][i] == c) {
if (i <= 6 && j <= 6 && f[j + 1][i] == c && f[j][i + 1] == c &&
f[j + 1][i + 1] == c) {
printf("A\n");
ans = true;
break;
} else if (j <= 4 && f[j + 1][i] == c && f[j + 2][i] == c &&
f[j + 3][i] == c) {
printf("B\n");
ans = true;
break;
} else if (i <= 4 && f[j][i + 1] == c && f[j][i + 2] == c &&
f[j][i + 3] == c) {
printf("C\n");
ans = true;
break;
} else if (1 <= j && j <= 6 && i <= 6 && f[j + 1][i] == c &&
f[j][i + 1] == c && f[j - 1][i + 1] == c) {
printf("D\n");
ans = true;
break;
} else if (j <= 6 && i <= 5 && f[j][i + 1] == c &&
f[j + 1][i + 1] == c && f[j + 1][i + 2] == c) {
printf("E\n");
ans = true;
break;
} else if (j <= 5 && i <= 6 && f[j + 1][i] == c &&
f[j + 1][i + 1] == c && f[j + 2][i + 1] == c) {
printf("F\n");
ans = true;
break;
} else if (1 <= j && i <= 5 && f[j][i + 1] == c &&
f[j - 1][i + 1] == c && f[j - 1][i + 2] == c) {
printf("G\n");
ans = true;
break;
}
}
}
if (ans)
break;
}
}
}
|
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 12, 13], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 622
| 4
|
#include <iostream>
#include <string>
using namespace std;
int main() {
while (true) {
int i = 0;
string map[8];
while (cin >> map[i], !cin.eof()) {
i++;
if (i == 8) {
break;
}
}
if (cin.eof()) {
break;
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (i < 7 && j < 7) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i + 1][j] == '1' && map[i + 1][j + 1] == '1') {
cout << 'A' << endl;
}
}
if (i < 5) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 2][j] == '1' && map[i + 3][j] == '1') {
cout << 'B' << endl;
}
}
if (j < 5) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i][j + 2] == '1' && map[i][j + 3] == '1') {
cout << 'C' << endl;
}
}
if (j > 0 && i < 6) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j - 1] == '1' && map[i + 2][j - 1] == '1') {
cout << 'D' << endl;
}
}
if (i < 7 && j < 6) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i + 1][j + 1] == '1' && map[i + 1][j + 2] == '1') {
cout << 'E' << endl;
}
}
if (i < 6 && j < 7) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j + 1] == '1' && map[i + 2][i + 1] == '1') {
cout << 'F' << endl;
}
}
if (i < 7 && j > 1) {
if (map[i][j] == '1' && map[i][j - 1] == '1' &&
map[i + 1][j - 1] == '1' && map[i + 1][j - 2] == '1') {
cout << 'G' << endl;
}
}
}
}
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
while (true) {
int i = 0;
string map[8];
while (cin >> map[i], !cin.eof()) {
i++;
if (i == 8) {
break;
}
}
if (cin.eof()) {
break;
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (i < 7 && j < 7) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i + 1][j] == '1' && map[i + 1][j + 1] == '1') {
cout << 'A' << endl;
}
}
if (i < 5) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 2][j] == '1' && map[i + 3][j] == '1') {
cout << 'B' << endl;
}
}
if (j < 5) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i][j + 2] == '1' && map[i][j + 3] == '1') {
cout << 'C' << endl;
}
}
if (j > 0 && i < 6) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j - 1] == '1' && map[i + 2][j - 1] == '1') {
cout << 'D' << endl;
}
}
if (i < 7 && j < 6) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i + 1][j + 1] == '1' && map[i + 1][j + 2] == '1') {
cout << 'E' << endl;
}
}
if (i < 6 && j < 7) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j + 1] == '1' && map[i + 2][j + 1] == '1') {
cout << 'F' << endl;
}
}
if (i < 7 && j > 1) {
if (map[i][j] == '1' && map[i][j - 1] == '1' &&
map[i + 1][j - 1] == '1' && map[i + 1][j - 2] == '1') {
cout << 'G' << endl;
}
}
}
}
}
return 0;
}
|
[["-", 12, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 31, 22]]
| 1
| 665
| 2
|
#include <bits/stdc++.h>
using namespace std;
double eps = 1e-10;
int main() {
string s[16];
while (cin >> s[0]) {
for (int i = 1; i < 8; ++i) {
cin >> s[i];
}
int h, w;
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (s[i][j] == '1') {
h = i;
w = j;
goto next;
}
}
}
next:;
if (s[h + 1][w] == '1' && s[h][w + 1] == '1' && s[h + 1][w + 1] == '1') {
cout << "A" << endl;
} else if (s[h + 1][w] == '1' && s[h + 2][w] == '1' && s[h + 3][w] == '1') {
cout << "B" << endl;
} else if (s[h][w + 1] == '1' && s[h][w + 2] == '1' && s[h][w + 3] == '1') {
cout << "C" << endl;
} else if (s[h + 1][w - 1] == '1' && s[h + 1][w] == '1' &&
s[h + 2][w - 1] == '1') {
cout << "D" << endl;
} else if (s[h][w + 1] == '1' && s[h + 1][w + 1] == '1' &&
s[h + 1][w + 2] == '1') {
cout << "E" << endl;
} else if (s[h + 1][w] == '1' && s[h + 1][w + 1] == '1' &&
s[h + 2][w + 1] == '1') {
cout << "F" << endl;
} else if (s[h][w + 1] == '1' && s[h + 1][h] == '1' &&
s[h + 1][w - 1] == '1') {
cout << "G" << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double eps = 1e-10;
int main() {
string s[16];
while (cin >> s[0]) {
for (int i = 1; i < 8; ++i) {
cin >> s[i];
}
int h, w;
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (s[i][j] == '1') {
h = i;
w = j;
goto next;
}
}
}
next:;
if (s[h + 1][w] == '1' && s[h][w + 1] == '1' && s[h + 1][w + 1] == '1') {
cout << "A" << endl;
} else if (s[h + 1][w] == '1' && s[h + 2][w] == '1' && s[h + 3][w] == '1') {
cout << "B" << endl;
} else if (s[h][w + 1] == '1' && s[h][w + 2] == '1' && s[h][w + 3] == '1') {
cout << "C" << endl;
} else if (s[h + 1][w - 1] == '1' && s[h + 1][w] == '1' &&
s[h + 2][w - 1] == '1') {
cout << "D" << endl;
} else if (s[h][w + 1] == '1' && s[h + 1][w + 1] == '1' &&
s[h + 1][w + 2] == '1') {
cout << "E" << endl;
} else if (s[h + 1][w] == '1' && s[h + 1][w + 1] == '1' &&
s[h + 2][w + 1] == '1') {
cout << "F" << endl;
} else if (s[h][w + 1] == '1' && s[h + 1][w] == '1' &&
s[h + 1][w - 1] == '1') {
cout << "G" << endl;
}
}
return 0;
}
|
[["-", 31, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 31, 16, 12, 16, 31, 69, 341, 342, 0, 22]]
| 1
| 527
| 2
|
#include <cstdio>
using namespace std;
int main() {
char ch[8][8];
bool judged;
while ((scanf("%s", ch[0])) != EOF) {
for (int i = 1; i < 8; i++) {
scanf("%s", ch[i]);
}
judged = false;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (ch[i][j] == '1') {
// A
if (i + 1 < 8 && ch[i + 1][j] == '1' && j + 1 < 8 &&
ch[i][j + 1] == '1' && ch[i + 1][j + 1] == '1') {
printf("A\n");
judged = true;
break;
}
// B
if (i + 3 < 8 && ch[i + 1][j] == '1' && ch[i + 2][j] == '1' &&
ch[i + 3][j] == '1') {
printf("B\n");
judged = true;
break;
}
// C
if (j + 3 < 8 && ch[i][j + 1] == '1' && ch[i][j + 2] == '1' &&
ch[i][j + 3] == '1') {
printf("C\n");
judged = true;
break;
}
// D
if (i + 2 < 8 && j - 1 >= 0 && ch[i + 1][j - 1] == '1' &&
ch[i + 1][j] == '1' && ch[i + 2][j - 1] == '1') {
printf("D\n");
judged = true;
break;
}
// E
if (i + 1 < 8 && j + 2 < 8 && ch[i][j + 1] == '1' &&
ch[i + 1][j + 1] == '1' && ch[i + 1][j + 2] == '1') {
printf("E\n");
judged = true;
break;
}
// F
if (i + 1 < 8 && j + 2 < 8 && ch[i + 1][j] == '1' &&
ch[i + 1][j + 1] == '1' && ch[i + 2][j + 1] == '1') {
printf("F\n");
judged = true;
break;
}
// G
if (i + 1 < 8 && j + 1 < 8 && j - 1 >= 0 && ch[i + 1][j] == '1' &&
ch[i][j + 1] == '1' && ch[i + 1][j - 1] == '1') {
printf("G\n");
judged = true;
break;
}
}
}
if (judged)
break;
}
}
return 0;
}
|
#include <cstdio>
using namespace std;
int main() {
char ch[10][10];
bool judged;
while ((scanf("%s", ch[0])) != EOF) {
for (int i = 1; i < 8; i++) {
scanf("%s", ch[i]);
}
judged = false;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (ch[i][j] == '1') {
// A
if (i + 1 < 8 && ch[i + 1][j] == '1' && j + 1 < 8 &&
ch[i][j + 1] == '1' && ch[i + 1][j + 1] == '1') {
printf("A\n");
judged = true;
break;
}
// B
if (i + 3 < 8 && ch[i + 1][j] == '1' && ch[i + 2][j] == '1' &&
ch[i + 3][j] == '1') {
printf("B\n");
judged = true;
break;
}
// C
if (j + 3 < 8 && ch[i][j + 1] == '1' && ch[i][j + 2] == '1' &&
ch[i][j + 3] == '1') {
printf("C\n");
judged = true;
break;
}
// D
if (i + 2 < 8 && j - 1 >= 0 && ch[i + 1][j - 1] == '1' &&
ch[i + 1][j] == '1' && ch[i + 2][j - 1] == '1') {
printf("D\n");
judged = true;
break;
}
// E
if (i + 1 < 8 && j + 2 < 8 && ch[i][j + 1] == '1' &&
ch[i + 1][j + 1] == '1' && ch[i + 1][j + 2] == '1') {
printf("E\n");
judged = true;
break;
}
// F
if (i + 2 < 8 && j + 1 < 8 && ch[i + 1][j] == '1' &&
ch[i + 1][j + 1] == '1' && ch[i + 2][j + 1] == '1') {
printf("F\n");
judged = true;
break;
}
// G
if (i + 1 < 8 && j + 1 < 8 && j - 1 >= 0 && ch[i + 1][j] == '1' &&
ch[i][j + 1] == '1' && ch[i + 1][j - 1] == '1') {
printf("G\n");
judged = true;
break;
}
}
}
if (judged)
break;
}
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["-", 31, 16, 31, 16, 12, 16, 31, 16, 12, 13], ["+", 31, 16, 31, 16, 12, 16, 31, 16, 12, 13]]
| 1
| 654
| 8
|
#include <iostream>
#include <string>
using namespace std;
bool check(int (&field)[8][8], int x, int y) {
if (x < 0 || x >= 8 || y < 0 || y >= 8 || (field[y][x] == 0)) {
return false;
}
return true;
}
int main() {
int inptf[8][8] = {0}, i, j, x, y;
string str;
char btype;
while (true) {
i = 0;
while (cin >> str) {
for (j = 0; j < 8; j++) {
inptf[i][j] = str[j] - '0';
}
i++;
if (i == 8)
break;
}
if (i < 8)
break;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (inptf[i][j] != 0) {
y = i;
x = j;
i = j = 8;
}
}
}
if (check(inptf, x, y) && //[][] A
check(inptf, x, y + 1) && //[][]
check(inptf, x + 1, y) && check(inptf, x + 1, y + 1))
btype = 'A';
if (check(inptf, x, y) && //[] B
check(inptf, x, y + 1) && //[]
check(inptf, x, y + 2) && //[]
check(inptf, x, y + 3)) //[]
btype = 'B';
if (check(inptf, x, y) && //[][][][] C
check(inptf, x + 1, y) && check(inptf, x + 2, y) &&
check(inptf, x + 3, y))
btype = 'C';
if (check(inptf, x, y) && // [] D
check(inptf, x, y + 1) && //[][]
check(inptf, x - 1, y + 1) && //[]
check(inptf, x - 1, y + 2))
btype = 'D';
if (check(inptf, x, y) && //[][] E
check(inptf, x + 1, y) && // [][]
check(inptf, x + 1, y + 1) && check(inptf, x + 2, y + 1))
btype = 'E';
if (check(inptf, x, y) && //[] F
check(inptf, x, y + 1) && //[][]
check(inptf, x + 1, y + 1) && // []
check(inptf, x + 1, y + 2))
btype = 'F';
if (check(inptf, x, y) && // [][]G
check(inptf, x + 1, y) && //[][]
check(inptf, x, y + 1) && check(inptf, x - 1, y + 1))
btype = 'F';
cout << btype << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
bool check(int (&field)[8][8], int x, int y) {
if (x < 0 || x >= 8 || y < 0 || y >= 8 || (field[y][x] == 0)) {
return false;
}
return true;
}
int main() {
int inptf[8][8] = {0}, i, j, x, y;
string str;
char btype;
while (true) {
i = 0;
while (cin >> str) {
for (j = 0; j < 8; j++) {
inptf[i][j] = str[j] - '0';
}
i++;
if (i == 8)
break;
}
if (i < 8)
break;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (inptf[i][j] != 0) {
y = i;
x = j;
i = j = 8;
}
}
}
if (check(inptf, x, y) && //[][] A
check(inptf, x, y + 1) && //[][]
check(inptf, x + 1, y) && check(inptf, x + 1, y + 1))
btype = 'A';
if (check(inptf, x, y) && //[] B
check(inptf, x, y + 1) && //[]
check(inptf, x, y + 2) && //[]
check(inptf, x, y + 3)) //[]
btype = 'B';
if (check(inptf, x, y) && //[][][][] C
check(inptf, x + 1, y) && check(inptf, x + 2, y) &&
check(inptf, x + 3, y))
btype = 'C';
if (check(inptf, x, y) && // [] D
check(inptf, x, y + 1) && //[][]
check(inptf, x - 1, y + 1) && //[]
check(inptf, x - 1, y + 2))
btype = 'D';
if (check(inptf, x, y) && //[][] E
check(inptf, x + 1, y) && // [][]
check(inptf, x + 1, y + 1) && check(inptf, x + 2, y + 1))
btype = 'E';
if (check(inptf, x, y) && //[] F
check(inptf, x, y + 1) && //[][]
check(inptf, x + 1, y + 1) && // []
check(inptf, x + 1, y + 2))
btype = 'F';
if (check(inptf, x, y) && // [][]G
check(inptf, x + 1, y) && //[][]
check(inptf, x, y + 1) && check(inptf, x - 1, y + 1))
btype = 'G';
cout << btype << endl;
}
}
|
[["-", 0, 57, 64, 1, 0, 11, 12, 103, 0, 125], ["+", 0, 57, 64, 1, 0, 11, 12, 103, 0, 125]]
| 1
| 618
| 2
|
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
char p[8][9];
int i, j;
while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
for (i = 0; i < 8; ++i) {
for (j = 0; j < 9; ++j) {
if (p[i][j] == '1')
goto next;
}
}
next:
if (p[i][j + 1] == '1' && p[i + 1][j] == '1' && p[i + 1][j + 1] == '1')
cout << 'A' << endl;
else if (p[i + 1][j] == '1' && p[i + 2][j] == '1' && p[i + 3][j] == '1')
cout << 'B' << endl;
else if (p[i][j + 1] == '1' && p[i][j + 2] == '1' && p[i][j + 3] == '1')
cout << 'C' << endl;
else if (p[i + 1][j] == '1' && p[i + 1][j - 1] == '1' &&
p[i + 2][j - 1] == '1')
cout << 'D' << endl;
else if (p[i][j + 1] == '1' && p[i + 1][j + 1] == '1' &&
p[i + 1][j + 2] == '1')
cout << 'E' << endl;
else if (p[i + 1][j] == '1' && p[i + 1][j + 1] == '1' &&
p[i + 2][j + 1] == '1')
cout << 'F' << endl;
else if (p[i][j + 1] == '1' && p[i + 1][j + 1] == '1' &&
p[i + 1][j - 1] == '1')
cout << 'G' << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
char p[8][9];
int i, j;
while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
for (i = 0; i < 8; ++i) {
for (j = 0; j < 9; ++j) {
if (p[i][j] == '1')
goto next;
}
}
next:
if (p[i][j + 1] == '1' && p[i + 1][j] == '1' && p[i + 1][j + 1] == '1')
cout << 'A' << endl;
else if (p[i + 1][j] == '1' && p[i + 2][j] == '1' && p[i + 3][j] == '1')
cout << 'B' << endl;
else if (p[i][j + 1] == '1' && p[i][j + 2] == '1' && p[i][j + 3] == '1')
cout << 'C' << endl;
else if (p[i + 1][j] == '1' && p[i + 1][j - 1] == '1' &&
p[i + 2][j - 1] == '1')
cout << 'D' << endl;
else if (p[i][j + 1] == '1' && p[i + 1][j + 1] == '1' &&
p[i + 1][j + 2] == '1')
cout << 'E' << endl;
else if (p[i + 1][j] == '1' && p[i + 1][j + 1] == '1' &&
p[i + 2][j + 1] == '1')
cout << 'F' << endl;
else if (p[i][j + 1] == '1' && p[i + 1][j] == '1' && p[i + 1][j - 1] == '1')
cout << 'G' << endl;
}
return 0;
}
|
[["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 526
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char str[20][20];
while (1) {
for (int i = 4; i < 12; i++) {
for (int j = 4; j < 12; j++) {
cin >> str[i][j];
if (cin.eof())
return 0;
}
}
char ans;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (str[i][j] == '1' && str[i][j + 1] == '1' && str[i + 1][j] == '1' &&
str[i + 1][j + 1] == '1')
ans = 'A';
else if (str[i][j] == '1' && str[i + 1][j] == '1' &&
str[i + 2][j] == '1' && str[i + 3][j] == '1')
ans = 'B';
else if (str[i][j] == '1' && str[i][j + 1] == '1' &&
str[i][j + 2] == '1' && str[i][j + 3] == '1')
ans = 'C';
else if (str[i][j] == '1' && str[i + 1][j - 1] == '1' &&
str[i + 1][j] == '1' && str[i + 2][j - 1] == '1')
ans = 'D';
else if (str[i][j] == '1' && str[i][j + 1] == '1' &&
str[i + 1][j + 1] == '1' && str[i + 1][j + 2] == '1')
ans = 'E';
else if (str[i][j] == '1' && str[i + 1][j] == '1' &&
str[i + 1][j + 1] == '1' && str[i + 2][j + 1] == '1')
ans = 'F';
else if (str[i][j] == '1' && str[i][j + 1] == '1' &&
str[i + 1][j - 1] == '1' && str[i + 1][j] == '1')
ans = 'G';
}
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char str[20][20];
while (1) {
for (int i = 4; i < 12; i++) {
for (int j = 4; j < 12; j++) {
cin >> str[i][j];
if (cin.eof())
return 0;
}
}
char ans;
for (int i = 4; i < 12; i++) {
for (int j = 4; j < 12; j++) {
if (str[i][j] == '1' && str[i][j + 1] == '1' && str[i + 1][j] == '1' &&
str[i + 1][j + 1] == '1')
ans = 'A';
else if (str[i][j] == '1' && str[i + 1][j] == '1' &&
str[i + 2][j] == '1' && str[i + 3][j] == '1')
ans = 'B';
else if (str[i][j] == '1' && str[i][j + 1] == '1' &&
str[i][j + 2] == '1' && str[i][j + 3] == '1')
ans = 'C';
else if (str[i][j] == '1' && str[i + 1][j - 1] == '1' &&
str[i + 1][j] == '1' && str[i + 2][j - 1] == '1')
ans = 'D';
else if (str[i][j] == '1' && str[i][j + 1] == '1' &&
str[i + 1][j + 1] == '1' && str[i + 1][j + 2] == '1')
ans = 'E';
else if (str[i][j] == '1' && str[i + 1][j] == '1' &&
str[i + 1][j + 1] == '1' && str[i + 2][j + 1] == '1')
ans = 'F';
else if (str[i][j] == '1' && str[i][j + 1] == '1' &&
str[i + 1][j - 1] == '1' && str[i + 1][j] == '1')
ans = 'G';
}
}
cout << ans << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 580
| 8
|
#include <iostream>
#include <string>
using namespace std;
string table[8];
bool range(int y, int x) {
if (y < 0 || x < 0 || y >= 8 || x >= 8)
return false;
return true;
}
bool A(int y, int x) {
int dx[] = {0, 1, 1, 0};
int dy[] = {0, 0, 1, 1};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool B(int y, int x) {
int dx[] = {0, 0, 0, 0};
int dy[] = {0, 1, 2, 3};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool C(int y, int x) {
int dx[] = {0, 1, 2, 3};
int dy[] = {0, 0, 0, 0};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool D(int y, int x) {
int dx[] = {0, 0, -1, -1};
int dy[] = {0, 1, 1, 2};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool E(int y, int x) {
int dx[] = {0, 1, 1, 2};
int dy[] = {0, 0, 1, 1};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool F(int y, int x) {
int dx[] = {0, 0, 1, 1};
int dy[] = {0, 1, 1, 2};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool G(int y, int x) {
int dx[] = {0, 1, 0, -1};
int dy[] = {0, 0, -1, -1};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
char check(int y, int x) {
if (A(y, x))
return 'A';
else if (B(y, x))
return 'B';
else if (C(y, x))
return 'C';
else if (D(y, x))
return 'D';
else if (E(y, x))
return 'E';
else if (F(y, x))
return 'F';
else if (G(y, x))
return 'G';
else
return 0;
}
int main() {
while (true) {
for (int i = 0; i < 8; i++) {
if (!(cin >> table[i]))
return 0;
}
bool find = false;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
int ret = check(i, j);
if (ret > 0) {
find = true;
cout << ((char)ret) << endl;
break;
}
}
if (find)
break;
}
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
string table[8];
bool range(int y, int x) {
if (y < 0 || x < 0 || y >= 8 || x >= 8)
return false;
return true;
}
bool A(int y, int x) {
int dx[] = {0, 1, 1, 0};
int dy[] = {0, 0, 1, 1};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool B(int y, int x) {
int dx[] = {0, 0, 0, 0};
int dy[] = {0, 1, 2, 3};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool C(int y, int x) {
int dx[] = {0, 1, 2, 3};
int dy[] = {0, 0, 0, 0};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool D(int y, int x) {
int dx[] = {0, 0, -1, -1};
int dy[] = {0, 1, 1, 2};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool E(int y, int x) {
int dx[] = {0, 1, 1, 2};
int dy[] = {0, 0, 1, 1};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool F(int y, int x) {
int dx[] = {0, 0, 1, 1};
int dy[] = {0, 1, 1, 2};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
bool G(int y, int x) {
int dx[] = {0, 1, 0, -1};
int dy[] = {0, 0, 1, 1};
for (int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
if (range(ny, nx) && table[ny][nx] == '1')
continue;
return false;
}
return true;
}
char check(int y, int x) {
if (A(y, x))
return 'A';
else if (B(y, x))
return 'B';
else if (C(y, x))
return 'C';
else if (D(y, x))
return 'D';
else if (E(y, x))
return 'E';
else if (F(y, x))
return 'F';
else if (G(y, x))
return 'G';
else
return 0;
}
int main() {
while (true) {
for (int i = 0; i < 8; i++) {
if (!(cin >> table[i]))
return 0;
}
bool find = false;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
int ret = check(i, j);
if (ret > 0) {
find = true;
cout << ((char)ret) << endl;
break;
}
}
if (find)
break;
}
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
| 1
| 1,034
| 4
|
#include <cstdio>
#include <iostream>
using namespace std;
bool map[8][8];
char Solve(int x, int y) {
if (x != 7 && map[y][x + 1] == 1 && y != 7 && map[y + 1][x] == 1 &&
map[y + 1][x + 1] == 1)
return 'A';
else if (y <= 4 && map[y + 1][x] == 1 && map[y + 2][x] == 1 &&
map[y + 3][x] == 1)
return 'B';
else if (x <= 4 && map[y][x + 1] == 1 && map[y][x + 2] == 1 &&
map[y][x + 3] == 1)
return 'C';
else if (x > 0 && y <= 5 && map[y - 1][x] == 1 && map[y - 1][x - 1] == 1 &&
map[y - 2][x - 1] == 1)
return 'D';
else if (y < 7 && x <= 5 && map[y][x + 1] == 1 && map[y + 1][x + 1] == 1 &&
map[y + 1][x + 2] == 1)
return 'E';
else if (x < 7 && y <= 5 && map[y - 1][x] == 1 && map[y - 1][x + 1] == 1 &&
map[y - 2][x + 1] == 1)
return 'F';
else
return 'G';
}
int main() {
char c;
while (cin >> c) {
map[0][0] = c - '0';
for (int i = 1; i < 8; i++) {
cin >> c;
map[0][i] = c - '0';
}
for (int i = 1; i < 8; i++)
for (int j = 0; j < 8; j++) {
cin >> c;
map[i][j] = c - '0';
}
int i, j;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (map[i][j] == true)
goto BREAK;
}
}
BREAK:;
// for(int m=0;m<8;m++){for(int n=0;n<8;n++)cout<<map[m][n];cout<<endl;}
cout << Solve(j, i) << endl;
// getchar();
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
bool map[8][8];
char Solve(int x, int y) {
if (x != 7 && map[y][x + 1] == 1 && y != 7 && map[y + 1][x] == 1 &&
map[y + 1][x + 1] == 1)
return 'A';
else if (y <= 4 && map[y + 1][x] == 1 && map[y + 2][x] == 1 &&
map[y + 3][x] == 1)
return 'B';
else if (x <= 4 && map[y][x + 1] == 1 && map[y][x + 2] == 1 &&
map[y][x + 3] == 1)
return 'C';
else if (x > 0 && y <= 5 && map[y + 1][x] == 1 && map[y + 1][x - 1] == 1 &&
map[y + 2][x - 1] == 1)
return 'D';
else if (y < 7 && x <= 5 && map[y][x + 1] == 1 && map[y + 1][x + 1] == 1 &&
map[y + 1][x + 2] == 1)
return 'E';
else if (x < 7 && y <= 5 && map[y + 1][x] == 1 && map[y + 1][x + 1] == 1 &&
map[y + 2][x + 1] == 1)
return 'F';
else
return 'G';
}
int main() {
char c;
while (cin >> c) {
map[0][0] = c - '0';
for (int i = 1; i < 8; i++) {
cin >> c;
map[0][i] = c - '0';
}
for (int i = 1; i < 8; i++)
for (int j = 0; j < 8; j++) {
cin >> c;
map[i][j] = c - '0';
}
int i, j;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (map[i][j] == true)
goto BREAK;
}
}
BREAK:;
// for(int m=0;m<8;m++){for(int n=0;n<8;n++)cout<<map[m][n];cout<<endl;}
cout << Solve(j, i) << endl;
// getchar();
}
return 0;
}
|
[["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72]]
| 1
| 533
| 12
|
#include <iostream>
#include <string>
using namespace std;
string s[10];
int main() {
while (1) {
int t = 0;
int r = 0;
bool flag = false;
for (int i = 0; i < 9; i++) {
if (!(cin >> s[i]))
return 0;
}
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (s[i][j] == '1') {
if (flag == false) {
t = 8 * i + j;
flag = true;
};
r += 8 * i + j;
}
}
}
r -= 4 * t;
if (r == 19)
cout << 'A' << endl;
else if (r == 48)
cout << 'B' << endl;
else if (r == 6)
cout << 'C' << endl;
else if (r == 30)
cout << 'D' << endl;
else if (r == 20)
cout << 'E' << endl;
else if (r == 34)
cout << 'F' << endl;
else if (r == 16)
cout << 'G' << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
string s[10];
int main() {
while (1) {
int t = 0;
int r = 0;
bool flag = false;
for (int i = 0; i < 8; i++) {
if (!(cin >> s[i]))
return 0;
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (s[i][j] == '1') {
if (flag == false) {
t = 8 * i + j;
flag = true;
};
r += 8 * i + j;
}
}
}
r -= 4 * t;
if (r == 18)
cout << 'A' << endl;
else if (r == 48)
cout << 'B' << endl;
else if (r == 6)
cout << 'C' << endl;
else if (r == 30)
cout << 'D' << endl;
else if (r == 20)
cout << 'E' << endl;
else if (r == 34)
cout << 'F' << endl;
else if (r == 16)
cout << 'G' << endl;
}
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 259
| 8
|
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
std::string ans[7] = {"1100000011", "1000000010000000100000001",
"1111", "1000000110000001",
"11000000011", "100000001100000001",
"110000011"};
std::string alpha[7] = {"A", "B", "C", "D", "E", "F", "G"};
std::string prob[8];
std::string problem;
while (std::cin >> prob[0]) {
for (int a = 1; a < 8; a++) {
std::cin >> prob[a];
}
for (int b = 0; b < 8; b++) {
problem = problem + prob[b];
}
for (int c = 0; c < 7; c++) {
std::string::size_type index = problem.find(ans[c]);
if (index != std::string::npos) {
std::cout << alpha[c] << std::endl;
}
}
}
}
|
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
std::string ans[7] = {"1100000011", "1000000010000000100000001",
"1111", "1000000110000001",
"11000000011", "100000001100000001",
"110000011"};
std::string alpha[7] = {"A", "B", "C", "D", "E", "F", "G"};
std::string prob[8];
std::string problem;
while (std::cin >> prob[0]) {
for (int a = 1; a < 8; a++) {
std::cin >> prob[a];
}
for (int b = 0; b < 8; b++) {
problem = problem + prob[b];
}
for (int c = 0; c < 7; c++) {
std::string::size_type index = problem.find(ans[c]);
if (index != std::string::npos) {
std::cout << alpha[c] << std::endl;
}
}
problem = "";
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 228
| 5
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define For(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v) \
for (int i = 0; i < (n); i++) { \
int j; \
cin >> j; \
v.push_back(j); \
}
bool hasA(int bd[8][8]) {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (bd[i][j] && bd[i][j + 1] && bd[i + 1][j] && bd[i + 1][j + 1])
return true;
}
}
return false;
}
bool hasB(int bd[8][8]) {
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 8; j++) {
if (bd[i][j] && bd[i + 1][j] && bd[i + 2][j] && bd[i + 3][j])
return true;
}
}
return false;
}
bool hasC(int bd[8][8]) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 5; j++) {
if (bd[i][j] && bd[i][j + 1] && bd[i][j + 2] && bd[i][j + 3])
return true;
}
}
return false;
}
bool hasD(int bd[8][8]) {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
if (bd[i][j + 1] && bd[i + 1][j] && bd[i + 1][j + 1] && bd[i + 2][j])
return true;
}
}
return false;
}
bool hasE(int bd[8][8]) {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 6; j++) {
if (bd[i][j] && bd[i][j + 1] && bd[i + 1][j + 1] && bd[i + 1][j + 2])
return true;
}
}
return false;
}
bool hasF(int bd[8][8]) {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
if (bd[i][j] && bd[i + 1][j] && bd[i + 1][j + 1] && bd[i + 2][j + 1])
return true;
}
}
return false;
}
bool hasG(int bd[8][8]) {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 6; j++) {
if (bd[i][j + 1] && bd[i][j + 2] && bd[i + 1][j] && bd[i + 1][j + 1])
return true;
}
}
return false;
}
int main() {
string s;
int bd[8][8];
while (cin >> s) {
REP(i, 8) bd[0][i] = s[i] - '0';
REP(j, 7) {
cin >> s;
REP(i, 8) bd[j + 1][i] = s[i] - '0';
}
// input ends
if (hasA(bd))
cout << "A" << endl;
else if (hasB(bd))
cout << "B" << endl;
else if (hasC(bd))
cout << "C" << endl;
else if (hasD(bd))
cout << "D" << endl;
else if (hasE(bd))
cout << "E" << endl;
else if (hasF(bd))
cout << "F" << endl;
else if (hasG(bd))
cout << "G" << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define For(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v) \
for (int i = 0; i < (n); i++) { \
int j; \
cin >> j; \
v.push_back(j); \
}
bool hasA(int bd[8][8]) {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (bd[i][j] && bd[i][j + 1] && bd[i + 1][j] && bd[i + 1][j + 1])
return true;
}
}
return false;
}
bool hasB(int bd[8][8]) {
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 8; j++) {
if (bd[i][j] && bd[i + 1][j] && bd[i + 2][j] && bd[i + 3][j])
return true;
}
}
return false;
}
bool hasC(int bd[8][8]) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 5; j++) {
if (bd[i][j] && bd[i][j + 1] && bd[i][j + 2] && bd[i][j + 3])
return true;
}
}
return false;
}
bool hasD(int bd[8][8]) {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
if (bd[i][j + 1] && bd[i + 1][j] && bd[i + 1][j + 1] && bd[i + 2][j])
return true;
}
}
return false;
}
bool hasE(int bd[8][8]) {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 6; j++) {
if (bd[i][j] && bd[i][j + 1] && bd[i + 1][j + 1] && bd[i + 1][j + 2])
return true;
}
}
return false;
}
bool hasF(int bd[8][8]) {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
if (bd[i][j] && bd[i + 1][j] && bd[i + 1][j + 1] && bd[i + 2][j + 1])
return true;
}
}
return false;
}
bool hasG(int bd[8][8]) {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 6; j++) {
if (bd[i][j + 1] && bd[i][j + 2] && bd[i + 1][j] && bd[i + 1][j + 1])
return true;
}
}
return false;
}
int main() {
string s;
int bd[8][8];
while (cin >> s) {
REP(i, 8) bd[0][i] = s[i] - '0';
REP(j, 7) {
cin >> s;
REP(i, 8) bd[j + 1][i] = s[i] - '0';
}
// input ends
if (hasA(bd))
cout << "A" << endl;
else if (hasB(bd))
cout << "B" << endl;
else if (hasC(bd))
cout << "C" << endl;
else if (hasD(bd))
cout << "D" << endl;
else if (hasE(bd))
cout << "E" << endl;
else if (hasF(bd))
cout << "F" << endl;
else if (hasG(bd))
cout << "G" << endl;
}
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 913
| 4
|
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define DBG 1
#define dump(o) \
if (DBG) { \
cerr << #o << " " << o << endl; \
}
#define dumpc(o) \
if (DBG) { \
cerr << #o; \
for (auto &e : (o)) \
cerr << " " << e; \
cerr << endl; \
}
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++)
#define all(c) c.begin(), c.end()
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
signed main() {
string s;
while (cin >> s) {
vector<string> v;
v.push_back(s);
rep(i, 0, 7) {
string t;
cin >> t;
v.push_back(t);
}
char ans;
rep(i, 0, 8) {
rep(j, 0, 8) {
if (v[i][j] == '1') {
if (j + 1 < 8 && i + 1 < 8 && v[i][j + 1] == '1' &&
v[i + 1][j] == '1' && v[i + 1][j + 1] == '1')
ans = 'A';
else if (i + 3 < 8 && v[i + 1][j] == '1' && v[i + 2][j] == '1' &&
v[i + 3][j] == '1')
ans = 'B';
else if (j + 3 < 8 && v[i][j + 1] == '1' && v[i][j + 2] == '1' &&
v[i][j + 3] == '1')
ans = 'C';
else if (i + 1 < 8 && j + 2 < 8 && v[i][j + 1] == '1' &&
v[i + 1][j + 1] == '1' && v[i + 1][j + 2] == '1')
ans = 'E';
else if (i + 2 < 8 && j + 1 < 8 && v[i + 1][j] == '1' &&
v[i + 1][j + 1] == '1' && v[i + 2][j + 1] == '1')
ans = 'F';
else if (i + 2 < 8 && j - 1 >= 0 && v[i + 1][j] == '1' &&
v[i + 1][j - 1] == '1' && v[i + 2][j - 1] == '1')
ans = 'D';
else if (i - 1 >= 0 && i + 1 < 8 && j + 1 < 8 && v[i][j + 1] == '1' &&
v[i + 1][j] == '1' && v[i - 1][j - 1] == '1')
ans = 'G';
goto here;
}
}
}
here:;
cout << ans << endl;
}
return 0;
}
|
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define DBG 1
#define dump(o) \
if (DBG) { \
cerr << #o << " " << o << endl; \
}
#define dumpc(o) \
if (DBG) { \
cerr << #o; \
for (auto &e : (o)) \
cerr << " " << e; \
cerr << endl; \
}
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++)
#define all(c) c.begin(), c.end()
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
signed main() {
string s;
while (cin >> s) {
vector<string> v;
v.push_back(s);
rep(i, 0, 7) {
string t;
cin >> t;
v.push_back(t);
}
char ans;
rep(i, 0, 8) {
rep(j, 0, 8) {
if (v[i][j] == '1') {
if (j + 1 < 8 && i + 1 < 8 && v[i][j + 1] == '1' &&
v[i + 1][j] == '1' && v[i + 1][j + 1] == '1')
ans = 'A';
else if (i + 3 < 8 && v[i + 1][j] == '1' && v[i + 2][j] == '1' &&
v[i + 3][j] == '1')
ans = 'B';
else if (j + 3 < 8 && v[i][j + 1] == '1' && v[i][j + 2] == '1' &&
v[i][j + 3] == '1')
ans = 'C';
else if (i + 1 < 8 && j + 2 < 8 && v[i][j + 1] == '1' &&
v[i + 1][j + 1] == '1' && v[i + 1][j + 2] == '1')
ans = 'E';
else if (i + 2 < 8 && j + 1 < 8 && v[i + 1][j] == '1' &&
v[i + 1][j + 1] == '1' && v[i + 2][j + 1] == '1')
ans = 'F';
else if (i + 2 < 8 && j - 1 >= 0 && v[i + 1][j] == '1' &&
v[i + 1][j - 1] == '1' && v[i + 2][j - 1] == '1')
ans = 'D';
else if (j - 1 >= 0 && j + 1 < 8 && i + 1 < 8 && v[i][j + 1] == '1' &&
v[i + 1][j] == '1' && v[i + 1][j - 1] == '1')
ans = 'G';
goto here;
}
}
}
here:;
cout << ans << endl;
}
return 0;
}
|
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 31, 16, 31, 16, 12, 16, 31, 16, 31, 22], ["+", 31, 16, 31, 16, 12, 16, 31, 16, 31, 22], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72]]
| 1
| 655
| 8
|
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for (int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for (int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
char s[10][10];
int main() {
while (cin >> s[0]) {
FOR(i, 1, 8) cin >> s[i];
rep(i, 8) rep(j, 8) if (s[i][j] == '1') {
if (s[i][j + 1] == '1') {
if (s[i + 1][j] == '1' && s[i + 1][j + 1] == '1') {
printf("A\n");
goto end;
} else if (s[i + 1][j + 1] == '1' && s[i + 1][j + 2] == '1') {
printf("E\n");
goto end;
} else if (s[i][j + 2] == '1' && s[i][j + 3] == '1') {
printf("C\n");
goto end;
} else {
printf("G\n");
goto end;
}
} else {
if (s[i - 1][j - 1] == '1' && s[i + 1][j] == '1' &&
s[i + 2][j - 1] == '1') {
printf("D\n");
goto end;
} else if (s[i + 1][j] == '1' && s[i + 1][j + 1] == '1' &&
s[i + 2][j + 1] == '1') {
printf("F\n");
goto end;
} else {
printf("B\n");
goto end;
}
}
}
end:;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for (int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for (int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
char s[10][10];
int main() {
while (cin >> s[0]) {
FOR(i, 1, 8) cin >> s[i];
rep(i, 8) rep(j, 8) if (s[i][j] == '1') {
if (s[i][j + 1] == '1') {
if (s[i + 1][j] == '1' && s[i + 1][j + 1] == '1') {
printf("A\n");
goto end;
} else if (s[i + 1][j + 1] == '1' && s[i + 1][j + 2] == '1') {
printf("E\n");
goto end;
} else if (s[i][j + 2] == '1' && s[i][j + 3] == '1') {
printf("C\n");
goto end;
} else {
printf("G\n");
goto end;
}
} else {
if (s[i + 1][j - 1] == '1' && s[i + 1][j] == '1' &&
s[i + 2][j - 1] == '1') {
printf("D\n");
goto end;
} else if (s[i + 1][j] == '1' && s[i + 1][j + 1] == '1' &&
s[i + 2][j + 1] == '1') {
printf("F\n");
goto end;
} else {
printf("B\n");
goto end;
}
}
}
end:;
}
return 0;
}
|
[["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72]]
| 1
| 425
| 2
|
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main(void) {
string s[8];
while (cin >> s[0]) {
std::vector<pair<int, int>> v;
for (int i = 1; i < 8; i++)
cin >> s[i];
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (s[i][j] == '1')
v.push_back(make_pair(i, j));
}
}
// second=x,first=y
if (v[0].first == v[1].first && v[0].second == v[2].second)
cout << "A" << endl;
else if (v[0].second == v[1].second && v[2].second == v[1].second &&
v[2].second == v[3].second)
cout << "B" << endl;
else if (v[2].first == v[0].first)
cout << "C" << endl;
else if (make_pair(v[0].first + 2, v[0].second - 1) == v[3])
cout << "D" << endl;
else if (make_pair(v[0].first + 1, v[0].second + 2) == v[3])
cout << "E" << endl;
else if (make_pair(v[9].first + 2, v[0].second + 1) == v[3])
cout << "F" << endl;
else
cout << "G" << endl;
// cin>>s[0]; // CRLF
}
}
|
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main(void) {
string s[8];
while (cin >> s[0]) {
std::vector<pair<int, int>> v;
for (int i = 1; i < 8; i++)
cin >> s[i];
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (s[i][j] == '1')
v.push_back(make_pair(i, j));
}
}
// second=x,first=y
if (v[0].first == v[1].first && v[0].second == v[2].second)
cout << "A" << endl;
else if (v[0].second == v[1].second && v[2].second == v[1].second &&
v[2].second == v[3].second)
cout << "B" << endl;
else if (v[2].first == v[0].first)
cout << "C" << endl;
else if (make_pair(v[0].first + 2, v[0].second - 1) == v[3])
cout << "D" << endl;
else if (make_pair(v[0].first + 1, v[0].second + 2) == v[3])
cout << "E" << endl;
else if (make_pair(v[0].first + 2, v[0].second + 1) == v[3])
cout << "F" << endl;
else
cout << "G" << endl;
// cin>>s[0]; // CRLF
}
}
|
[["-", 0, 16, 31, 118, 28, 69, 341, 342, 0, 13], ["+", 0, 16, 31, 118, 28, 69, 341, 342, 0, 13]]
| 1
| 366
| 2
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
int main() {
while (true) {
string a[8];
vector<int> tracex;
vector<int> tracey;
bool flag = false;
rep(i, 8) if (!(cin >> a[i])) return 0;
rep(i, 8) rep(j, 8) if (a[i][j] == '1') {
tracex.push_back(j);
tracey.push_back(i);
}
REP(i, 1, tracex.size())
tracex[i] -= tracex[0];
REP(i, 1, tracey.size())
tracey[i] -= tracey[0];
// tracex[0]=0;tracey[0]=0;
if (tracex[3] == 1 && tracey[3] == 1)
cout << "A" << endl;
if (tracex[3] == 3)
cout << "C" << endl;
if (tracey[3] == 3)
cout << "B" << endl;
if (tracex[1] == -1 && tracey[3] == 2)
cout << "D" << endl;
if (tracex[3] == 2)
cout << "E" << endl;
if (tracex[1] == 1 && tracey[3] == 2)
cout << "F" << endl;
if (tracex[2] == -1 && tracey[2] == 1)
cout << "G" << endl;
if (flag)
break;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
int main() {
while (true) {
string a[8];
vector<int> tracex;
vector<int> tracey;
bool flag = false;
rep(i, 8) if (!(cin >> a[i])) return 0;
rep(i, 8) rep(j, 8) if (a[i][j] == '1') {
tracex.push_back(j);
tracey.push_back(i);
}
REP(i, 1, tracex.size())
tracex[i] -= tracex[0];
REP(i, 1, tracey.size())
tracey[i] -= tracey[0];
// tracex[0]=0;tracey[0]=0;
if (tracex[3] == 1 && tracey[3] == 1)
cout << "A" << endl;
if (tracex[3] == 3)
cout << "C" << endl;
if (tracey[3] == 3)
cout << "B" << endl;
if (tracex[1] == -1 && tracey[3] == 2)
cout << "D" << endl;
if (tracex[3] == 2)
cout << "E" << endl;
if (tracex[2] == 1 && tracey[3] == 2)
cout << "F" << endl;
if (tracex[2] == -1 && tracey[2] == 1)
cout << "G" << endl;
if (flag)
break;
}
return 0;
}
|
[["-", 51, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["+", 51, 16, 31, 16, 31, 69, 341, 342, 0, 13]]
| 1
| 341
| 2
|
#include <array>
#include <iostream>
using namespace std;
char checkData(array<int, 4> data_i, array<int, 4> data_j) {
int i = 0, j = 0;
if (data_i[i] + 1 == data_i[i + 1] && data_j[j] == data_j[j + 1] &&
data_i[i] == data_i[i + 2] && data_j[j] + 1 == data_j[i + 2] &&
data_i[i] + 1 == data_i[j + 3] && data_j[j] + 1 == data_j[j + 3]) {
return 'A';
} else if (data_i[i] == data_i[i + 1] && data_j[j] + 1 == data_j[j + 1] &&
data_i[i] == data_i[i + 2] && data_j[j] + 2 == data_j[j + 2] &&
data_i[i] == data_i[i + 3] && data_j[j] + 3 == data_j[j + 3]) {
return 'B';
} else if (data_i[i] + 1 == data_i[i + 1] && data_j[j] == data_j[j + 1] &&
data_i[i] + 2 == data_i[i + 2] && data_j[j] == data_j[j + 2] &&
data_i[i] + 3 == data_i[j + 3] && data_j[j] == data_j[j + 3]) {
return 'C';
} else if (data_i[i] - 1 == data_i[i + 1] && data_j[j] + 1 == data_j[j + 1] &&
data_i[i] == data_i[i + 2] && data_j[j] + 1 == data_j[j + 2] &&
data_i[i] - 1 == data_i[i + 3] && data_j[j] + 2 == data_j[j + 3]) {
return 'D';
} else if (data_i[i] + 1 == data_i[i + 1] && data_j[j] == data_j[j + 1] &&
data_i[i] + 1 == data_i[i + 2] && data_j[j] + 1 == data_j[j + 2] &&
data_i[i] + 2 == data_i[i + 3] && data_j[j] + 1 == data_j[j + 3]) {
return 'E';
} else if (data_i[i] == data_i[i + 1] && data_j[j] + 1 == data_j[j + 2] &&
data_i[i] + 1 == data_i[i + 2] && data_j[j] + 1 == data_j[j + 2] &&
data_i[i] + 1 == data_i[i + 2] && data_j[j] + 1 == data_j[j + 3]) {
return 'F';
} else {
return 'G';
}
}
int main() {
char table[8][8];
array<int, 4> data_i;
array<int, 4> data_j;
int tmp = 0, inum = 0, jnum = 0, i, j;
while (cin >> table[0]) {
for (i = 1; i < 8; i++) {
cin >> table[i];
}
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (table[i][j] == '1') {
data_i[inum] = i;
data_j[jnum] = j;
inum++;
jnum++;
}
}
}
inum = 0;
jnum = 0;
cout << checkData(data_j, data_i) << endl;
}
return 0;
}
|
#include <array>
#include <iostream>
using namespace std;
char checkData(array<int, 4> data_i, array<int, 4> data_j) {
int i = 0, j = 0;
if (data_i[i] + 1 == data_i[i + 1] && data_j[j] == data_j[j + 1] &&
data_i[i] == data_i[i + 2] && data_j[j] + 1 == data_j[i + 2] &&
data_i[i] + 1 == data_i[j + 3] && data_j[j] + 1 == data_j[j + 3]) {
return 'A';
} else if (data_i[i] == data_i[i + 1] && data_j[j] + 1 == data_j[j + 1] &&
data_i[i] == data_i[i + 2] && data_j[j] + 2 == data_j[j + 2] &&
data_i[i] == data_i[i + 3] && data_j[j] + 3 == data_j[j + 3]) {
return 'B';
} else if (data_i[i] + 1 == data_i[i + 1] && data_j[j] == data_j[j + 1] &&
data_i[i] + 2 == data_i[i + 2] && data_j[j] == data_j[j + 2] &&
data_i[i] + 3 == data_i[j + 3] && data_j[j] == data_j[j + 3]) {
return 'C';
} else if (data_i[i] - 1 == data_i[i + 1] && data_j[j] + 1 == data_j[j + 1] &&
data_i[i] == data_i[i + 2] && data_j[j] + 1 == data_j[j + 2] &&
data_i[i] - 1 == data_i[i + 3] && data_j[j] + 2 == data_j[j + 3]) {
return 'D';
} else if (data_i[i] + 1 == data_i[i + 1] && data_j[j] == data_j[j + 1] &&
data_i[i] + 1 == data_i[i + 2] && data_j[j] + 1 == data_j[j + 2] &&
data_i[i] + 2 == data_i[i + 3] && data_j[j] + 1 == data_j[j + 3]) {
return 'E';
} else if (data_i[i] == data_i[i + 1] && data_j[j] + 1 == data_j[j + 2] &&
data_i[i] + 1 == data_i[i + 2] && data_j[j] + 1 == data_j[j + 2] &&
data_i[i] + 1 == data_i[i + 2] && data_j[j] + 2 == data_j[j + 3]) {
return 'F';
} else {
return 'G';
}
}
int main() {
char table[8][8];
array<int, 4> data_i;
array<int, 4> data_j;
int tmp = 0, inum = 0, jnum = 0, i, j;
while (cin >> table[0]) {
for (i = 1; i < 8; i++) {
cin >> table[i];
}
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
if (table[i][j] == '1') {
data_i[inum] = i;
data_j[jnum] = j;
inum++;
jnum++;
}
}
}
inum = 0;
jnum = 0;
cout << checkData(data_j, data_i) << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13]]
| 1
| 756
| 2
|
#include <stdio.h>
int main(void) {
char s[8][10];
int i, j, k, l;
int dx[7][3] = {{1, 1, 0}, {0, 0, 0}, {1, 2, 3}, {0, -1, -1},
{1, 1, 2}, {0, 1, 1}, {1, -1, 0}},
dy[7][3] = {{0, 1, 1}, {1, 2, 3}, {0, 0, 0}, {1, 1, 2},
{0, 1, 1}, {1, 1, 2}, {0, 1, 1}};
while (scanf("%s", s[0]) != EOF) {
for (i = 1; i < 8; ++i)
scanf("%s", s[i]);
int t = 1;
for (i = 0; i < 8; ++i) {
for (j = 0; j < 8; ++j) {
if (s[i][j] == '1') {
for (k = 0; k < 7; ++k) {
for (l = 0; l < 3; ++l) {
if (i + dy[k][l] < 0 || i + dy[k][l] > 8 || j + dx[k][l] < 0 ||
j + dx[k][l] > 8 || s[i + dy[k][l]][j + dx[k][l]] == '0')
break;
}
if (l == 3) {
printf("%c\n", 'A' + k);
break;
}
}
t = 0;
break;
}
}
if (!t)
break;
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
char s[8][10];
int i, j, k, l;
int dx[7][3] = {{1, 1, 0}, {0, 0, 0}, {1, 2, 3}, {0, -1, -1},
{1, 1, 2}, {0, 1, 1}, {1, -1, 0}},
dy[7][3] = {{0, 1, 1}, {1, 2, 3}, {0, 0, 0}, {1, 1, 2},
{0, 1, 1}, {1, 1, 2}, {0, 1, 1}};
while (scanf("%s", s[0]) != EOF) {
for (i = 1; i < 8; ++i)
scanf("%s", s[i]);
int t = 1;
for (i = 0; i < 8; ++i) {
for (j = 0; j < 8; ++j) {
if (s[i][j] == '1') {
for (k = 0; k < 7; ++k) {
for (l = 0; l < 3; ++l) {
if (i + dy[k][l] < 0 || i + dy[k][l] >= 8 || j + dx[k][l] < 0 ||
j + dx[k][l] >= 8 || s[i + dy[k][l]][j + dx[k][l]] == '0')
break;
}
if (l == 3) {
printf("%c\n", 'A' + k);
break;
}
}
t = 0;
break;
}
}
if (!t)
break;
}
}
return 0;
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 16, 17, 47], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 17, 20], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 47], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 20]]
| 1
| 404
| 4
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define reep(i, f, n) for (int i = f; i < int(n); ++i)
#define rep(i, n) reep(i, 0, n)
typedef vector<int> vi;
int main() {
while (1) {
char field[8][9];
int left = 8, right = 0, top = 8, bottom = 0;
rep(y, 8) {
if (scanf("%s", field[y]) == EOF)
return 0;
rep(x, 8) {
if (field[y][x] == '1') {
left = min(left, x);
right = max(right, x);
top = min(top, y);
bottom = max(bottom, y);
}
}
}
int w = right - left + 1, h = bottom - top + 1;
if (h == 4)
puts("B");
else if (w == 4)
puts("C");
else if (w == 2 && w == 2)
puts("A");
else if (w == 2 && h == 3)
puts(field[top][left] == '1' ? "F" : "D");
else
puts(field[top][left] == '1' ? "E" : "G");
}
}
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define reep(i, f, n) for (int i = f; i < int(n); ++i)
#define rep(i, n) reep(i, 0, n)
typedef vector<int> vi;
int main() {
while (1) {
char field[8][9];
int left = 8, right = 0, top = 8, bottom = 0;
rep(y, 8) {
if (scanf("%s", field[y]) == EOF)
return 0;
rep(x, 8) {
if (field[y][x] == '1') {
left = min(left, x);
right = max(right, x);
top = min(top, y);
bottom = max(bottom, y);
}
}
}
int w = right - left + 1, h = bottom - top + 1;
if (h == 4)
puts("B");
else if (w == 4)
puts("C");
else if (w == 2 && h == 2)
puts("A");
else if (w == 2 && h == 3)
puts(field[top][left] == '1' ? "F" : "D");
else
puts(field[top][left] == '1' ? "E" : "G");
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
| 1
| 296
| 2
|
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int d[64];
char c[64];
while (1) {
int k = 0;
for (int i = 0; i < 64; i++) {
c[i] = 0;
d[i] = 0;
}
for (int i = 0; i < 64; i++) {
cin >> c[i];
if (c[i] == '1') {
d[k] = i;
k += 1;
}
}
if (k != 4)
return 0;
if (d[1] == d[0] + 1) {
if (d[2] == d[0] + 2)
cout << "C" << endl;
else if (d[2] == d[0] + 7)
cout << "G" << endl;
else if (d[2] == d[0] + 8)
cout << "A" << endl;
else
cout << "E" << endl;
} else if (d[1] == d[0] + 8) {
if (d[2] == d[0] + 8)
cout << "B" << endl;
else
cout << "F" << endl;
} else
cout << "D" << endl;
}
}
|
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int d[64];
char c[64];
while (1) {
int k = 0;
for (int i = 0; i < 64; i++) {
c[i] = 0;
d[i] = 0;
}
for (int i = 0; i < 64; i++) {
cin >> c[i];
if (c[i] == '1') {
d[k] = i;
k += 1;
}
}
if (k != 4)
return 0;
if (d[1] == d[0] + 1) {
if (d[2] == d[0] + 2)
cout << "C" << endl;
else if (d[2] == d[0] + 7)
cout << "G" << endl;
else if (d[2] == d[0] + 8)
cout << "A" << endl;
else
cout << "E" << endl;
} else if (d[1] == d[0] + 8) {
if (d[2] == d[0] + 16)
cout << "B" << endl;
else
cout << "F" << endl;
} else
cout << "D" << endl;
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 279
| 2
|
#include <cstdio>
#include <iostream>
using namespace std;
int dx[7][3] = {1, 1, 0, 0, 0, 0, 1, 2, 3, 0, -1,
-1, 1, 1, 2, 0, 1, 1, 1, 0, -1};
int dy[7][3] = {0, -1, -1, -1, -2, -3, 0, 0, 0, -1, -1,
-2, 0, -1, -1, -1, -1, -2, 0, -1, -1};
char field[10][10];
int main() {
while (true) {
for (int i = 0; i < 10; i++) {
fill(field[i], &field[i][10], 0);
}
if (scanf("%c ", &field[1][1]) != 1) {
break;
}
for (int i = 2; i < 9; i++) {
scanf("%c ", &field[1][i]);
}
for (int i = 2; i < 9; i++) {
for (int j = 1; j < 9; j++) {
scanf("%c ", &field[i][j]);
}
}
/*for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
printf("%c ", field[i][j]);
}
printf("\n");
}*/
for (int i = 1; i <= 8; i++) {
for (int j = 1; j <= 8; j++) {
if (field[i][j] == '1') {
int c = 0;
for (c = 0; c < 7; c++) {
for (int k = 0; k < 3; k++) {
if (field[i - dy[c][k]][j + dx[c][k]] == '0') {
goto next;
}
}
printf("%c\n", 'A' + c);
goto end;
next:;
}
}
}
}
end:;
}
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int dx[7][3] = {1, 1, 0, 0, 0, 0, 1, 2, 3, 0, -1,
-1, 1, 1, 2, 0, 1, 1, 1, 0, -1};
int dy[7][3] = {0, -1, -1, -1, -2, -3, 0, 0, 0, -1, -1,
-2, 0, -1, -1, -1, -1, -2, 0, -1, -1};
char field[10][10];
int main() {
while (true) {
for (int i = 0; i < 10; i++) {
fill(field[i], &field[i][10], '0');
}
if (scanf("%c ", &field[1][1]) != 1) {
break;
}
for (int i = 2; i < 9; i++) {
scanf("%c ", &field[1][i]);
}
for (int i = 2; i < 9; i++) {
for (int j = 1; j < 9; j++) {
scanf("%c ", &field[i][j]);
}
}
/*for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
printf("%c ", field[i][j]);
}
printf("\n");
}*/
for (int i = 1; i <= 8; i++) {
for (int j = 1; j <= 8; j++) {
if (field[i][j] == '1') {
int c = 0;
for (c = 0; c < 7; c++) {
for (int k = 0; k < 3; k++) {
if (field[i - dy[c][k]][j + dx[c][k]] == '0') {
goto next;
}
}
printf("%c\n", 'A' + c);
goto end;
next:;
}
}
}
}
end:;
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 103, 0, 104]]
| 1
| 417
| 2
|
#include <cstdio>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
char m[16][16], buf[16];
int main() {
while (true) {
bool done = false;
rep(i, 8) if (scanf("%s", m[i]) == EOF) done = true;
if (done)
break;
char res = 0;
rep(i, 8) rep(j, 8) {
if (m[i][j] == '1') {
if (j < 5 && m[i][j + 1] == '1' && m[i][j + 2] == '1' &&
m[i][j + 3] == '1') {
res = 'C';
} else if (j < 7 && i < 7 && m[i][j + 1] == '1' && m[i + 1][j] == '1' &&
m[i + 1][j + 1] == '1') {
res = 'A';
} else if (i < 5 && m[i + 1][j] == '1' && m[i + 2][j] == '1' &&
m[i + 3][j] == '1') {
res = 'B';
} else if (i < 6 && j > 0 && m[i + 1][j - 1] == '1' &&
m[i + 1][j] == '1' && m[i + 2][j - 1] == '1') {
res = 'D';
} else if (i < 7 && j < 6 && m[i][j + 1] == '1' &&
m[i + 1][j + 1] == '1' && m[i + 1][j + 2] == '1') {
res = 'E';
} else if (i < 6 && j < 7 && m[i + 1][j + 1] == '1' &&
m[i + 1][j] == '1' && m[i + 2][j + 1] == '1') {
res = 'F';
} else if (i < 7 && j < 7 && j > 0 && m[i][j + 1] == '1' &&
m[i][j + 1] == '1' && m[i - 1][j - 1] == '1') {
res = 'G';
}
}
if (res > 0)
goto BREAK;
}
BREAK:
printf("%c\n", res);
}
return 0;
}
|
#include <cstdio>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
char m[16][16], buf[16];
int main() {
while (true) {
bool done = false;
rep(i, 8) if (scanf("%s", m[i]) == EOF) done = true;
if (done)
break;
char res = 0;
rep(i, 8) rep(j, 8) {
if (m[i][j] == '1') {
if (j < 5 && m[i][j + 1] == '1' && m[i][j + 2] == '1' &&
m[i][j + 3] == '1') {
res = 'C';
} else if (j < 7 && i < 7 && m[i][j + 1] == '1' && m[i + 1][j] == '1' &&
m[i + 1][j + 1] == '1') {
res = 'A';
} else if (i < 5 && m[i + 1][j] == '1' && m[i + 2][j] == '1' &&
m[i + 3][j] == '1') {
res = 'B';
} else if (i < 6 && j > 0 && m[i + 1][j - 1] == '1' &&
m[i + 1][j] == '1' && m[i + 2][j - 1] == '1') {
res = 'D';
} else if (i < 7 && j < 6 && m[i][j + 1] == '1' &&
m[i + 1][j + 1] == '1' && m[i + 1][j + 2] == '1') {
res = 'E';
} else if (i < 6 && j < 7 && m[i + 1][j + 1] == '1' &&
m[i + 1][j] == '1' && m[i + 2][j + 1] == '1') {
res = 'F';
} else if (i < 7 && j < 7 && j > 0 && m[i][j + 1] == '1' &&
m[i + 1][j] == '1' && m[i + 1][j - 1] == '1') {
res = 'G';
}
}
if (res > 0)
goto BREAK;
}
BREAK:
printf("%c\n", res);
}
return 0;
}
|
[["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33]]
| 1
| 583
| 6
|
#include <cstdio>
#include <iostream>
using namespace std;
char w[8][8];
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}, s[8][8], q[4];
//ツ湘」ツ、ツ可コツ、ツ右ツ、ツ債カ
void func(int y, int x) {
s[y][x] = 0;
for (int i = 0; i < 4; i++)
if (y + dy[i] >= 0 && y + dy[i] < 8 && x + dx[i] >= 0 && x + dx[i] < 8)
if (s[y + dy[i]][x + dx[i]] == 1) {
q[i]++;
func(y + dy[i], x + dx[i]);
}
}
int main() {
while (scanf("%s", w[0]) != EOF) {
for (int i = 1; i < 8; i++)
scanf("%s", w[i]);
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
s[i][j] = w[i][j] - '0';
for (int i = 0; i < 4; i++)
q[i] = 0;
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
if (s[i][j] == 1)
func(i, j);
if (q[0] == 1 && q[1] == 1 && q[2] == 1)
cout << 'A' << endl;
else if (q[1] == 3)
cout << 'B' << endl;
else if (q[2] == 3)
cout << 'C' << endl;
else if (q[0] == 2 && q[3] == 1)
cout << 'D' << endl;
else if (q[0] == 1 && q[2] == 2)
cout << 'E' << endl;
else if (q[0] == 2 && q[2] == 1)
cout << 'F' << endl;
else if (q[0] == 1 && q[2] == 1 && q[3] == 1)
cout << 'G' << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
char w[8][8];
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}, s[8][8], q[4];
//ツ湘」ツ、ツ可コツ、ツ右ツ、ツ債カ
void func(int y, int x) {
s[y][x] = 0;
for (int i = 0; i < 4; i++)
if (y + dy[i] >= 0 && y + dy[i] < 8 && x + dx[i] >= 0 && x + dx[i] < 8)
if (s[y + dy[i]][x + dx[i]] == 1) {
q[i]++;
func(y + dy[i], x + dx[i]);
}
}
int main() {
while (scanf("%s", w[0]) != EOF) {
for (int i = 1; i < 8; i++)
scanf("%s", w[i]);
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
s[i][j] = w[i][j] - '0';
for (int i = 0; i < 4; i++)
q[i] = 0;
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
if (s[i][j] == 1)
func(i, j);
if (q[0] == 1 && q[1] == 1 && q[2] == 1)
cout << 'A' << endl;
else if (q[0] == 3)
cout << 'B' << endl;
else if (q[2] == 3)
cout << 'C' << endl;
else if (q[0] == 2 && q[3] == 1)
cout << 'D' << endl;
else if (q[0] == 1 && q[2] == 2)
cout << 'E' << endl;
else if (q[0] == 2 && q[2] == 1)
cout << 'F' << endl;
else if (q[0] == 1 && q[2] == 1 && q[3] == 1)
cout << 'G' << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13]]
| 1
| 523
| 2
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool one(const vector<string> &v, int x, int y) {
if (x < 0 || y < 0 || x >= v[0].size() || y >= v.size())
return false;
return v[y][x] == '1';
}
int main() {
vector<string> v(8);
while (cin >> v[0]) {
for (int i = 1; i < 8; ++i)
cin >> v[i];
char kind;
for (int y = 0; y < 8; ++y) {
for (int x = 0; x < 8; ++x) {
if (one(v, x, y)) {
if (one(v, x + 1, y) && one(v, x, y + 1) && one(v, x + 1, y + 1))
kind = 'A';
else if (one(v, x, y + 1) && one(v, x, y + 2) && one(v, x, y + 3))
kind = 'B';
else if (one(v, x + 1, y) && one(v, x + 2, y) && one(v, x + 3, y))
kind = 'C';
else if (one(v, x, y + 1) && one(v, x - 1, y + 1) &&
one(v, x - 1, y + 2))
kind = 'D';
else if (one(v, x + 1, y) && one(v, x + 1, y + 1) &&
one(v, x + 2, y + 1))
kind = 'E';
else if (one(v, x, y + 1) && one(v, x + 1, y + 1) &&
one(v, x + 2, y + 2))
kind = 'F';
else if (one(v, x + 1, y) && one(v, x, y + 1) && one(v, x - 1, y + 1))
kind = 'G';
goto end;
}
}
}
end:
cout << kind << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool one(const vector<string> &v, int x, int y) {
if (x < 0 || y < 0 || x >= v[0].size() || y >= v.size())
return false;
return v[y][x] == '1';
}
int main() {
vector<string> v(8);
while (cin >> v[0]) {
for (int i = 1; i < 8; ++i)
cin >> v[i];
char kind;
for (int y = 0; y < 8; ++y) {
for (int x = 0; x < 8; ++x) {
if (one(v, x, y)) {
if (one(v, x + 1, y) && one(v, x, y + 1) && one(v, x + 1, y + 1))
kind = 'A';
else if (one(v, x, y + 1) && one(v, x, y + 2) && one(v, x, y + 3))
kind = 'B';
else if (one(v, x + 1, y) && one(v, x + 2, y) && one(v, x + 3, y))
kind = 'C';
else if (one(v, x, y + 1) && one(v, x - 1, y + 1) &&
one(v, x - 1, y + 2))
kind = 'D';
else if (one(v, x + 1, y) && one(v, x + 1, y + 1) &&
one(v, x + 2, y + 1))
kind = 'E';
else if (one(v, x, y + 1) && one(v, x + 1, y + 1) &&
one(v, x + 1, y + 2))
kind = 'F';
else if (one(v, x + 1, y) && one(v, x, y + 1) && one(v, x - 1, y + 1))
kind = 'G';
goto end;
}
}
}
end:
cout << kind << endl;
}
return 0;
}
|
[["-", 51, 16, 12, 2, 3, 4, 0, 16, 12, 13], ["+", 51, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 492
| 2
|
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
for (;;) {
vector<string> s(8);
for (int i = 0; i < 8; ++i) {
if (!(cin >> s[i]))
return 0;
}
int dy[] = {3, 0, 2, 1, 2, 1};
int dx[] = {0, 3, -1, 2, 1, -2};
bool ok = false;
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (ok || s[i][j] == '0')
continue;
for (int k = 0; k < 6; ++k) {
if (i + dy[k] < 8 && 0 <= j + dx[k] && j + dx[k] < 8 &&
s[i + dy[k]][j + dx[k]] == '1') {
cout << (char)('B' + k) << endl;
ok = true;
break;
}
}
if (!ok) {
cout << 'A' << endl;
ok = true;
}
}
}
}
}
|
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
for (;;) {
vector<string> s(8);
for (int i = 0; i < 8; ++i) {
if (!(cin >> s[i]))
return 0;
}
int dy[] = {3, 0, 2, 1, 2, 1};
int dx[] = {0, 3, -1, 2, 1, -1};
bool ok = false;
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (ok || s[i][j] == '0')
continue;
for (int k = 0; k < 6; ++k) {
if (i + dy[k] < 8 && 0 <= j + dx[k] && j + dx[k] < 8 &&
s[i + dy[k]][j + dx[k]] == '1') {
cout << (char)('B' + k) << endl;
ok = true;
break;
}
}
if (!ok) {
cout << 'A' << endl;
ok = true;
}
}
}
}
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
| 1
| 291
| 2
|
#include <stdio.h>
#include <string.h>
int main(void) {
char b[65];
char p[7][33] = {
"1100000011", "10000000100000001000000010000000",
"1111", "1000000110000001",
"11000000011", "100000001100000001",
"110000011",
};
char *bi;
int t = 0;
while (true) {
if (scanf("%s", b) == EOF) {
break;
}
for (int i = 1; i < 8; ++i) {
scanf("%s", b + i * 8);
}
bi = strchr(b, '1');
for (int i = 0; i < 7; ++i) {
if (memcmp(bi, p[i], strlen(p[i])) == 0) {
printf("%c\n", 'A' + i);
break;
}
}
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main(void) {
char b[65];
char p[7][33] = {
"1100000011", "1000000010000000100000001",
"1111", "1000000110000001",
"11000000011", "100000001100000001",
"110000011",
};
char *bi;
int t = 0;
while (true) {
if (scanf("%s", b) == EOF) {
break;
}
for (int i = 1; i < 8; ++i) {
scanf("%s", b + i * 8);
}
bi = strchr(b, '1');
for (int i = 0; i < 7; ++i) {
if (memcmp(bi, p[i], strlen(p[i])) == 0) {
printf("%c\n", 'A' + i);
break;
}
}
}
return 0;
}
|
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
| 1
| 188
| 2
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
typedef long long ll;
using namespace std;
bool in(int i, int j) {
if (i >= 0 && i < 8 && j >= 0 && j < 8)
return true;
return false;
}
bool is_A(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i + 1, j) && table[i + 1][j] == 1 && in(i + 1, j + 1) &&
table[i + 1][j + 1] == 1)
return true;
return false;
}
bool is_B(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i + 1, j + 1) && table[i + 1][j] == 1 &&
in(i + 2, j) && table[i + 2][j] == 1 && in(i + 3, j + 1) &&
table[i + 3][j] == 1)
return true;
return false;
}
bool is_C(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i, j + 2) && table[i][j + 2] == 1 && in(i, j + 3) &&
table[i][j + 3] == 1)
return true;
return false;
}
bool is_D(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i - 1, j + 1) && table[i - 1][j + 1] == 1 && in(i + 1, j) &&
table[i + 1][j] == 1)
return true;
return false;
}
bool is_E(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i + 1, j + 1) && table[i + 1][j + 1] == 1 && in(i + 1, j + 2) &&
table[i + 1][j + 2] == 1)
return true;
return false;
}
bool is_F(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i + 1, j) && table[i + 1][j] == 1 &&
in(i + 1, j + 1) && table[i + 1][j + 1] == 1 && in(i + 2, j + 1) &&
table[i + 2][j + 1] == 1)
return true;
return false;
}
bool is_G(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i + 1, j - 1) && table[i + 1][j - 1] == 1 && in(i + 1, j) &&
table[i + 1][j] == 1)
return true;
return false;
}
int main() {
int table[8][8];
while (1) {
bool is_eof = false;
memset(table, 0, sizeof(table));
for (int i = 0; i < 8; i++) {
char buf[32];
if (scanf("%s", buf) == EOF) {
is_eof = true;
break;
}
for (int j = 0; j < 8; j++) {
table[i][j] = buf[j] - '0';
}
}
if (is_eof)
break;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (is_A(i, j, table)) {
cout << 'A' << endl;
goto found;
} else if (is_B(i, j, table)) {
cout << 'B' << endl;
goto found;
} else if (is_C(i, j, table)) {
cout << 'C' << endl;
goto found;
} else if (is_D(i, j, table)) {
cout << 'D' << endl;
goto found;
} else if (is_E(i, j, table)) {
cout << 'E' << endl;
goto found;
} else if (is_F(i, j, table)) {
cout << 'F' << endl;
goto found;
} else if (is_G(i, j, table)) {
cout << 'G' << endl;
goto found;
}
}
}
found:;
}
}
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
typedef long long ll;
using namespace std;
bool in(int i, int j) {
if (i >= 0 && i < 8 && j >= 0 && j < 8)
return true;
return false;
}
bool is_A(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i + 1, j) && table[i + 1][j] == 1 && in(i + 1, j + 1) &&
table[i + 1][j + 1] == 1)
return true;
return false;
}
bool is_B(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i + 1, j) && table[i + 1][j] == 1 &&
in(i + 2, j) && table[i + 2][j] == 1 && in(i + 3, j) &&
table[i + 3][j] == 1)
return true;
return false;
}
bool is_C(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i, j + 2) && table[i][j + 2] == 1 && in(i, j + 3) &&
table[i][j + 3] == 1)
return true;
return false;
}
bool is_D(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i - 1, j + 1) && table[i - 1][j + 1] == 1 && in(i + 1, j) &&
table[i + 1][j] == 1)
return true;
return false;
}
bool is_E(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i + 1, j + 1) && table[i + 1][j + 1] == 1 && in(i + 1, j + 2) &&
table[i + 1][j + 2] == 1)
return true;
return false;
}
bool is_F(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i + 1, j) && table[i + 1][j] == 1 &&
in(i + 1, j + 1) && table[i + 1][j + 1] == 1 && in(i + 2, j + 1) &&
table[i + 2][j + 1] == 1)
return true;
return false;
}
bool is_G(int i, int j, int table[8][8]) {
if (table[i][j] == 1 && in(i, j + 1) && table[i][j + 1] == 1 &&
in(i + 1, j - 1) && table[i + 1][j - 1] == 1 && in(i + 1, j) &&
table[i + 1][j] == 1)
return true;
return false;
}
int main() {
int table[8][8];
while (1) {
bool is_eof = false;
memset(table, 0, sizeof(table));
for (int i = 0; i < 8; i++) {
char buf[32];
if (scanf("%s", buf) == EOF) {
is_eof = true;
break;
}
for (int j = 0; j < 8; j++) {
table[i][j] = buf[j] - '0';
}
}
if (is_eof)
break;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (is_A(i, j, table)) {
cout << 'A' << endl;
goto found;
} else if (is_B(i, j, table)) {
cout << 'B' << endl;
goto found;
} else if (is_C(i, j, table)) {
cout << 'C' << endl;
goto found;
} else if (is_D(i, j, table)) {
cout << 'D' << endl;
goto found;
} else if (is_E(i, j, table)) {
cout << 'E' << endl;
goto found;
} else if (is_F(i, j, table)) {
cout << 'F' << endl;
goto found;
} else if (is_G(i, j, table)) {
cout << 'G' << endl;
goto found;
}
}
}
found:;
}
}
|
[["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 1,134
| 4
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char judge(vector<string> surface) {
for (unsigned int i = 0; i < surface.size(); i++) {
for (unsigned int j = 0; j < surface[i].length(); j++) {
if (surface[i][j] == '1') {
// A
if (surface[i][j + 1] == '1' && surface[i + 1][j] == '1' &&
surface[i + 1][j + 1] == '1') {
return 'A';
}
// B
else if (surface[i + 1][j] == '1' && surface[i + 2][j] == '1' &&
surface[i + 3][j] == '1') {
return 'B';
}
// C
else if (surface[i][j + 1] == '1' && surface[i][j + 2] == '1' &&
surface[i][j + 3] == '1') {
return 'C';
}
// D
else if (surface[i + 1][j] == '1' && surface[i - 1][j - 1] == '1' &&
surface[i - 2][j - 1] == '1') {
return 'D';
}
// E
else if (surface[i][j + 1] == '1' && surface[i + 1][j + 1] == '1' &&
surface[i + 1][j + 2] == '1') {
return 'E';
}
// F
else if (surface[i + 1][j] == '1' && surface[i + 1][j + 1] == '1' &&
surface[i + 2][j + 1] == '1') {
return 'F';
}
// G
else if (surface[i + 1][j + 1] == '1' && surface[i - 1][j - 1] == '1' &&
surface[i + 1][j] == '1') {
return 'G';
} else {
return '-';
}
}
}
}
return '-';
}
int main() {
while (true) {
string buffer;
vector<string> surface;
surface.push_back("00000000000000");
surface.push_back("00000000000000");
surface.push_back("00000000000000");
for (int i = 0; i < 8; i++) {
if (cin >> buffer) {
surface.push_back("000" + buffer + "000");
} else {
return 0;
}
}
surface.push_back("00000000000000");
surface.push_back("00000000000000");
surface.push_back("00000000000000");
cout << judge(surface) << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char judge(vector<string> surface) {
for (unsigned int i = 0; i < surface.size(); i++) {
for (unsigned int j = 0; j < surface[i].length(); j++) {
if (surface[i][j] == '1') {
// A
if (surface[i][j + 1] == '1' && surface[i + 1][j] == '1' &&
surface[i + 1][j + 1] == '1') {
return 'A';
}
// B
else if (surface[i + 1][j] == '1' && surface[i + 2][j] == '1' &&
surface[i + 3][j] == '1') {
return 'B';
}
// C
else if (surface[i][j + 1] == '1' && surface[i][j + 2] == '1' &&
surface[i][j + 3] == '1') {
return 'C';
}
// D
else if (surface[i + 1][j] == '1' && surface[i + 1][j - 1] == '1' &&
surface[i + 2][j - 1] == '1') {
return 'D';
}
// E
else if (surface[i][j + 1] == '1' && surface[i + 1][j + 1] == '1' &&
surface[i + 1][j + 2] == '1') {
return 'E';
}
// F
else if (surface[i + 1][j] == '1' && surface[i + 1][j + 1] == '1' &&
surface[i + 2][j + 1] == '1') {
return 'F';
}
// G
else if (surface[i][j + 1] == '1' && surface[i + 1][j - 1] == '1' &&
surface[i + 1][j] == '1') {
return 'G';
} else {
return '-';
}
}
}
}
return '-';
}
int main() {
while (true) {
string buffer;
vector<string> surface;
surface.push_back("00000000000000");
surface.push_back("00000000000000");
surface.push_back("00000000000000");
for (int i = 0; i < 8; i++) {
if (cin >> buffer) {
surface.push_back("000" + buffer + "000");
} else {
return 0;
}
}
surface.push_back("00000000000000");
surface.push_back("00000000000000");
surface.push_back("00000000000000");
cout << judge(surface) << endl;
}
return 0;
}
|
[["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 637
| 8
|
#include <iostream>
#include <vector>
using namespace std;
string match(const vector<string> v) {
const string PTN[7][4]{
{"11", "11"}, {"1", "1", "1", "1"}, {"1111"}, {"01", "11", "10"},
{"110", "011"}, {"10", "11", "01"}, {"011", "110"}};
const int PTN_H[7]{2, 4, 1, 3, 2, 3, 2};
const string PTN_NAME[7] = {"A", "B", "C", "D", "E", "F", "G"};
int ans = -1;
for (int k = 0; k < 7; ++k) {
int pw = PTN[k][0].size(), ph = PTN_H[k];
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (i + ph < 8 && j + pw <= 8) { // substrなので含む
bool f = true;
for (int l = 0; l < ph; ++l) {
if (PTN[k][l] != v[i + l].substr(j, pw))
f = false;
}
if (f) {
ans = k;
break;
break;
break;
}
} else {
break;
}
}
}
}
return PTN_NAME[ans];
}
int main() {
for (;;) {
vector<string> surface;
for (int i = 0; i < 8; ++i) {
string s;
cin >> s;
if (s.empty())
return 0;
surface.push_back(s);
}
string ans = match(surface);
cout << ans << endl;
if (cin.eof())
break;
}
return 0;
}
|
#include <iostream>
#include <vector>
using namespace std;
string match(const vector<string> v) {
const string PTN[7][4]{
{"11", "11"}, {"1", "1", "1", "1"}, {"1111"}, {"01", "11", "10"},
{"110", "011"}, {"10", "11", "01"}, {"011", "110"}};
const int PTN_H[7]{2, 4, 1, 3, 2, 3, 2};
const string PTN_NAME[7] = {"A", "B", "C", "D", "E", "F", "G"};
int ans = -1;
for (int k = 0; k < 7; ++k) {
int pw = PTN[k][0].size(), ph = PTN_H[k];
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (i + ph <= 8 && j + pw <= 8) {
bool f = true;
for (int l = 0; l < ph; ++l) {
if (PTN[k][l] != v[i + l].substr(j, pw))
f = false;
}
if (f) {
ans = k;
break;
break;
break;
}
} else {
break;
}
}
}
}
return PTN_NAME[ans];
}
int main() {
for (;;) {
vector<string> surface;
for (int i = 0; i < 8; ++i) {
string s;
cin >> s;
if (s.empty())
return 0;
surface.push_back(s);
}
string ans = match(surface);
cout << ans << endl;
if (cin.eof())
break;
}
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19]]
| 1
| 427
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string s, shape[7];
string tmp;
shape[0] = "1100000011";
shape[1] = "1000000010000000100000001";
shape[2] = "1111";
shape[3] = "1000000110000001";
shape[4] = "11000000011";
shape[5] = "100000001100000001";
shape[6] = "110000011";
while (cin >> s) {
for (int i = 0; i < 7; i++) {
cin >> tmp;
s += tmp;
}
for (int i = 0; i < 7; i++) {
if (s.find(shape[i]) != string::npos) {
cout << (char)('A' + i) << endl;
}
}
cin >> s;
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string s, shape[7];
string tmp;
shape[0] = "1100000011";
shape[1] = "1000000010000000100000001";
shape[2] = "1111";
shape[3] = "1000000110000001";
shape[4] = "11000000011";
shape[5] = "100000001100000001";
shape[6] = "110000011";
while (cin >> s) {
for (int i = 0; i < 7; i++) {
cin >> tmp;
s += tmp;
}
for (int i = 0; i < 7; i++) {
if (s.find(shape[i]) != string::npos) {
cout << (char)('A' + i) << endl;
}
}
}
}
|
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 174
| 4
|
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>
#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#ifdef _MSC_VER
#define __typeof__ decltype
#endif
#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it = (c).begin(); it != (c).end(); ++it)
#define RITER(c) __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it = (c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n) REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n) for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n) std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n) std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1, p2) ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A) (sizeof(A) / sizeof((A)[0]))
#define MIN(p1, p2) (((p1) < (p2)) ? (p1) : (p2))
#define MAX(p1, p2) (((p1) > (p2)) ? (p1) : (p2))
#define CIN_NO_SYNC \
do { \
cin.tie(0); \
ios_base::sync_with_stdio(false); \
} while (0)
#define GETSTR(p) fgets((p), sizeof(p), stdin)
#define CHOMP(p) \
do { \
char *_q = (p) + strlen(p) - 1; \
if (*_q == '\n') \
*_q = 0; \
} while (0)
typedef long long ll;
typedef unsigned long long ull;
#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)
inline D inprd(const P &a, const P &b) { return (conj(a) * b).X; }
inline D outprd(const P &a, const P &b) { return (conj(a) * b).Y; }
inline D sign(D d) { return (d < 0) ? -1 : d > 0 ? 1 : 0; }
#ifdef _DEBUG
#define pf printf
#define pr(n) \
do { \
cout << #n " = " << (n) << endl; \
} while (0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif
int table[][6] = {
{1, 0, 0, 1, 1, 1}, // A
{0, 1, 0, 2, 0, 3}, // B
{1, 0, 2, 0, 3, 0}, // C
{-1, 1, 0, 1, -1, 2}, // D
{1, 0, 1, 1, 2, 1}, // E
{0, 1, 1, 1, 1, 2}, // F
{1, 0, -1, 1, 0, 1}, // G
};
int main() {
deque<string> sv;
string s;
cin.binary;
while (getline(cin, s)) {
if (s == "")
continue;
sv.push_back(s);
s = "";
}
if (sv.size() % 8 != 0)
throw;
int n = sv.size() / 8;
REP(i, n) {
char m[8][8];
REP(y, 8) {
string s = sv.front();
sv.pop_front();
REP(x, 8) { m[y][x] = s[x] - '0'; }
}
bool f = false;
REP(y, 8) REP(x, 8) {
if (m[y][x]) {
REP(t, 6) {
bool f2 = true;
REP(u, 3) {
int nx = x + table[t][u * 2 + 0];
int ny = y + table[t][u * 2 + 1];
if (nx < 0 || nx >= 8 || ny < 0 || ny >= 8 || m[ny][nx] == 0) {
f2 = false;
break;
}
}
if (f2) {
printf("%c\n", 'A' + t);
goto END;
}
}
}
}
END:;
}
return 0;
}
|
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>
#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#ifdef _MSC_VER
#define __typeof__ decltype
#endif
#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it = (c).begin(); it != (c).end(); ++it)
#define RITER(c) __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it = (c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n) REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n) for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n) std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n) std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1, p2) ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A) (sizeof(A) / sizeof((A)[0]))
#define MIN(p1, p2) (((p1) < (p2)) ? (p1) : (p2))
#define MAX(p1, p2) (((p1) > (p2)) ? (p1) : (p2))
#define CIN_NO_SYNC \
do { \
cin.tie(0); \
ios_base::sync_with_stdio(false); \
} while (0)
#define GETSTR(p) fgets((p), sizeof(p), stdin)
#define CHOMP(p) \
do { \
char *_q = (p) + strlen(p) - 1; \
if (*_q == '\n') \
*_q = 0; \
} while (0)
typedef long long ll;
typedef unsigned long long ull;
#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)
inline D inprd(const P &a, const P &b) { return (conj(a) * b).X; }
inline D outprd(const P &a, const P &b) { return (conj(a) * b).Y; }
inline D sign(D d) { return (d < 0) ? -1 : d > 0 ? 1 : 0; }
#ifdef _DEBUG
#define pf printf
#define pr(n) \
do { \
cout << #n " = " << (n) << endl; \
} while (0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif
int table[7][6] = {
{1, 0, 0, 1, 1, 1}, // A
{0, 1, 0, 2, 0, 3}, // B
{1, 0, 2, 0, 3, 0}, // C
{-1, 1, 0, 1, -1, 2}, // D
{1, 0, 1, 1, 2, 1}, // E
{0, 1, 1, 1, 1, 2}, // F
{1, 0, -1, 1, 0, 1}, // G
};
int main() {
deque<string> sv;
string s;
cin.binary;
while (getline(cin, s)) {
if (s == "")
continue;
sv.push_back(s);
s = "";
}
if (sv.size() % 8 != 0)
throw;
int n = sv.size() / 8;
REP(i, n) {
char m[8][8];
REP(y, 8) {
string s = sv.front();
sv.pop_front();
REP(x, 8) { m[y][x] = s[x] - '0'; }
}
bool f = false;
REP(y, 8) REP(x, 8) {
if (m[y][x]) {
REP(t, 7) {
bool f2 = true;
REP(u, 3) {
int nx = x + table[t][u * 2 + 0];
int ny = y + table[t][u * 2 + 1];
if (nx < 0 || nx >= 8 || ny < 0 || ny >= 8 || m[ny][nx] == 0) {
f2 = false;
break;
}
}
if (f2) {
printf("%c\n", 'A' + t);
goto END;
}
}
}
}
END:;
}
return 0;
}
|
[["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["-", 64, 9, 0, 42, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 42, 0, 2, 3, 4, 0, 13]]
| 1
| 721
| 3
|
#include <iostream>
using namespace std;
int main() {
while (true) {
char board[8][8];
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cin >> board[i][j];
}
}
bool flag = false;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (board[i][j] == '1') // ブロックがあれば
{
if (board[i + 3][j] == '1') {
cout << 'B' << endl;
} else if (board[i][j + 3] == '1') {
cout << 'C' << endl;
} else if (board[i + 2][j - 1] == '1') {
cout << 'D' << endl;
} else if (board[i + 1][j + 2] == '1') {
cout << 'E' << endl;
} else if (board[i + 2][j + 1] == '1') {
cout << 'F' << endl;
} else if (board[i + 1][j - 1] == '1') {
cout << 'G' << endl;
} else {
cout << 'A' << endl;
}
flag = true;
}
if (flag)
break;
}
if (flag)
break;
}
char dummy;
cin >> noskipws;
cin >> dummy;
cin >> skipws;
if (cin.eof())
break;
}
}
|
#include <iostream>
using namespace std;
int main() {
while (true) {
char board[8][8];
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cin >> board[i][j];
}
}
bool flag = false;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (board[i][j] == '1') // ブロックがあれば
{
if (board[i + 3][j] == '1') {
cout << 'B' << endl;
} else if (board[i][j + 3] == '1') {
cout << 'C' << endl;
} else if (board[i + 2][j - 1] == '1') {
cout << 'D' << endl;
} else if (board[i + 1][j + 2] == '1') {
cout << 'E' << endl;
} else if (board[i + 2][j + 1] == '1') {
cout << 'F' << endl;
} else if (board[i + 1][j - 1] == '1') {
cout << 'G' << endl;
} else {
cout << 'A' << endl;
}
flag = true;
}
if (flag)
break;
}
if (flag)
break;
}
char dummy;
cin >> noskipws;
cin >> dummy >> dummy;
cin >> skipws;
if (cin.eof())
break;
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 344
| 2
|
#include <iostream>
using namespace std;
int main() {
char mas[8][8];
while (1) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cin >> mas[i][j];
}
}
if (cin.eof())
break;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (mas[i][j] == '1') {
if (mas[i + 1][j] == '1' && mas[i][j + 1] == '1' &&
mas[i + 1][j + 1] == '1')
cout << "A" << endl;
else if (mas[i + 1][j] == '1' && mas[i + 2][j] == '1' &&
mas[i + 3][j] == '1')
cout << "B" << endl;
else if (mas[i][j + 1] == '1' && mas[i][j + 2] == '1' &&
mas[i][j + 3] == '1')
cout << "C" << endl;
else if (mas[i + 1][j] == '1' && mas[i + 1][j - 1] == '1' &&
mas[i + 2][j - 1] == '1')
cout << "D" << endl;
else if (mas[i][j + 1] == '1' && mas[i + 1][j + 1] == '1' &&
mas[i + 1][j + 2] == '1')
cout << "E" << endl;
else if (mas[i + 1][j] == '1' && mas[i + 1][j + 1] == '1' &&
mas[i + 2][j + 1] == '1')
cout << "F" << endl;
else if (mas[i][j + 1] == '1' && mas[i + 1][j] == '1' &&
mas[i - 1][j - 1] == '1')
cout << "G" << endl;
}
}
}
}
}
|
#include <iostream>
using namespace std;
int main() {
char mas[8][8];
while (1) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cin >> mas[i][j];
}
}
if (cin.eof())
break;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (mas[i][j] == '1') {
if (mas[i + 1][j] == '1' && mas[i][j + 1] == '1' &&
mas[i + 1][j + 1] == '1')
cout << "A" << endl;
else if (mas[i + 1][j] == '1' && mas[i + 2][j] == '1' &&
mas[i + 3][j] == '1')
cout << "B" << endl;
else if (mas[i][j + 1] == '1' && mas[i][j + 2] == '1' &&
mas[i][j + 3] == '1')
cout << "C" << endl;
else if (mas[i + 1][j] == '1' && mas[i + 1][j - 1] == '1' &&
mas[i + 2][j - 1] == '1')
cout << "D" << endl;
else if (mas[i][j + 1] == '1' && mas[i + 1][j + 1] == '1' &&
mas[i + 1][j + 2] == '1')
cout << "E" << endl;
else if (mas[i + 1][j] == '1' && mas[i + 1][j + 1] == '1' &&
mas[i + 2][j + 1] == '1')
cout << "F" << endl;
else if (mas[i][j + 1] == '1' && mas[i + 1][j] == '1' &&
mas[i + 1][j - 1] == '1')
cout << "G" << endl;
}
}
}
}
}
|
[["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72]]
| 1
| 513
| 2
|
#include <iostream>
#include <string>
using namespace std;
string s[8];
int check(int i, int j) {
if (i + 1 < 8 && j + 1 < 8) {
if (s[i][j + 1] == '1' && s[i + 1][j + 1] == '1' && s[i + 1][j] == '1') {
return 1;
}
}
if (i + 3 < 8) {
if (s[i + 1][j] == '1' && s[i + 2][j] == '1' && s[i + 3][j] == '1') {
return 2;
}
}
if (j + 3 < 8) {
if (s[i][j + 1] == '1' && s[i][j + 2] == '1' && s[i][j + 3] == '1') {
return 3;
}
}
if (j - i >= 0 && i + 2 < 8) {
if (s[i + 1][j] == '1' && s[i + 1][j - 1] == '1' &&
s[i + 2][j - 1] == '1') {
return 4;
}
}
if (j + 2 < 8 && i + 1 < 8) {
if (s[i][j + 1] == '1' && s[i + 1][j + 1] == '1' &&
s[i + 1][j + 2] == '1') {
return 5;
}
}
if (j + 1 < 8 && i + 2 < 8) {
if (s[i + 1][j] == '1' && s[i + 1][j + 1] == '1' &&
s[i + 2][j + 1] == '1') {
return 6;
}
}
return 7;
}
int main(void) {
while (cin >> s[0]) {
for (int i = 1; i < 8; i++) {
cin >> s[i];
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (s[i][j] == '1') {
// cout << check( i , j ) << "---" << endl;
switch (check(i, j)) {
case 1:
cout << "A" << endl;
break;
case 2:
cout << "B" << endl;
break;
case 3:
cout << "C" << endl;
break;
case 4:
cout << "D" << endl;
break;
case 5:
cout << "E" << endl;
break;
case 6:
cout << "F" << endl;
break;
case 7:
cout << "G" << endl;
break;
}
goto end;
}
}
}
end:;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
string s[8];
int check(int i, int j) {
if (i + 1 < 8 && j + 1 < 8) {
if (s[i][j + 1] == '1' && s[i + 1][j + 1] == '1' && s[i + 1][j] == '1') {
return 1;
}
}
if (i + 3 < 8) {
if (s[i + 1][j] == '1' && s[i + 2][j] == '1' && s[i + 3][j] == '1') {
return 2;
}
}
if (j + 3 < 8) {
if (s[i][j + 1] == '1' && s[i][j + 2] == '1' && s[i][j + 3] == '1') {
return 3;
}
}
if (j - 1 >= 0 && i + 2 < 8) {
if (s[i + 1][j] == '1' && s[i + 1][j - 1] == '1' &&
s[i + 2][j - 1] == '1') {
return 4;
}
}
if (j + 2 < 8 && i + 1 < 8) {
if (s[i][j + 1] == '1' && s[i + 1][j + 1] == '1' &&
s[i + 1][j + 2] == '1') {
return 5;
}
}
if (j + 1 < 8 && i + 2 < 8) {
if (s[i + 1][j] == '1' && s[i + 1][j + 1] == '1' &&
s[i + 2][j + 1] == '1') {
return 6;
}
}
return 7;
}
int main(void) {
while (cin >> s[0]) {
for (int i = 1; i < 8; i++) {
cin >> s[i];
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (s[i][j] == '1') {
// cout << i << j << "---" << endl;
switch (check(i, j)) {
case 1:
cout << "A" << endl;
break;
case 2:
cout << "B" << endl;
break;
case 3:
cout << "C" << endl;
break;
case 4:
cout << "D" << endl;
break;
case 5:
cout << "E" << endl;
break;
case 6:
cout << "F" << endl;
break;
case 7:
cout << "G" << endl;
break;
}
goto end;
}
}
}
end:;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 13]]
| 1
| 621
| 2
|
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int lli;
using namespace std;
int dx[7][4] = {{0, 0, 1, 1}, {0, 0, 0, 0}, {0, 1, 2, 3}, {0, 0, -1, -1},
{0, 1, 1, 2}, {0, 0, 1, 1}, {0, -1, 0, 1}};
int dy[7][4] = {{0, 1, 1, 0}, {0, 1, 2, 3}, {0, 0, 0, 0}, {0, 1, 1, 2},
{0, 0, 1, 1}, {0, 1, 1, 2}, {0, 1, 1, 0}};
string MAP[8];
string ans = "ABCDEFG";
int main() {
while (1) {
for (int i = 0; i < 8; ++i) {
cin >> MAP[i];
if (!cin.eof()) {
return 0;
}
}
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (MAP[i][j] == '1') {
for (int k = 0; k < 7; ++k) {
bool ok = true;
for (int l = 0; l < 4; ++l) {
int nx = j + dx[k][l];
int ny = i + dy[k][l];
if ((0 <= nx && nx < 8 && 0 <= ny && ny < 8 &&
MAP[ny][nx] != '1') ||
(nx < 0 || 8 <= nx || ny < 0 || 8 <= ny)) {
ok = false;
break;
}
}
if (ok) {
cout << ans[k] << "\n";
break;
}
}
}
}
}
}
return 0;
}
|
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int lli;
using namespace std;
int dx[7][4] = {{0, 0, 1, 1}, {0, 0, 0, 0}, {0, 1, 2, 3}, {0, 0, -1, -1},
{0, 1, 1, 2}, {0, 0, 1, 1}, {0, -1, 0, 1}};
int dy[7][4] = {{0, 1, 1, 0}, {0, 1, 2, 3}, {0, 0, 0, 0}, {0, 1, 1, 2},
{0, 0, 1, 1}, {0, 1, 1, 2}, {0, 1, 1, 0}};
string MAP[8];
string ans = "ABCDEFG";
int main() {
while (1) {
for (int i = 0; i < 8; ++i) {
cin >> MAP[i];
if (cin.eof()) {
return 0;
}
}
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (MAP[i][j] == '1') {
for (int k = 0; k < 7; ++k) {
bool ok = true;
for (int l = 0; l < 4; ++l) {
int nx = j + dx[k][l];
int ny = i + dy[k][l];
if ((0 <= nx && nx < 8 && 0 <= ny && ny < 8 &&
MAP[ny][nx] != '1') ||
(nx < 0 || 8 <= nx || ny < 0 || 8 <= ny)) {
ok = false;
break;
}
}
if (ok) {
cout << ans[k] << "\n";
break;
}
}
}
}
}
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111]]
| 1
| 445
| 1
|
#include <iostream>
using namespace std;
int main() {
int num[8];
int pattan[7][4] = {
{11000000, 11000000, 0, 0}, {10000000, 10000000, 10000000, 10000000},
{11110000, 0, 0, 0}, {1000000, 11000000, 10000000, 0},
{11000000, 1100000, 0, 0}, {10000000, 11000000, 1000000, 0},
{1100000, 11000000, 0, 0}};
while (cin >> num[0]) {
for (int i = 1; i < 8; i++)
cin >> num[i];
int t = 0;
while (num[t] == 0)
t++;
// char
for (int i = 0; i < 7; i++) {
// sift
for (int j = 0; j < 8; j++) {
// good mach
int flag = 1, tmp = 1;
for (int k = 0; k < j; k++)
tmp *= 10;
for (int k = 0; k < 4; k++)
if (num[t + k] != (pattan[i][k] / tmp))
flag = 0;
char str = 'A' + i;
if (flag)
cout << str << endl;
}
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int num[8];
int pattan[7][4] = {
{11000000, 11000000, 0, 0}, {10000000, 10000000, 10000000, 10000000},
{11110000, 0, 0, 0}, {1000000, 11000000, 10000000, 0},
{11000000, 1100000, 0, 0}, {10000000, 11000000, 1000000, 0},
{1100000, 11000000, 0, 0}};
while (cin >> num[0]) {
for (int i = 1; i < 8; i++)
cin >> num[i];
int t = 0;
while (num[t] == 0)
t++;
// char
for (int i = 0; i < 7; i++) {
// sift
for (int j = 0; j < 8; j++) {
// good mach
int flag = 1, tmp = 1;
for (int k = 0; k < j; k++)
tmp *= 10;
for (int k = 0; k < 4; k++)
if (num[t + k] != (pattan[i][k] / tmp) && t + k < 8)
flag = 0;
char str = 'A' + i;
if (flag)
cout << str << endl;
}
}
}
return 0;
}
|
[["+", 0, 7, 8, 57, 15, 339, 51, 16, 17, 98], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 31, 22], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 17, 72], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 12, 22], ["+", 8, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 8, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 271
| 6
|
while gets
l = $_.chomp
t = 8
t = 7 if l != ""
t.times do
l << gets.chomp
end
puts "A" if l.include?("1100000011")
puts "B" if l.include?("1000000100000010000001000000")
puts "C" if l.include?("1111")
puts "D" if l.include?("1000000110000001")
puts "E" if l.include?("11000000011")
puts "F" if l.include?("100000001100000001")
puts "G" if l.include?("110000011")
end
|
while gets
l = $_.chomp
t = 8
t = 7 if l != ""
t.times do
l << gets.chomp
end
puts "A" if l.include?("1100000011")
puts "B" if l.include?("1000000010000000100000001")
puts "C" if l.include?("1111")
puts "D" if l.include?("1000000110000001")
puts "E" if l.include?("11000000011")
puts "F" if l.include?("100000001100000001")
puts "G" if l.include?("110000011")
end
|
[["-", 0, 751, 15, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 751, 15, 652, 3, 4, 0, 557, 0, 6]]
| 4
| 120
| 2
|
#encoding=utf-8
import sys
def inp():
fe, fe1 = [], []
for line in sys.stdin:
fe += line.split()
i,j = 0,8
while True:
fe1 = fe[i:j]
if a(fe1):
if b(fe1):
if c(fe1):
if d(fe1):
if e(fe1):
if f(fe1):
if g(fe1):
pass
i, j =i + 8,j + 8
if j > len(fe): break
def a(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i][j+1]==fe1[i+1][j]==fe1[i+1][j+1]=="1":
print("A")
return False
except:
pass
return True
def b(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i+1][j]==fe1[i+2][j]==fe1[i+3][j]=="1":
print("B")
return False
except:
pass
return True
def c(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i][j+1]==fe1[i][j+2]==fe1[i][j+3]=="1":
print("C")
return False
except:
pass
return True
def d(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i+1][j-1]==fe1[i+1][j]==fe1[i+2][j-1]=="1":
print("D")
return False
except:
pass
return True
def e(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i][j+1]==fe1[i+1][j+1]==fe1[i+1][j+2]=="1":
print("E")
return False
except:
pass
return True
def f(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i+1][j]==fe1[i+1][j+1]==fe1[i+2][j+1]=="1":
print("F")
return False
except:
pass
True
def g(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i][j+1]==fe1[i+1][j-1]==fe1[i+1][j]=="1":
print("G")
return False
except:
pass
return True
if __name__ == "__main__":
inp()
|
#encoding=utf-8
import sys
def inp():
fe, fe1 = [], []
for line in sys.stdin:
fe += line.split()
i,j = 0,8
while True:
fe1 = fe[i:j]
if a(fe1):
if b(fe1):
if c(fe1):
if d(fe1):
if e(fe1):
if f(fe1):
if g(fe1):
pass
i, j =i + 8,j + 8
if j > len(fe): break
def a(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i][j+1]==fe1[i+1][j]==fe1[i+1][j+1]=="1":
print("A")
return False
except:
pass
return True
def b(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i+1][j]==fe1[i+2][j]==fe1[i+3][j]=="1":
print("B")
return False
except:
pass
return True
def c(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i][j+1]==fe1[i][j+2]==fe1[i][j+3]=="1":
print("C")
return False
except:
pass
return True
def d(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i+1][j-1]==fe1[i+1][j]==fe1[i+2][j-1]=="1":
print("D")
return False
except:
pass
return True
def e(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i][j+1]==fe1[i+1][j+1]==fe1[i+1][j+2]=="1":
print("E")
return False
except:
pass
return True
def f(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i+1][j]==fe1[i+1][j+1]==fe1[i+2][j+1]=="1":
print("F")
return False
except:
pass
return True
def g(fe1):
for i in range(8):
for j in range(8):
if fe1[i][j] == "1":
try:
if fe1[i][j+1]==fe1[i+1][j-1]==fe1[i+1][j]=="1":
print("G")
return False
except:
pass
return True
if __name__ == "__main__":
inp()
|
[["+", 0, 656, 0, 14, 8, 196, 0, 37, 0, 38]]
| 5
| 732
| 1
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static int[][] mapA = new int[5][4];
static int[][] mapB = new int[4][5];
static int x, y, d;
static boolean flag;
static ArrayList<Character> list = new ArrayList<Character>();
static void U() {
if (flag == true && y > 0 && mapB[y - 1][x] == 1) {
d = 0;
y--;
flag = false;
// System.out.print("U");
list.add('U');
}
}
static void R() {
if (flag == true && x < 4 && mapA[y][x] == 1) {
d = 1;
x++;
flag = false;
// System.out.print("R");
list.add('R');
}
}
static void D() {
if (flag == true && y < 4 && mapB[y][x] == 1) {
d = 2;
y++;
flag = false;
// System.out.print("D");
list.add('D');
}
}
static void L() {
if (flag == true && x > 0 && mapA[y][x - 1] == 1) {
d = 3;
x--;
flag = false;
// System.out.print("L");
list.add('L');
}
}
static void solve() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null) {
for (int i = 0; i < 4; i++)
mapA[0][i] = Integer.parseInt(line.charAt(i) + "");
for (int i = 0; i < 4; i++) {
line = br.readLine();
for (int j = 0; j < 5; j++)
mapB[i][j] = Integer.parseInt(line.charAt(j) + "");
line = br.readLine();
for (int j = 0; j < 4; j++)
mapA[i + 1][j] = Integer.parseInt(line.charAt(j) + "");
}
break;
}
} catch (Exception e) {
}
Scanner sc = new Scanner(System.in);
/*
for(int i=0;i<9;i++){
String s = sc.next();
if(i%2==0){
for(int j=0;j<4;j++) mapA[i/2][j] = s.codePointAt(j)-48;
}else{
for(int j=0;j<5;j++) mapB[i/2][j] = s.codePointAt(j)-48;
}
}*/
x = 0;
y = 0;
d = 1;
while (true) {
flag = true;
if (d == 0) {
L();
U();
R();
D();
} else if (d == 1) {
U();
R();
D();
L();
} else if (d == 2) {
R();
D();
L();
U();
} else if (d == 3) {
D();
L();
U();
R();
}
if (x == 0 && y == 0) {
for (char ch : list)
System.out.println(ch + "");
System.out.println();
break;
}
}
}
static int horW[] = new int[20], verW[] = new int[20];
public static void main(String[] args) {
solve();
if (horW[0] == 0)
return;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
ArrayList<Character> walk = new ArrayList<Character>();
while ((line = br.readLine()) != null) {
for (int i = 0; i < 4; i++)
horW[i] = Integer.parseInt(line.charAt(i) + "");
for (int i = 0; i < 4; i++) {
line = br.readLine();
for (int j = 0; j < 5; j++)
verW[5 * i + j] = Integer.parseInt(line.charAt(j) + "");
line = br.readLine();
for (int j = 0; j < 4; j++)
horW[4 * (i + 1) + j] = Integer.parseInt(line.charAt(j) + "");
}
break;
}
// System.out.println("hW"+Arrays.toString(horW));
// System.out.println("vW"+Arrays.toString(verW));
walk.add('R');
walkon(walk, 1, 0);
for (char ch : walk)
System.out.print(ch + "");
System.out.println("");
} catch (Exception e) {
}
}
static void walkon(ArrayList<Character> walk, int x, int y) {
char preD = walk.get(walk.size() - 1);
char nextD = '1';
int nX = x, nY = y;
int uW = (y == 0) ? 0 : verW[(y - 1) * 5 + x];
int dW = (y == 4) ? 0 : verW[y * 5 + x];
int rW = (x == 4) ? 0 : horW[x + 4 * y];
int lW = (x == 0) ? 0 : horW[x - 1 + 4 * y];
switch (preD) {
case 'R':
if (uW == 1) {
nextD = 'U';
nY--;
} else if (rW == 1) {
nextD = 'R';
nX++;
} else if (dW == 1) {
nextD = 'D';
nY++;
}
break;
case 'U':
if (lW == 1) {
nextD = 'L';
nX--;
} else if (uW == 1) {
nextD = 'U';
nY--;
} else if (rW == 1) {
nextD = 'R';
nX++;
}
break;
case 'L':
if (dW == 1) {
nextD = 'D';
nY++;
} else if (lW == 1) {
nextD = 'L';
nX--;
} else if (uW == 1) {
nextD = 'U';
nY--;
}
break;
case 'D':
if (rW == 1) {
nextD = 'R';
nX++;
} else if (dW == 1) {
nextD = 'D';
nY++;
} else if (lW == 1) {
nextD = 'L';
nX--;
}
break;
}
walk.add(nextD);
if (nX == 0 && nY == 0)
return;
else
walkon(walk, nX, nY);
}
}
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static int[][] mapA = new int[5][4];
static int[][] mapB = new int[4][5];
static int x, y, d;
static boolean flag;
static ArrayList<Character> list = new ArrayList<Character>();
static void U() {
if (flag == true && y > 0 && mapB[y - 1][x] == 1) {
d = 0;
y--;
flag = false;
// System.out.print("U");
list.add('U');
}
}
static void R() {
if (flag == true && x < 4 && mapA[y][x] == 1) {
d = 1;
x++;
flag = false;
// System.out.print("R");
list.add('R');
}
}
static void D() {
if (flag == true && y < 4 && mapB[y][x] == 1) {
d = 2;
y++;
flag = false;
// System.out.print("D");
list.add('D');
}
}
static void L() {
if (flag == true && x > 0 && mapA[y][x - 1] == 1) {
d = 3;
x--;
flag = false;
// System.out.print("L");
list.add('L');
}
}
static void solve() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null) {
for (int i = 0; i < 4; i++)
mapA[0][i] = Integer.parseInt(line.charAt(i) + "");
for (int i = 0; i < 4; i++) {
line = br.readLine();
for (int j = 0; j < 5; j++)
mapB[i][j] = Integer.parseInt(line.charAt(j) + "");
line = br.readLine();
for (int j = 0; j < 4; j++)
mapA[i + 1][j] = Integer.parseInt(line.charAt(j) + "");
}
break;
}
} catch (Exception e) {
}
Scanner sc = new Scanner(System.in);
/*
for(int i=0;i<9;i++){
String s = sc.next();
if(i%2==0){
for(int j=0;j<4;j++) mapA[i/2][j] = s.codePointAt(j)-48;
}else{
for(int j=0;j<5;j++) mapB[i/2][j] = s.codePointAt(j)-48;
}
}*/
x = 0;
y = 0;
d = 1;
while (true) {
flag = true;
if (d == 0) {
L();
U();
R();
D();
} else if (d == 1) {
U();
R();
D();
L();
} else if (d == 2) {
R();
D();
L();
U();
} else if (d == 3) {
D();
L();
U();
R();
}
if (x == 0 && y == 0) {
for (char ch : list)
System.out.print(ch + "");
System.out.println();
break;
}
}
}
static int horW[] = new int[20], verW[] = new int[20];
public static void main(String[] args) {
solve();
if (horW[0] == 0)
return;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
ArrayList<Character> walk = new ArrayList<Character>();
while ((line = br.readLine()) != null) {
for (int i = 0; i < 4; i++)
horW[i] = Integer.parseInt(line.charAt(i) + "");
for (int i = 0; i < 4; i++) {
line = br.readLine();
for (int j = 0; j < 5; j++)
verW[5 * i + j] = Integer.parseInt(line.charAt(j) + "");
line = br.readLine();
for (int j = 0; j < 4; j++)
horW[4 * (i + 1) + j] = Integer.parseInt(line.charAt(j) + "");
}
break;
}
// System.out.println("hW"+Arrays.toString(horW));
// System.out.println("vW"+Arrays.toString(verW));
walk.add('R');
walkon(walk, 1, 0);
for (char ch : walk)
System.out.print(ch + "");
System.out.println("");
} catch (Exception e) {
}
}
static void walkon(ArrayList<Character> walk, int x, int y) {
char preD = walk.get(walk.size() - 1);
char nextD = '1';
int nX = x, nY = y;
int uW = (y == 0) ? 0 : verW[(y - 1) * 5 + x];
int dW = (y == 4) ? 0 : verW[y * 5 + x];
int rW = (x == 4) ? 0 : horW[x + 4 * y];
int lW = (x == 0) ? 0 : horW[x - 1 + 4 * y];
switch (preD) {
case 'R':
if (uW == 1) {
nextD = 'U';
nY--;
} else if (rW == 1) {
nextD = 'R';
nX++;
} else if (dW == 1) {
nextD = 'D';
nY++;
}
break;
case 'U':
if (lW == 1) {
nextD = 'L';
nX--;
} else if (uW == 1) {
nextD = 'U';
nY--;
} else if (rW == 1) {
nextD = 'R';
nX++;
}
break;
case 'L':
if (dW == 1) {
nextD = 'D';
nY++;
} else if (lW == 1) {
nextD = 'L';
nX--;
} else if (uW == 1) {
nextD = 'U';
nY--;
}
break;
case 'D':
if (rW == 1) {
nextD = 'R';
nX++;
} else if (dW == 1) {
nextD = 'D';
nY++;
} else if (lW == 1) {
nextD = 'L';
nX--;
}
break;
}
walk.add(nextD);
if (nX == 0 && nY == 0)
return;
else
walkon(walk, nX, nY);
}
}
|
[["-", 64, 196, 0, 514, 8, 1, 0, 492, 141, 22], ["+", 64, 196, 0, 514, 8, 1, 0, 492, 141, 22]]
| 3
| 1,341
| 2
|
require("fs")
.readFileSync("/dev/stdin", "utf8")
.split('\n')
.slice(-1)
.map(function(i) {
for (t = 26; t--;)
for (s = 26; s--;)
r = i.replace(/[\w]/g, function(j) {
return String.fromCharCode((j.charCodeAt(0) * t + s) % 26 + 97)
}), r.match(/th(is|at)/) ? console.log(r) : 0
})
|
require("fs").readFileSync("/dev/stdin", "utf8").split('\n').map(function(i) {
for (t = 26; t--;)
for (s = 26; s--;)
r = i.replace(/[\w]/g, function(j) {
return String.fromCharCode((j.charCodeAt(0) * t + s) % 26 + 97)
}), r.match(/th(is|at)/) ? console.log(r) : 0
})
|
[["-", 0, 2, 63, 558, 500, 2, 63, 558, 559, 560], ["-", 0, 2, 63, 558, 500, 2, 3, 3, 0, 24], ["-", 63, 558, 500, 2, 3, 3, 0, 91, 17, 33], ["-", 63, 558, 500, 2, 3, 3, 0, 91, 28, 555], ["-", 0, 2, 63, 558, 500, 2, 3, 3, 0, 25], ["-", 0, 493, 0, 1, 0, 2, 63, 558, 0, 131]]
| 2
| 118
| 6
|
#!ruby -p
$.>1&&(1..97).find{|i|(1..26).find{|j|/th[ai]/=~$s=$_.bytes.map{|c|(c<97?c:97+(c%26*i+j)%26).chr}*""}}
$_=$s
|
#!ruby -p
$.>1&&(1..26).find{|i|(1..26).find{|j|/th(at|is)/=~$s=$_.bytes.map{|c|(c<97?c:97+(c%26*i+j)%26).chr}*""}}
$_=$s
|
[["-", 0, 738, 12, 652, 486, 739, 0, 475, 444, 612], ["+", 0, 738, 12, 652, 486, 739, 0, 475, 444, 612], ["-", 196, 196, 8, 734, 0, 738, 31, 575, 0, 6], ["+", 196, 196, 8, 734, 0, 738, 31, 575, 0, 6]]
| 4
| 74
| 12
|
for _ in[0]*int(input()):
e=input()
for i in range(26,2):
for j in range(26):
a=''.join([c,chr(((ord(c)-97)*i+j)%26+97)][c.islower()]for c in e)
if('that'or'this')in a:print(a);break
|
for _ in[0]*int(input()):
e=input()
for i in range(26):
for j in range(26):
a=''.join([c,chr(((ord(c)-97)*i+j)%26+97)][c.islower()]for c in e)
if'that'in a or'this'in a:print(a);break
|
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 8, 196, 0, 57, 15, 666, 0, 23, 0, 24], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 667, 267], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 23, 0, 25]]
| 5
| 100
| 6
|
for i in range(int(input())):
s = input()
for a in range(1, 1000):
for b in range(26):
def f(s, a, b):
return ''.join([chr(((ord(c) - ord('a')) * a + b) % 26 + ord('a')) for c in s])
if f('that', a, b) in s or f('this', a, b) in s:
dic = dict([(chr((i * a + b) % 26 + ord('a')), chr(i + ord('a'))) for i in range(26)])
print(dic)
print(''.join([dic.get(c, c) for c in s]))
break
else:
continue
break
|
for i in range(int(input())):
s = input()
for a in range(1, 1000):
for b in range(26):
def f(s, a, b):
return ''.join([chr(((ord(c) - ord('a')) * a + b) % 26 + ord('a')) for c in s])
if f('that', a, b) in s or f('this', a, b) in s:
dic = dict([(chr((i * a + b) % 26 + ord('a')), chr(i + ord('a'))) for i in range(26)])
print(''.join([dic.get(c, c) for c in s]))
break
else:
continue
break
|
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24]]
| 5
| 196
| 4
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUF_UNIT_SIZE 10000
#define MAX_LINE_LENGTH 1000
typedef struct {
int x, y;
} vector_t;
void complex_mul(const vector_t *v1, const vector_t *v2, vector_t *t) {
t->x = v1->x * v2->x - v1->y * v2->y;
t->y = v1->x * v2->y + v1->y * v2->x;
}
char *bufp[100], *wall[1000], path[10000];
const vector_t next_dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
const char dir_char[][3] = {{' ', 'U', ' '}, {'L', ' ', 'R'}, {' ', 'D', ' '}};
int main(void) {
int W, H, i;
int buf_idx, buf_len, path_idx, nx, ny;
char *buf;
vector_t pos, dir, ndir;
buf_idx = 0;
buf_len = 0;
buf = (char *)malloc(BUF_UNIT_SIZE * sizeof(char));
bufp[buf_idx++] = buf;
for (i = 0, W = 0; gets(buf) != NULL; i++) {
wall[i] = buf;
if (W == 0)
W = strlen(buf);
buf_len += strlen(buf) + 1;
if (buf_len + MAX_LINE_LENGTH > BUF_UNIT_SIZE) {
buf = (char *)malloc(BUF_UNIT_SIZE * sizeof(char));
bufp[buf_idx++] = buf;
buf_len = 0;
} else {
buf += strlen(buf) + 1;
}
}
H = i;
path_idx = 0;
path[path_idx++] = 'R';
pos.x = 0;
pos.y = 0;
dir.x = 1;
dir.y = 0;
while (1) {
for (i = 0; i < 3; i++) {
complex_mul(&dir, &next_dir[i], &ndir);
if ((pos.y & 1) == 0) {
ny = pos.y + ndir.y;
nx = pos.x + ndir.x + (dir.x > 0) * ((ny + 2) & 1);
} else {
ny = pos.y + ndir.y + dir.y;
nx = pos.x + ndir.x - (ndir.x > 0);
}
if (nx < 0 || W + (ny & 1) <= nx || ny < 0 || H <= ny)
continue;
if (wall[ny][nx] == '1')
break;
}
if (i == 3) {
dir.x = -dir.x;
dir.y = -dir.y;
} else {
pos.x = nx;
pos.y = ny;
dir.x = ndir.x;
dir.y = ndir.y;
}
path[path_idx++] = dir_char[1 + dir.y][1 + dir.x];
if ((pos.x == 0 && pos.y == 0 && dir.x == -1) ||
(pos.x == 0 && pos.y == 1 && dir.y == -1))
break;
}
path[path_idx] = '\0';
puts(path);
for (i = 0; i < buf_idx; i++) {
free(bufp[i]);
}
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUF_UNIT_SIZE 10000
#define MAX_LINE_LENGTH 1000
typedef struct {
int x, y;
} vector_t;
void complex_mul(const vector_t *v1, const vector_t *v2, vector_t *t) {
t->x = v1->x * v2->x - v1->y * v2->y;
t->y = v1->x * v2->y + v1->y * v2->x;
}
char *bufp[100], *wall[1000], path[10000];
const vector_t next_dir[] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
const char dir_char[][3] = {{' ', 'U', ' '}, {'L', ' ', 'R'}, {' ', 'D', ' '}};
int main(void) {
int W, H, i;
int buf_idx, buf_len, path_idx, nx, ny;
char *buf;
vector_t pos, dir, ndir;
buf_idx = 0;
buf_len = 0;
buf = (char *)malloc(BUF_UNIT_SIZE * sizeof(char));
bufp[buf_idx++] = buf;
for (i = 0, W = 0; gets(buf) != NULL; i++) {
wall[i] = buf;
if (W == 0)
W = strlen(buf);
buf_len += strlen(buf) + 1;
if (buf_len + MAX_LINE_LENGTH > BUF_UNIT_SIZE) {
buf = (char *)malloc(BUF_UNIT_SIZE * sizeof(char));
bufp[buf_idx++] = buf;
buf_len = 0;
} else {
buf += strlen(buf) + 1;
}
}
H = i;
path_idx = 0;
path[path_idx++] = 'R';
pos.x = 0;
pos.y = 0;
dir.x = 1;
dir.y = 0;
while (1) {
for (i = 0; i < 3; i++) {
complex_mul(&dir, &next_dir[i], &ndir);
if ((pos.y & 1) == 0) {
ny = pos.y + ndir.y;
nx = pos.x + ndir.x + (dir.x > 0) * ((ny + 2) & 1);
} else {
ny = pos.y + ndir.y + dir.y;
nx = pos.x + ndir.x - (ndir.x > 0);
}
if (nx < 0 || W + (ny & 1) <= nx || ny < 0 || H <= ny)
continue;
if (wall[ny][nx] == '1')
break;
}
if (i == 3) {
dir.x = -dir.x;
dir.y = -dir.y;
} else {
pos.x = nx;
pos.y = ny;
dir.x = ndir.x;
dir.y = ndir.y;
}
path[path_idx++] = dir_char[1 + dir.y][1 + dir.x];
if ((pos.x == 0 && pos.y == 0 && dir.x == -1) ||
(pos.x == 0 && pos.y == 1 && dir.y == -1))
break;
}
path[path_idx] = '\0';
puts(path);
for (i = 0; i < buf_idx; i++) {
free(bufp[i]);
}
return 0;
}
|
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
| 0
| 724
| 4
|
#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const char ch[] = {"ULDR"};
bool g[10][10][10][10];
int main() {
char c;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 4; j++) {
scanf(" %c", &c);
if (c == '0')
continue;
g[i][j][i][j + 1] = true;
g[i][j + 1][i][j] = true;
}
if (i == 5)
continue;
for (int j = 1; j <= 5; j++) {
scanf(" %c", &c);
if (c == '0')
continue;
g[i][j][i + 1][j] = true;
g[i + 1][j][i][j] = true;
}
}
int dir = 3;
int x = 1, y = 2;
while (true) {
printf("%c", ch[dir]);
if (x == 1 && y == 1)
break;
for (int t = -1; t <= 2; t++) {
int nd = (dir + t + 4) % 4;
int nx = x + dx[nd];
int ny = y + dy[nd];
if (g[x][y][nx][ny]) {
x = nx;
y = ny;
dir = nd;
break;
}
}
}
puts("");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const char ch[] = {"ULDR"};
bool g[10][10][10][10];
int main() {
char c;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 4; j++) {
scanf(" %c", &c);
if (c == '0')
continue;
g[i][j][i][j + 1] = true;
g[i][j + 1][i][j] = true;
}
if (i == 5)
continue;
for (int j = 1; j <= 5; j++) {
scanf(" %c", &c);
if (c == '0')
continue;
g[i][j][i + 1][j] = true;
g[i + 1][j][i][j] = true;
}
}
int dir = 3;
int x = 1, y = 2;
while (true) {
printf("%c", ch[dir]);
if (x == 1 && y == 1)
break;
for (int t = 1; t >= -2; t--) {
int nd = (dir + t + 4) % 4;
int nx = x + dx[nd];
int ny = y + dy[nd];
if (g[x][y][nx][ny]) {
x = nx;
y = ny;
dir = nd;
break;
}
}
}
puts("");
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 20], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 17, 68]]
| 1
| 376
| 8
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))
template <typename T> void FILL_(void *ptr, size_t size, T value) {
std::fill((T *)ptr, (T *)ptr + size, value);
}
//参考http://hadrori.hateblo.jp/entry/aoj0037
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int path[16][16][4]; // 0:L,1:U,2:R,3:D
int main() {
char c;
for (int i = 0; i < 9; i++) {
if (i % 2) {
for (int j = 0; j < 5; j++) {
cin >> c;
if (c == '1') {
path[i / 2][j][3] = 1;
path[i / 2 + 1][j][1] = 1;
}
}
} else {
for (int j = 0; j < 4; j++) {
cin >> c;
if (c == '1') {
path[i / 2][j][2] = 1;
path[i / 2][j + 1][0] = 1;
}
}
}
}
int x = 0, y = 0, d = 2;
/*
(前の方向:右 の場合)
進む方向の優先順位は、上、右、下、左となる。
(前の方向:左 の場合)
進む方向の優先順位は、下、左、上、右となる。
(前の方向:上 の場合)
進む方向の優先順位は、左、上、右、下となる。
(前の方向:下 の場合)
進む方向の優先順位は、右、下、左、上となる。*/
string dir = "LURD";
do {
for (int i = 0; i < 4; i++) {
int dd = (d + i) % 4;
if (path[y][x][dd] == 1) {
path[y][x][dd] -= 1;
x += dx[dd];
y += dy[dd];
d = dd;
cout << dir[dd];
break;
}
}
} while (x || y);
cout << endl;
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))
template <typename T> void FILL_(void *ptr, size_t size, T value) {
std::fill((T *)ptr, (T *)ptr + size, value);
}
//参考http://hadrori.hateblo.jp/entry/aoj0037
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int path[16][16][4]; // 0:L,1:U,2:R,3:D
int main() {
char c;
for (int i = 0; i < 9; i++) {
if (i % 2) {
for (int j = 0; j < 5; j++) {
cin >> c;
if (c == '1') {
path[i / 2][j][3] = 1;
path[i / 2 + 1][j][1] = 1;
}
}
} else {
for (int j = 0; j < 4; j++) {
cin >> c;
if (c == '1') {
path[i / 2][j][2] = 1;
path[i / 2][j + 1][0] = 1;
}
}
}
}
int x = 0, y = 0, d = 2;
/*
(前の方向:右 の場合)
進む方向の優先順位は、上、右、下、左となる。
(前の方向:左 の場合)
進む方向の優先順位は、下、左、上、右となる。
(前の方向:上 の場合)
進む方向の優先順位は、左、上、右、下となる。
(前の方向:下 の場合)
進む方向の優先順位は、右、下、左、上となる。*/
string dir = "LURD";
do {
for (int i = 0; i < 4; i++) {
int dd = (d + i + 3) % 4;
if (path[y][x][dd] == 1) {
path[y][x][dd] -= 1;
x += dx[dd];
y += dy[dd];
d = dd;
cout << dir[dd];
break;
}
}
} while (x || y);
cout << endl;
return 0;
}
|
[["+", 49, 50, 51, 16, 31, 23, 0, 16, 17, 72], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 12, 13]]
| 1
| 455
| 2
|
d=2
map=*$<
o=?R
x,y=1,0
(u,v=1,1
(d+=1
u=x+[0,0,-1,0][d%4]
v=y+[0,1,0,-1][d%4]
)until u>=0&&v>=0&&v<9&&map[v][u]==?1
e=d%4
x+=[1,0,-1,0][e]
y+=[0,2,0,-2][e]
o+="RDLU"[e]
d+=2
)while [x,y]!=[0,0]
puts o
|
d=2
map=*$<
o=?R
x,y=1,0
(u,v=9,9
(d+=1
u=x+[0,0,-1,0][d%4]
v=y+[0,1,0,-1][d%4]
)until u>=0&&v>=0&&v<9&&map[v][u]==?1
e=d%4
x+=[1,0,-1,0][e]
y+=[0,2,0,-2][e]
o+="RDLU"[e]
d+=2
)while [x,y]!=[0,0]
puts o
|
[["-", 0, 740, 8, 739, 0, 662, 12, 762, 0, 612], ["+", 0, 740, 8, 739, 0, 662, 12, 762, 0, 612]]
| 4
| 151
| 4
|
g=[[0]*5 for _ in[0]*5]
for i in range(9):
e=input()
for j in range(4+i%2):
if int(e[j]):
if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1
else:r=g[i//2];r[j]+=2;r[j+1]+=8
y,x=0,1
k=1
a=[1]
while 1:
k+=2
for _ in[0]*4:
k+=1
if g[y][x]&int(2**(k%4)):a+=[k%4];break
if k%2:x+=1-2*((k%4)>0)
else:y+=2*((k%4)>0)-1
if x+y==0:break
print(''.join('URDL'[c]for c in a))
|
g=[[0]*5 for _ in[0]*5]
for i in range(9):
e=input()
for j in range(4+i%2):
if int(e[j]):
if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1
else:r=g[i//2];r[j]+=2;r[j+1]+=8
y,x=0,1
k=1
a=[1]
while 1:
k+=2
for _ in[0]*4:
k+=1
if g[y][x]&int(2**(k%4)):a+=[k%4];break
if k%2:x+=1-2*((k%4)>1)
else:y+=2*((k%4)>0)-1
if x+y<1:break
print(''.join('URDL'[c]for c in a))
|
[["-", 12, 657, 12, 657, 12, 23, 0, 666, 0, 612], ["+", 12, 657, 12, 657, 12, 23, 0, 666, 0, 612], ["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 60], ["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612]]
| 5
| 233
| 6
|
import sys
grid=[line.strip() for line in sys.stdin.readlines()]
xgrid=["0"+grid[i]+"0" for i in range(9) if i%2==0]
ygrid=[grid[i] for i in range(9) if i%2==1]
ygrid.insert(5,"0"*5)
ygrid.insert(0,"0"*5)
graph=[[None]*5 for i in range(5)]
#0->north 1->east...
for y in range(5):
for x in range(5):
graph[y][x]=[ygrid[y][x],xgrid[y][x+1],ygrid[y+1][x],xgrid[y][x]]
#right hand ->dir+1
nx,ny,dir=0,0,1
DIRECTION=["U","R","D","L",]
dx=[0,1,0,-1]
dy=[-1,0,1,0]
log=[]
while True:
for i in range(4):
if graph[ny][nx][(dir+1)%4]=="1":
dir=(dir+1)%4
log.append(DIRECTION[dir])
nx,ny=nx+dx[dir],ny+dy[dir]
break
dir=(dir-1)%4
if nx==0 and ny==0:break
print("".join(log))
|
import sys
grid=[line.strip() for line in sys.stdin.readlines()]
xgrid=["0"+grid[i]+"0" for i in range(9) if i%2==0]
ygrid=[grid[i] for i in range(9) if i%2==1]
ygrid.insert(5,"0"*5)
ygrid.insert(0,"0"*5)
graph=[[None]*5 for i in range(5)]
for y in range(5):
for x in range(5):
graph[y][x]=[ygrid[y][x],xgrid[y][x+1],ygrid[y+1][x],xgrid[y][x]]
nx,ny,dir=0,0,1
DIRECTION=["U","R","D","L",]
dx=[0,1,0,-1]
dy=[-1,0,1,0]
log=[]
while True:
for i in range(4):
if graph[ny][nx][(dir+3)%4]=="1":
dir=(dir+3)%4
log.append(DIRECTION[dir])
nx,ny=nx+dx[dir],ny+dy[dir]
break
dir=(dir+1)%4
if nx==0 and ny==0:break
print("".join(log))
|
[["-", 0, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["-", 0, 662, 12, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 12, 612], ["-", 0, 662, 12, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 17, 72]]
| 5
| 331
| 6
|
import sys
class Grid:
def __init__(self, lines):
lines = list(map((lambda line: list(line)), lines))
l = []
for i in range(len(lines)):
if i % 2 == 0:
l.append(intersperse2(lines[i], '+'))
else:
l.append(intersperse(lines[i], 'x'))
l.insert(0, ['0','x','0','x','0','x','0','x','0'])
l.append(['0','x','0','x','0','x','0','x','0'])
l = [self._outer(x) for x in l]
self.grid = l
def show(self):
for l in self.grid:
print(l)
return self
def _outer(self, lis):
if lis[0] == '0' or lis[0] == '1':
lis.insert(0, 'x')
else:
lis.insert(0, '0')
if lis[-1] == '0' or lis[-1] == '1':
lis.append('x')
else:
lis.append('0')
return lis
class Walker:
def __init__(self, grid, x, y):
self.grid = grid
self.x = x
self.y = y
self.dir = 'R'
def walk(self):
if self.left() == '1':
return self.to_left()
elif self.ahead() == '1':
return self.to_ahead()
elif self.right() == '1':
return self.to_right()
else:
return self.to_back()
def left(self):
x = self.x
y = self.y
d = self.dir
if d == 'R':
return self.grid.grid[y-1][x]
elif d == 'L':
return self.grid.grid[y+1][x]
elif d == 'U':
return self.grid.grid[y][x-1]
else: # d == 'D'
return self.grid.grid[y][x+1]
def ahead(self):
x = self.x
y = self.y
d = self.dir
if d == 'R':
return self.grid.grid[y][x+1]
elif d == 'L':
return self.grid.grid[y][x-1]
elif d == 'U':
return self.grid.grid[y-1][x]
else: # d == 'D'
return self.grid.grid[y+1][x]
def right(self):
x = self.x
y = self.y
d = self.dir
if d == 'R':
return self.grid.grid[y+1][x]
elif d == 'L':
return self.grid.grid[y-1][x]
elif d == 'U':
return self.grid.grid[y][x+1]
else: # d == 'D'
return self.grid.grid[y][x-1]
def to_left(self):
d = self.dir
if d == 'R':
self.y -= 2
self.dir = 'U'
return 'U'
elif d == 'L':
self.y += 2
self.dir = 'D'
return 'D'
elif d == 'U':
self.x -= 2
self.dir = 'L'
return 'L'
else: # d == 'D'
self.x += 2
self.dir = 'R'
return 'R'
def to_ahead(self):
d = self.dir
if d == 'R':
self.x += 2
return 'R'
elif d == 'L':
self.x -= 2
return 'L'
elif d == 'U':
self.y -= 2
return 'U'
else: # d == 'D'
self.y += 2
return 'D'
def to_right(self):
d = self.dir
if d == 'R':
self.y += 2
self.dir = 'D'
return 'D'
elif d == 'L':
self.y -= 2
self.dir = 'U'
return 'U'
elif d == 'U':
self.x += 2
self.dir = 'R'
return 'R'
else: # d == 'D'
self.x -= 2
self.dir = 'L'
return 'L'
def to_backt(self):
d = self.dir
if d == 'R':
self.x -= 2
self.dir = 'L'
return 'L'
elif d == 'L':
self.x += 2
self.dir = 'R'
return 'R'
elif d == 'U':
self.y -= 2
self.dir = 'D'
return 'D'
else: # d == 'D'
self.y += 2
self.dir = 'U'
return 'U'
def intersperse(lis, s):
r = []
for a in lis:
r.append(a)
r.append(s)
r.pop()
return r
def intersperse2(lis, s):
r = []
for a in lis:
r.append(s)
r.append(a)
r.append(s)
return r
lines = sys.stdin.readlines()
lines = [x.rstrip("\r\n") for x in lines]
grid = Grid(lines)
#grid.show()
walker = Walker(grid, 1, 1)
path = []
while True:
path.append(walker.walk())
if (walker.x, walker.y) == (1,1):
break
print(''.join(path))
|
import sys
class Grid:
def __init__(self, lines):
lines = list(map((lambda line: list(line)), lines))
l = []
for i in range(len(lines)):
if i % 2 == 0:
l.append(intersperse2(lines[i], '+'))
else:
l.append(intersperse(lines[i], 'x'))
l.insert(0, ['0','x','0','x','0','x','0','x','0'])
l.append(['0','x','0','x','0','x','0','x','0'])
l = [self._outer(x) for x in l]
self.grid = l
def show(self):
for l in self.grid:
print(l)
return self
def _outer(self, lis):
if lis[0] == '0' or lis[0] == '1':
lis.insert(0, 'x')
else:
lis.insert(0, '0')
if lis[-1] == '0' or lis[-1] == '1':
lis.append('x')
else:
lis.append('0')
return lis
class Walker:
def __init__(self, grid, x, y):
self.grid = grid
self.x = x
self.y = y
self.dir = 'R'
def walk(self):
if self.left() == '1':
return self.to_left()
elif self.ahead() == '1':
return self.to_ahead()
elif self.right() == '1':
return self.to_right()
else:
return self.to_back()
def left(self):
x = self.x
y = self.y
d = self.dir
if d == 'R':
return self.grid.grid[y-1][x]
elif d == 'L':
return self.grid.grid[y+1][x]
elif d == 'U':
return self.grid.grid[y][x-1]
else: # d == 'D'
return self.grid.grid[y][x+1]
def ahead(self):
x = self.x
y = self.y
d = self.dir
if d == 'R':
return self.grid.grid[y][x+1]
elif d == 'L':
return self.grid.grid[y][x-1]
elif d == 'U':
return self.grid.grid[y-1][x]
else: # d == 'D'
return self.grid.grid[y+1][x]
def right(self):
x = self.x
y = self.y
d = self.dir
if d == 'R':
return self.grid.grid[y+1][x]
elif d == 'L':
return self.grid.grid[y-1][x]
elif d == 'U':
return self.grid.grid[y][x+1]
else: # d == 'D'
return self.grid.grid[y][x-1]
def to_left(self):
d = self.dir
if d == 'R':
self.y -= 2
self.dir = 'U'
return 'U'
elif d == 'L':
self.y += 2
self.dir = 'D'
return 'D'
elif d == 'U':
self.x -= 2
self.dir = 'L'
return 'L'
else: # d == 'D'
self.x += 2
self.dir = 'R'
return 'R'
def to_ahead(self):
d = self.dir
if d == 'R':
self.x += 2
return 'R'
elif d == 'L':
self.x -= 2
return 'L'
elif d == 'U':
self.y -= 2
return 'U'
else: # d == 'D'
self.y += 2
return 'D'
def to_right(self):
d = self.dir
if d == 'R':
self.y += 2
self.dir = 'D'
return 'D'
elif d == 'L':
self.y -= 2
self.dir = 'U'
return 'U'
elif d == 'U':
self.x += 2
self.dir = 'R'
return 'R'
else: # d == 'D'
self.x -= 2
self.dir = 'L'
return 'L'
def to_back(self):
d = self.dir
if d == 'R':
self.x -= 2
self.dir = 'L'
return 'L'
elif d == 'L':
self.x += 2
self.dir = 'R'
return 'R'
elif d == 'U':
self.y += 2
self.dir = 'D'
return 'D'
else: # d == 'D'
self.y -= 2
self.dir = 'U'
return 'U'
def intersperse(lis, s):
r = []
for a in lis:
r.append(a)
r.append(s)
r.pop()
return r
def intersperse2(lis, s):
r = []
for a in lis:
r.append(s)
r.append(a)
r.append(s)
return r
lines = sys.stdin.readlines()
lines = [x.rstrip("\r\n") for x in lines]
grid = Grid(lines)
walker = Walker(grid, 1, 1)
path = []
while True:
path.append(walker.walk())
if (walker.x, walker.y) == (1,1):
break
print(''.join(path))
|
[["-", 0, 656, 0, 682, 8, 196, 0, 14, 141, 22], ["+", 0, 656, 0, 682, 8, 196, 0, 14, 141, 22], ["-", 75, 665, 64, 196, 0, 1, 0, 677, 17, 110], ["+", 75, 665, 64, 196, 0, 1, 0, 677, 17, 107], ["-", 75, 76, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 17, 110]]
| 5
| 1,236
| 6
|
wx=[]
wy=[]
def readdata():
it=0
x=[]
y=[]
while True:
try: tmp = list(map(int,input()))
except:
return x,y
if it%2==0:
x.append(tmp)
else:
y.append(tmp)
it +=1
def nextpath(p, dir0):
# 0:north, 1:east, 2:south, 3:west
tmp = ispath(p, (dir0+3)%4)
if tmp!=[]: return tmp
tmp = ispath(p, dir0)
if tmp!=[]: return tmp
tmp = ispath(p, (dir0+1)%4)
if tmp!=[]: return tmp
tmp = ispath(p, (dir0+2)%4)
if tmp!=[]: return tmp
return tmp
def ispath(p,dir1):
y,x = p
if dir1==0:
if y>0 and wy[y-1][x]==1: return [-1,0]
else: return []
elif dir1==1:
if x<len(wx[0]) and wx[y][x]==1: return [0,1]
else: return []
elif dir1==2:
if y<len(wy[0])-1 and wy[y][x]==1: return [1,0]
else: return []
elif dir1==3:
if x>0 and wx[y][x-1]==1: return [0,-1]
else: return []
return []
def f0037():
p =[0,0]
direction = 1
msg = []
while True:
dp = nextpath(p, direction)
p[0] += dp[0]
p[1] += dp[1]
if dp == [0,1]:
direction = 1
msg.append("R")
elif dp == [0,-1]:
direction = 3
msg.append("L")
elif dp == [1,0]:
direction = 2
msg.append("U")
elif dp == [-1,0]:
direction = 0
msg.append("U")
if p==[0,0]: break
return msg
wx, wy = readdata()
msg = f0037()
print("".join(msg))
|
wx=[]
wy=[]
def readdata():
it=0
x=[]
y=[]
while True:
try: tmp = list(map(int,input()))
except:
return x,y
if it%2==0:
x.append(tmp)
else:
y.append(tmp)
it +=1
def nextpath(p, dir0):
tmp = ispath(p, (dir0+3)%4)
if tmp!=[]: return tmp
tmp = ispath(p, dir0)
if tmp!=[]: return tmp
tmp = ispath(p, (dir0+1)%4)
if tmp!=[]: return tmp
tmp = ispath(p, (dir0+2)%4)
if tmp!=[]: return tmp
return tmp
def ispath(p,dir1):
y,x = p
if dir1==0:
if y>0 and wy[y-1][x]==1: return [-1,0]
else: return []
elif dir1==1:
if x<len(wx[0]) and wx[y][x]==1: return [0,1]
else: return []
elif dir1==2:
if y<len(wy[0])-1 and wy[y][x]==1: return [1,0]
else: return []
elif dir1==3:
if x>0 and wx[y][x-1]==1: return [0,-1]
else: return []
return []
def f0037():
p =[0,0]
direction = 1
msg = []
while True:
dp = nextpath(p, direction)
p[0] += dp[0]
p[1] += dp[1]
if dp == [0,1]:
direction = 1
msg.append("R")
elif dp == [0,-1]:
direction = 3
msg.append("L")
elif dp == [1,0]:
direction = 2
msg.append("D")
elif dp == [-1,0]:
direction = 0
msg.append("U")
if p==[0,0]: break
return msg
wx, wy = readdata()
msg = f0037()
print("".join(msg))
|
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
| 5
| 489
| 2
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (stdIn.hasNext()) {
String str = stdIn.nextLine();
int[] number = new int[5];
int[] count = new int[14];
int j = 0;
for (int i = 0; i < str.length(); i++) {
if ('0' <= str.charAt(i) && str.charAt(i) <= '9') {
number[j] = number[j] * 10;
number[j] += (int)str.charAt(i) - (int)'0';
} else {
j++;
}
}
Arrays.sort(number);
j = 0;
int k = 0;
int count_x = 0;
while (k < number.length) {
if (number[k] == j) {
count[j]++;
if (0 < k) {
if (number[k] - number[k - 1] == 1) {
count_x++;
} else {
count_x = 0;
}
}
k++;
} else {
j++;
}
}
int count_3 = 0;
int count_2 = 0;
for (int i = 0; i < 14; i++) {
if (count[i] == 4) {
System.out.println("four card");
break;
} else if (count[i] == 3) {
count_3++;
} else if (count[i] == 2) {
count_2++;
}
if (count_3 == 1 && count_2 == 1) {
System.out.println("full house");
break;
} else if (i == 12) {
if (count_x == 4 ||
(count_x == 3 && number[0] == 1 && number[1] != 1)) {
System.out.println("straight");
break;
} else if (count_3 == 1) {
System.out.println("three card");
break;
} else if (count_2 == 2) {
System.out.println("two pair");
break;
} else if (count_2 == 1) {
System.out.println("one pair");
break;
} else {
System.out.println("null");
break;
}
}
}
}
}
}
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (stdIn.hasNext()) {
String str = stdIn.nextLine();
int[] number = new int[5];
int[] count = new int[14];
int j = 0;
for (int i = 0; i < str.length(); i++) {
if ('0' <= str.charAt(i) && str.charAt(i) <= '9') {
number[j] = number[j] * 10;
number[j] += (int)str.charAt(i) - (int)'0';
} else {
j++;
}
}
Arrays.sort(number);
j = 0;
int k = 0;
int count_x = 0;
while (k < number.length) {
if (number[k] == j) {
count[j]++;
if (0 < k) {
if (number[k] - number[k - 1] == 1) {
count_x++;
} else {
count_x = 0;
}
}
k++;
} else {
j++;
}
}
int count_3 = 0;
int count_2 = 0;
for (int i = 0; i < 14; i++) {
if (count[i] == 4) {
System.out.println("four card");
break;
} else if (count[i] == 3) {
count_3++;
} else if (count[i] == 2) {
count_2++;
}
if (count_3 == 1 && count_2 == 1) {
System.out.println("full house");
break;
}
if (i == 13) {
if (count_x == 4 ||
(count_x == 3 && number[0] == 1 && number[1] == 10)) {
System.out.println("straight");
break;
} else if (count_3 == 1) {
System.out.println("three card");
break;
} else if (count_2 == 2) {
System.out.println("two pair");
break;
} else if (count_2 == 1) {
System.out.println("one pair");
break;
} else {
System.out.println("null");
break;
}
}
}
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 57, 75, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["-", 0, 16, 12, 23, 0, 16, 12, 16, 17, 79], ["-", 0, 16, 12, 23, 0, 16, 12, 16, 12, 499], ["+", 0, 16, 12, 23, 0, 16, 12, 16, 17, 60], ["+", 0, 16, 12, 23, 0, 16, 12, 16, 12, 499]]
| 3
| 491
| 7
|
/**
*
* No.0038 Poker Hand
*
*
* @author yuichirw <y.iky917@gmail.com>
* @see
* http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0038&lang=jp
*/
import static java.lang.Math.*;
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static int[] cards;
static boolean read() {
if (!sc.hasNext())
return false;
String[] parsed = sc.next().split(",");
cards = new int[5];
for (int i = 0; i < 5; i++) {
cards[i] = Integer.parseInt(parsed[i]);
}
return true;
}
static String solve() {
char[] histgram = new char[14];
for (int i = 0; i < 5; i++) {
histgram[cards[i]]++;
}
Arrays.sort(histgram);
int a, b;
a = histgram[histgram.length - 1];
b = histgram[histgram.length - 2];
if (a == 4) {
return "four cards";
}
Arrays.sort(cards);
boolean straight = false;
int cnt = 0, c = 0, d = 0;
for (int i = 0; i < 5; i++) {
cnt = 0;
for (int j = 0; j < 4; j++) {
c = cards[(i + j) % 5];
d = cards[(i + j + 1) % 5];
if (abs(c - d) != 1 && abs(c - d) != 12)
break;
cnt++;
if (abs(c - d) == 12 && cnt <= 4)
break;
}
if (cnt == 4) {
straight = true;
break;
}
}
if (a == 3 && b == 2) {
return "full house";
}
if (straight) {
return "straight";
}
if (a == 3) {
return "three card";
}
if (a == 2 && b == 2) {
return "two pair";
}
if (a == 2) {
return "one pair";
}
return "null";
}
public static void main(String[] args) {
while (read()) {
System.out.println(solve());
}
}
}
|
/**
*
* No.0038 Poker Hand
*
*
* @author yuichirw <y.iky917@gmail.com>
* @see
* http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0038&lang=jp
*/
import static java.lang.Math.*;
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static int[] cards;
static boolean read() {
if (!sc.hasNext())
return false;
String[] parsed = sc.next().split(",");
cards = new int[5];
for (int i = 0; i < 5; i++) {
cards[i] = Integer.parseInt(parsed[i]);
}
return true;
}
static String solve() {
char[] histgram = new char[14];
for (int i = 0; i < 5; i++) {
histgram[cards[i]]++;
}
Arrays.sort(histgram);
int a, b;
a = histgram[histgram.length - 1];
b = histgram[histgram.length - 2];
if (a == 4) {
return "four card";
}
Arrays.sort(cards);
boolean straight = false;
int cnt = 0, c = 0, d = 0;
for (int i = 0; i < 5; i++) {
cnt = 0;
for (int j = 0; j < 4; j++) {
c = cards[(i + j) % 5];
d = cards[(i + j + 1) % 5];
if (abs(c - d) != 1 && abs(c - d) != 12)
break;
cnt++;
if (abs(c - d) == 12 && cnt <= 4)
break;
}
if (cnt == 4) {
straight = true;
break;
}
}
if (a == 3 && b == 2) {
return "full house";
}
if (straight) {
return "straight";
}
if (a == 3) {
return "three card";
}
if (a == 2 && b == 2) {
return "two pair";
}
if (a == 2) {
return "one pair";
}
return "null";
}
public static void main(String[] args) {
while (read()) {
System.out.println(solve());
}
}
}
|
[["-", 0, 57, 64, 196, 0, 37, 0, 5, 0, 491], ["+", 0, 57, 64, 196, 0, 37, 0, 5, 0, 491]]
| 3
| 462
| 2
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main {
static BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws Exception {
String row;
while ((row = reader.readLine()) != null) {
String[] temps = row.split(",");
int[] cards = new int[5];
for (int i = 0; i < temps.length; i++)
cards[i] = Integer.parseInt(temps[i]);
HashMap<Integer, Integer> dist = new HashMap<Integer, Integer>();
for (int i = 0; i < 5; i++) {
if (dist.containsKey(cards[i])) {
dist.put(cards[i], dist.get(cards[i]) + 1);
} else {
dist.put(cards[i], 1);
}
}
int max_dist = 0;
Set<Integer> keys = dist.keySet();
for (int key : keys) {
if (max_dist < dist.get(key)) {
max_dist = dist.get(key);
}
}
Integer[] a = keys.toArray(new Integer[0]);
Integer[] p = new Integer[a.length];
for (int i = 0; i < a.length; i++)
p[i] = dist.get(a[i]);
Arrays.sort(p);
if (keys.size() == 3 && max_dist < 3 && p[1] == 2 && p[2] == 2) {
max_dist = -3;
}
if (keys.size() == 2 && max_dist < 4) {
if (p[0] == 2 && p[1] == 3) {
max_dist = -1;
}
}
if (keys.size() == 5 && max_dist < 4) {
boolean flag = true;
for (int i = 1; i < 5; i++) {
if (a[i] - a[i - 1] != 1) {
flag = false;
}
}
if (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
flag = true;
}
if (flag) {
max_dist = -2;
}
}
String msg = "";
switch (max_dist) {
case 2:
msg = "one pair";
break;
case -3:
msg = "tow pair";
break;
case 3:
msg = "three card";
break;
case -2:
msg = "straight";
break;
case 4:
msg = "four card";
break;
case -1:
msg = "full house";
break;
default:
msg = "null";
break;
}
System.out.println(msg);
}
}
}
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main {
static BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws Exception {
String row;
while ((row = reader.readLine()) != null) {
String[] temps = row.split(",");
int[] cards = new int[5];
for (int i = 0; i < temps.length; i++)
cards[i] = Integer.parseInt(temps[i]);
HashMap<Integer, Integer> dist = new HashMap<Integer, Integer>();
for (int i = 0; i < 5; i++) {
if (dist.containsKey(cards[i])) {
dist.put(cards[i], dist.get(cards[i]) + 1);
} else {
dist.put(cards[i], 1);
}
}
int max_dist = 0;
Set<Integer> keys = dist.keySet();
for (int key : keys) {
if (max_dist < dist.get(key)) {
max_dist = dist.get(key);
}
}
Integer[] a = keys.toArray(new Integer[0]);
Integer[] p = new Integer[a.length];
for (int i = 0; i < a.length; i++)
p[i] = dist.get(a[i]);
Arrays.sort(p);
if (keys.size() == 3 && max_dist < 3 && p[1] == 2 && p[2] == 2) {
max_dist = -3;
}
if (keys.size() == 2 && max_dist < 4) {
if (p[0] == 2 && p[1] == 3) {
max_dist = -1;
}
}
if (keys.size() == 5 && max_dist < 4) {
boolean flag = true;
for (int i = 1; i < 5; i++) {
if (a[i] - a[i - 1] != 1) {
flag = false;
}
}
if (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
flag = true;
}
if (flag) {
max_dist = -2;
}
}
String msg = "";
switch (max_dist) {
case 2:
msg = "one pair";
break;
case -3:
msg = "two pair";
break;
case 3:
msg = "three card";
break;
case -2:
msg = "straight";
break;
case 4:
msg = "four card";
break;
case -1:
msg = "full house";
break;
default:
msg = "null";
break;
}
System.out.println(msg);
}
}
}
|
[["-", 0, 520, 0, 1, 0, 11, 12, 5, 0, 491], ["+", 0, 520, 0, 1, 0, 11, 12, 5, 0, 491]]
| 3
| 617
| 2
|
#include <stdio.h>
int main() {
int c[5], i;
while (scanf("%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4]) != EOF) {
int t[14] = {0};
int max = 0, c2 = 0;
for (i = 0; i < 5; i++) {
t[c[i]]++;
if (t[c[i]] > max) {
max = t[c[i]];
}
}
for (i = 0; i < 13; i++) {
if (t[i] == 2) {
c2++;
}
}
if (max == 4)
printf("four card\n");
else if (max == 3) {
if (c2 == 1)
printf("full house\n");
else
printf("three card\n");
} else if (max == 2) {
if (c2 == 2)
printf("two pair\n");
else
printf("one pair\n");
} else if (max == 1) {
for (i = 0; t[i] == 0; i++)
;
if (t[i + 1] == 1 && t[i + 2] == 1 && t[i + 3] == 1 && t[i + 4] == 1)
printf("straight\n");
else if (t[1] == 1 && t[10] == 1 && t[11] == 1 && t[12] == 1 &&
t[13] == 1)
printf("straight\n");
else
printf("null\n");
}
}
return 0;
}
|
#include <stdio.h>
int main() {
int c[5], i;
while (scanf("%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4]) != EOF) {
int t[14] = {0};
int max = 0, c2 = 0;
for (i = 0; i < 5; i++) {
t[c[i]]++;
if (t[c[i]] > max) {
max = t[c[i]];
}
}
for (i = 0; i < 14; i++) {
if (t[i] == 2) {
c2++;
}
}
if (max == 4)
printf("four card\n");
else if (max == 3) {
if (c2 == 1)
printf("full house\n");
else
printf("three card\n");
} else if (max == 2) {
if (c2 == 2)
printf("two pair\n");
else
printf("one pair\n");
} else if (max == 1) {
for (i = 0; t[i] == 0; i++)
;
if (t[i + 1] == 1 && t[i + 2] == 1 && t[i + 3] == 1 && t[i + 4] == 1)
printf("straight\n");
else if (t[1] == 1 && t[10] == 1 && t[11] == 1 && t[12] == 1 &&
t[13] == 1)
printf("straight\n");
else
printf("null\n");
}
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
| 0
| 363
| 2
|
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
int main() {
int num[5], i, j, k, l, m, key, flag = 0, count = 0;
while (scanf("%d,%d,%d,%d,%d", &num[0], &num[1], &num[2], &num[3], &num[4]) !=
EOF) {
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++)
if (num[i] == num[j] && i != j) {
flag = 1;
count++;
}
}
if (count == 2)
flag = 2;
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (num[i] == num[j] && i != j) {
for (k = 0; k < 5; k++)
if (i != k && j != k && num[i] == num[k] && num[j] == num[k])
flag = 3;
}
}
}
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (num[i] > num[j]) {
key = num[i];
num[i] = num[j];
num[j] = key;
}
}
}
if (num[0] == num[1] - 1 && num[1] == num[2] - 1 && num[2] == num[3] - 1 &&
num[3] == num[4] - 1 ||
num[0] == 1 && num[1] == 10 && num[2] == 11 && num[3] == 12 &&
num[4] == 13)
flag = 4;
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (num[i] == num[j] && i != j) {
for (k = 0; k < 5; k++) {
if (i != k && j != k && num[i] == num[k] && num[j] == num[k]) {
for (l = 0; l < 5; l++) {
for (m = l; m < 5; m++)
if (num[l] == num[l + m] && l != i && l != j && l != k &&
l != m)
flag = 5;
}
}
}
}
}
}
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (num[i] == num[j] && i != j) {
for (k = 0; k < 5; k++) {
if (i != k && j != k && num[i] == num[k] && num[j] == num[k]) {
for (l = 0; l < 5; l++)
if (i != l && j != l && k != l && num[i] == num[l] &&
num[j] == num[l] && num[k] == num[l])
flag = 6;
}
}
}
}
}
switch (flag) {
case 0:
printf("null\n");
break;
case 1:
printf("one pair\n");
break;
case 2:
printf("two pair\n");
break;
case 3:
printf("three card\n");
break;
case 4:
printf("straight\n");
break;
case 5:
printf("full house\n");
break;
case 6:
printf("four card\n");
break;
}
flag = 0;
count = 0;
}
return 0;
}
|
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
int main() {
int num[5], i, j, k, l, m, key, flag = 0, count = 0;
while (scanf("%d,%d,%d,%d,%d", &num[0], &num[1], &num[2], &num[3], &num[4]) !=
EOF) {
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++)
if (num[i] == num[j] && i != j) {
flag = 1;
count++;
}
}
if (count == 2)
flag = 2;
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (num[i] == num[j] && i != j) {
for (k = 0; k < 5; k++)
if (i != k && j != k && num[i] == num[k] && num[j] == num[k])
flag = 3;
}
}
}
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (num[i] > num[j]) {
key = num[i];
num[i] = num[j];
num[j] = key;
}
}
}
if (num[0] == num[1] - 1 && num[1] == num[2] - 1 && num[2] == num[3] - 1 &&
num[3] == num[4] - 1 ||
num[0] == 1 && num[1] == 10 && num[2] == 11 && num[3] == 12 &&
num[4] == 13)
flag = 4;
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (num[i] == num[j] && i != j) {
for (k = 0; k < 5; k++) {
if (i != k && j != k && num[i] == num[k] && num[j] == num[k]) {
for (l = 0; l < 5; l++) {
for (m = 0; m < 5; m++)
if (num[l] == num[m] && l != i && l != j && l != k && l != m)
flag = 5;
}
}
}
}
}
}
for (i = 0; i < 5; i++) {
for (j = i; j < 5; j++) {
if (num[i] == num[j] && i != j) {
for (k = 0; k < 5; k++) {
if (i != k && j != k && num[i] == num[k] && num[j] == num[k]) {
for (l = 0; l < 5; l++)
if (i != l && j != l && k != l && num[i] == num[l] &&
num[j] == num[l] && num[k] == num[l])
flag = 6;
}
}
}
}
}
switch (flag) {
case 0:
printf("null\n");
break;
case 1:
printf("one pair\n");
break;
case 2:
printf("two pair\n");
break;
case 3:
printf("three card\n");
break;
case 4:
printf("straight\n");
break;
case 5:
printf("full house\n");
break;
case 6:
printf("four card\n");
break;
}
flag = 0;
count = 0;
}
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 7, 10, 11, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 31, 16, 31, 16, 12, 69, 71, 16, 31, 22], ["-", 31, 16, 31, 16, 12, 69, 71, 16, 17, 72]]
| 0
| 819
| 4
|
#include <stdio.h>
int main() {
int a[5], b[13];
int i, j;
while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF) {
for (i = 0; i < 13; i++) {
b[i] = 0;
}
for (i = 0; i < 5; i++) {
b[a[i] - 1]++;
}
for (i = 0; i < 13; i++) {
if (b[i] == 4) {
printf("four card\n");
goto exit;
}
}
for (i = 0; i < 13; i++) {
for (j = 0; j < 13; j++) {
if (b[i] == 2 && b[j] == 3) {
printf("full house\n");
goto exit;
} else if (b[i] == 2 && b[j] == 2) {
printf("two pair\n");
goto exit;
}
}
}
for (i = 0; i < 13; i++) {
if (b[i] == 3) {
printf("three card\n");
goto exit;
} else if (b[i] == 2) {
printf("two pair\n");
goto exit;
}
}
for (i = 0; i < 9; i++) {
if (b[i] == 1 && b[i + 1] == 1 && b[i + 2] == 1 && b[i + 3] == 1 &&
b[i + 4] == 1) {
printf("straight\n");
goto exit;
}
}
if (b[0] == 1 && b[9] == 1 && b[10] == 1 && b[11] == 1 & b[12] == 1) {
printf("straight\n");
goto exit;
}
printf("null\n");
exit:;
}
return 0;
}
|
#include <stdio.h>
int main() {
int a[5], b[13];
int i, j;
while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF) {
for (i = 0; i < 13; i++) {
b[i] = 0;
}
for (i = 0; i < 5; i++) {
b[a[i] - 1]++;
}
for (i = 0; i < 13; i++) {
if (b[i] == 4) {
printf("four card\n");
goto exit;
}
}
for (i = 0; i < 13; i++) {
for (j = 0; j < 13; j++) {
if (b[i] == 2 && b[j] == 3) {
printf("full house\n");
goto exit;
} else if (b[i] == 2 && b[j] == 2 && i != j) {
printf("two pair\n");
goto exit;
}
}
}
for (i = 0; i < 13; i++) {
if (b[i] == 3) {
printf("three card\n");
goto exit;
} else if (b[i] == 2) {
printf("one pair\n");
goto exit;
}
}
for (i = 0; i < 9; i++) {
if (b[i] == 1 && b[i + 1] == 1 && b[i + 2] == 1 && b[i + 3] == 1 &&
b[i + 4] == 1) {
printf("straight\n");
goto exit;
}
}
if (b[0] == 1 && b[9] == 1 && b[10] == 1 && b[11] == 1 & b[12] == 1) {
printf("straight\n");
goto exit;
}
printf("null\n");
exit:;
}
return 0;
}
|
[["+", 75, 76, 0, 57, 15, 23, 0, 16, 17, 98], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 438
| 6
|
#include <stdio.h>
char judge(int hand[5]);
void sort(int *hand);
int main(void) {
int hand[5];
char rank;
char OF;
while (scanf(" %c,", &OF) != EOF) {
hand[0] = OF - '0';
scanf("%d,%d,%d,%d", &hand[1], &hand[2], &hand[3], &hand[4]);
sort(hand);
rank = judge(hand);
switch (rank) {
case ('S'):
printf("four card\n");
break;
case ('A'):
printf("full house\n");
break;
case ('B'):
printf("straight\n");
break;
case ('C'):
printf("three card\n");
break;
case ('D'):
printf("two pair\n");
break;
case ('E'):
printf("one pair\n");
break;
case ('F'):
printf("null\n");
break;
}
}
return (0);
}
void sort(int *hand) {
int i, j;
int tmp;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
if (hand[i] < hand[j]) {
tmp = hand[i];
hand[i] = hand[j];
hand[j] = tmp;
}
}
}
}
char judge(int hand[5]) {
int pair = 0;
int card_3 = 0, card_4 = 0;
char rank;
int straight = 0;
int i;
int sum = 0;
for (i = 0; i < 5; i++) {
sum += hand[i];
if (hand[i] == hand[i + 1]) {
pair++;
if (hand[i] == hand[i + 2]) {
pair--;
card_3++;
if (hand[i] == hand[i + 3]) {
card_3--;
card_4++;
i++;
i++;
} else {
i++;
}
}
}
if (hand[i] + 1 == hand[i + 1]) {
straight++;
}
}
if (card_4 == 1) {
rank = 'S';
} else if (card_3 == 1 && pair == 1) {
rank = 'A';
} else if (straight == 4) {
rank = 'B';
} else if (straight == 3 && sum == 47) {
rank = 'B';
}
else if (card_3 == 1) {
rank = 'C';
} else if (pair == 2) {
rank = 'D';
} else if (pair == 1) {
rank = 'E';
} else {
rank = 'F';
}
return (rank);
}
|
#include <stdio.h>
char judge(int hand[5]);
void sort(int *hand);
int main(void) {
int hand[5];
char rank;
int OF;
while (scanf(" %d,", &OF) != EOF) {
hand[0] = OF;
scanf("%d,%d,%d,%d", &hand[1], &hand[2], &hand[3], &hand[4]);
sort(hand);
rank = judge(hand);
switch (rank) {
case ('S'):
printf("four card\n");
break;
case ('A'):
printf("full house\n");
break;
case ('B'):
printf("straight\n");
break;
case ('C'):
printf("three card\n");
break;
case ('D'):
printf("two pair\n");
break;
case ('E'):
printf("one pair\n");
break;
case ('F'):
printf("null\n");
break;
}
}
return (0);
}
void sort(int *hand) {
int i, j;
int tmp;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
if (hand[i] < hand[j]) {
tmp = hand[i];
hand[i] = hand[j];
hand[j] = tmp;
}
}
}
}
char judge(int hand[5]) {
int pair = 0;
int card_3 = 0, card_4 = 0;
char rank;
int straight = 0;
int i;
int sum = 0;
for (i = 0; i < 5; i++) {
sum += hand[i];
if (hand[i] == hand[i + 1]) {
pair++;
if (hand[i] == hand[i + 2]) {
pair--;
card_3++;
if (hand[i] == hand[i + 3]) {
card_3--;
card_4++;
i++;
i++;
} else {
i++;
}
}
}
if (hand[i] + 1 == hand[i + 1]) {
straight++;
}
}
if (card_4 == 1) {
rank = 'S';
} else if (card_3 == 1 && pair == 1) {
rank = 'A';
} else if (straight == 4) {
rank = 'B';
} else if (straight == 3 && sum == 47) {
rank = 'B';
}
else if (card_3 == 1) {
rank = 'C';
} else if (pair == 2) {
rank = 'D';
} else if (pair == 1) {
rank = 'E';
} else {
rank = 'F';
}
return (rank);
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 103, 0, 104], ["-", 0, 1, 0, 11, 12, 16, 12, 103, 0, 125]]
| 0
| 609
| 8
|
main() {
int a[6], i, j;
while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != -1) {
for (i = 0; i < 5 - 1; i++)
for (j = i + 1; j < 5; j++)
if (a[i] > a[j]) {
a[5] = a[i];
a[i] = a[j];
a[j] = a[5];
}
if ((a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) ||
(a[1] == a[2] && a[2] == a[3] && a[3] == a[4]))
puts("four cards");
else if ((a[0] == a[1] && a[1] == a[2] && a[3] == a[4]) ||
(a[0] == a[1] && a[2] == a[3] && a[3] == a[4]))
puts("full house");
else if ((a[1] == a[0] + 1 && a[2] == a[1] + 1 && a[3] == a[2] + 1 &&
a[4] == a[3] + 1) ||
(a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 &&
a[4] == 13))
puts("straight");
else if ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]) ||
(a[2] == a[3] && a[3] == a[4]))
puts("three card");
else if ((a[0] == a[1] && a[2] == a[3]) || (a[0] == a[1] && a[3] == a[4]) ||
(a[1] == a[2] && a[3] == a[4]))
puts("two pair");
else if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3] || a[3] == a[4])
puts("one pair");
else
puts("null");
}
return 0;
}
|
main() {
int a[6], i, j;
while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != -1) {
for (i = 0; i < 5 - 1; i++)
for (j = i + 1; j < 5; j++)
if (a[i] > a[j]) {
a[5] = a[i];
a[i] = a[j];
a[j] = a[5];
}
if ((a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) ||
(a[1] == a[2] && a[2] == a[3] && a[3] == a[4]))
puts("four card");
else if ((a[0] == a[1] && a[1] == a[2] && a[3] == a[4]) ||
(a[0] == a[1] && a[2] == a[3] && a[3] == a[4]))
puts("full house");
else if ((a[1] == a[0] + 1 && a[2] == a[1] + 1 && a[3] == a[2] + 1 &&
a[4] == a[3] + 1) ||
(a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 &&
a[4] == 13))
puts("straight");
else if ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]) ||
(a[2] == a[3] && a[3] == a[4]))
puts("three card");
else if ((a[0] == a[1] && a[2] == a[3]) || (a[0] == a[1] && a[3] == a[4]) ||
(a[1] == a[2] && a[3] == a[4]))
puts("two pair");
else if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3] || a[3] == a[4])
puts("one pair");
else
puts("null");
}
return 0;
}
|
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 589
| 2
|
#include <stdio.h>
int main() {
int card[14];
int c[5];
int i, j, t;
int pair, tri, fo, st;
int flag = 0;
while (scanf("%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4]) != EOF) {
flag = pair = tri = fo = st = 0;
for (i = 1; i < 14; i++)
card[i] = 0;
for (i = 0; i < 5; i++) {
card[c[i]]++;
if (card[c[i]] == 4) {
printf("four card\n");
flag = 1;
break;
} else if (card[c[i]] == 3)
tri = 1;
}
if (flag)
continue;
if (tri) {
for (i = 1; i < 14; i++) {
if (card[i] == 2)
break;
}
if (card[i] == 2)
printf("full house\n");
else
printf("tree card\n");
continue;
}
for (i = 1; i < 14; i++) {
if (card[i] == 2)
pair++;
}
if (pair == 2) {
printf("two pair\n");
continue;
} else if (pair == 1) {
printf("one pair\n");
continue;
}
for (i = 1; i < 10; i++) {
if (card[i] == 1 && card[i + 1] == 1 && card[i + 2] == 1 &&
card[i + 3] == 1 && card[i + 4] == 1) {
printf("straight\n");
st = 1;
break;
}
}
if (st)
continue;
if (card[1] == 1 && card[10] == 1 && card[11] == 1 && card[12] == 1 &&
card[13] == 1) {
printf("straight\n");
st = 1;
}
else
printf("null\n");
}
return 0;
}
|
#include <stdio.h>
int main() {
int card[14];
int c[5];
int i, j, t;
int pair, tri, fo, st;
int flag = 0;
while (scanf("%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4]) != EOF) {
flag = pair = tri = fo = st = 0;
for (i = 1; i < 14; i++)
card[i] = 0;
for (i = 0; i < 5; i++) {
card[c[i]]++;
if (card[c[i]] == 4) {
printf("four card\n");
flag = 1;
break;
} else if (card[c[i]] == 3)
tri = 1;
}
if (flag)
continue;
if (tri) {
for (i = 1; i < 14; i++) {
if (card[i] == 2)
break;
}
if (card[i] == 2)
printf("full house\n");
else
printf("three card\n");
continue;
}
for (i = 1; i < 14; i++) {
if (card[i] == 2)
pair++;
}
if (pair == 2) {
printf("two pair\n");
continue;
} else if (pair == 1) {
printf("one pair\n");
continue;
}
for (i = 1; i < 10; i++) {
if (card[i] == 1 && card[i + 1] == 1 && card[i + 2] == 1 &&
card[i + 3] == 1 && card[i + 4] == 1) {
printf("straight\n");
st = 1;
break;
}
}
if (st)
continue;
if (card[1] == 1 && card[10] == 1 && card[11] == 1 && card[12] == 1 &&
card[13] == 1) {
printf("straight\n");
st = 1;
}
else
printf("null\n");
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 460
| 2
|
#include <math.h>
#include <stdio.h>
main() {
int data[10000], p, i, j, k, n;
data[0] = 2;
data[1] = 3;
k = 2;
for (i = 5; i < 100000; i += 2) {
p = 0;
for (j = 0;; j++) {
if ((double)data[j] > sqrt((double)i))
break;
if (i % data[j] == 0) {
p = 1;
break;
}
}
if (p == 0) {
data[k] = i;
k++;
}
if (k >= 6000)
break;
}
while (1) {
if (scanf("%d", &n) == EOF)
break;
for (i = 0; i < 1000; i++) {
if (data[i] == n) {
printf("%d %d\n", data[i - 1], data[i + 1]);
break;
} else if (data[i] > n) {
printf("%d %d\n", data[i - 1], data[i]);
break;
}
}
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
main() {
int data[10000], p, i, j, k, n;
data[0] = 2;
data[1] = 3;
k = 2;
for (i = 5; i < 100000; i += 2) {
p = 0;
for (j = 0;; j++) {
if ((double)data[j] > sqrt((double)i))
break;
if (i % data[j] == 0) {
p = 1;
break;
}
}
if (p == 0) {
data[k] = i;
k++;
}
if (k >= 6000)
break;
}
while (1) {
if (scanf("%d", &n) == EOF)
break;
for (i = 0; i < 6000; i++) {
if (data[i] == n) {
printf("%d %d\n", data[i - 1], data[i + 1]);
break;
} else if (data[i] > n) {
printf("%d %d\n", data[i - 1], data[i]);
break;
}
}
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
| 0
| 250
| 2
|
#include <stdio.h>
int isprime(int n) {
int i;
for (i = 2; i * i < n; i++) {
if (n % i == 0) {
return (0);
}
}
return (1);
}
int main(void) {
int n;
int i;
while (scanf("%d", &n) != EOF) {
i = n;
while (isprime(--i) == 0)
;
printf("%d ", i);
i = n;
while (isprime(++i) == 0)
;
printf("%d\n", i);
}
return (0);
}
|
#include <stdio.h>
int isprime(int n) {
int i;
for (i = 2; i * i <= n; i++) {
if (n % i == 0) {
return (0);
}
}
return (1);
}
int main(void) {
int n;
int i;
while (scanf("%d", &n) != EOF) {
i = n;
while (isprime(--i) == 0)
;
printf("%d ", i);
i = n;
while (isprime(++i) == 0)
;
printf("%d\n", i);
}
return (0);
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
| 0
| 133
| 2
|
#include <math.h>
#include <stdio.h>
int sosuu(int n);
int b(int n);
int s(int n);
int main() {
int n, big, small;
while (scanf("%d", &n) != EOF) {
big = b(n);
small = s(n);
printf("%d %d\n", small, big);
}
return 0;
}
int s(int n) {
int i, result;
for (i = 0; i < n; i++) {
if (sosuu(i) != 0) {
result = sosuu(i);
}
}
return result;
}
int b(int n) {
int i;
for (i = n + 1;; i++) {
if (sosuu(i) != 0)
break;
}
return i;
}
int sosuu(int n) {
if (n <= 1)
return 0;
int i;
for (i = 2; i * i < n; i++) {
if (n % i == 0) {
return 0;
}
}
return n;
}
|
#include <math.h>
#include <stdio.h>
int sosuu(int n);
int b(int n);
int s(int n);
int main() {
int n, big, small;
while (scanf("%d", &n) != EOF) {
big = b(n);
small = s(n);
printf("%d %d\n", small, big);
}
return 0;
}
int s(int n) {
int i, result;
for (i = 0; i < n; i++) {
if (sosuu(i) != 0) {
result = sosuu(i);
}
}
return result;
}
int b(int n) {
int i;
for (i = n + 1;; i++) {
if (sosuu(i) != 0)
break;
}
return i;
}
int sosuu(int n) {
if (n <= 1)
return 0;
int i;
for (i = 2; i * i <= n; i++) {
if (n % i == 0) {
return 0;
}
}
return n;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
| 0
| 224
| 2
|
#include <stdio.h>
int prime[1000000] = {0};
int main() {
int i, j, k, flag;
while (scanf("%d", &i) != EOF) {
flag = 0;
for (j = 2; j <= i + 100; j++) {
for (k = 2; k * j <= i; k++) {
prime[j * k] = 1;
}
}
for (j = i * 2; j > 1; j--) {
if (j < i && prime[j] == 0) {
printf("%d ", j);
break;
}
}
for (j = 2; j < i * 2; j++) {
if (j > i && prime[j] == 0) {
printf("%d\n", j);
break;
}
}
}
return (0);
}
|
#include <stdio.h>
int prime[1000000] = {0};
int main() {
int i, j, k, flag;
while (scanf("%d", &i) != EOF) {
flag = 0;
for (j = 2; j <= i; j++) {
for (k = 2; k * j < 55000; k++) {
prime[j * k] = 1;
}
}
for (j = i * 2; j > 1; j--) {
if (j < i && prime[j] == 0) {
printf("%d ", j);
break;
}
}
for (j = 2; j < i * 2; j++) {
if (j > i && prime[j] == 0) {
printf("%d\n", j);
break;
}
}
}
return (0);
}
|
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
| 0
| 182
| 6
|
#include <cmath>
#include <iostream>
using namespace std;
bool Judge_Prime_Number(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x % i == 0)
return false;
}
return true;
}
int main() {
int a;
cin >> a;
int min = a - 1, max = a + 1;
while (Judge_Prime_Number(min) == false)
min--;
while (Judge_Prime_Number(max) == false)
max++;
cout << min << " " << max << endl;
return 0;
}
|
#include <cmath>
#include <iostream>
using namespace std;
bool Judge_Prime_Number(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x % i == 0)
return false;
}
return true;
}
int main() {
int a;
while (cin >> a) {
int min = a - 1, max = a + 1;
while (Judge_Prime_Number(min) == false)
min--;
while (Judge_Prime_Number(max) == false)
max++;
cout << min << " " << max << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 114
| 6
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
int i, no, input;
int prime[500];
int ptr = 0, c = 0;
int flag = 0;
int last;
while (cin >> input) {
flag = ptr = c = 0;
prime[ptr++] = 2;
prime[ptr++] = 3;
for (no = 5;; no += 2) {
if (flag == 2) {
break;
}
if (input + 1 <= no) {
flag = 1;
c++;
}
if (c == 1) {
if (input == prime[ptr - 1])
last = ptr - 2;
else
last = ptr - 1;
}
for (i = 1; i < ptr; i++) {
if (no % prime[i] == 0)
break;
}
if (ptr == i) {
prime[ptr++] = no;
if (flag == 1) {
flag = 2;
}
}
}
printf("%d %d\n", prime[last], prime[ptr - 1]);
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
int i, no, input;
int prime[10000];
int ptr = 0, c = 0;
int flag = 0;
int last;
while (cin >> input) {
flag = ptr = c = 0;
prime[ptr++] = 2;
prime[ptr++] = 3;
for (no = 5;; no += 2) {
if (flag == 2) {
break;
}
if (input + 1 <= no) {
flag = 1;
c++;
}
if (c == 1) {
if (input == prime[ptr - 1])
last = ptr - 2;
else
last = ptr - 1;
}
for (i = 1; i < ptr; i++) {
if (no % prime[i] == 0)
break;
}
if (ptr == i) {
prime[ptr++] = no;
if (flag == 1) {
flag = 2;
}
}
}
printf("%d %d\n", prime[last], prime[ptr - 1]);
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
| 1
| 228
| 2
|
#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int na, nb;
bool flag = true;
for (int i = n - 1;; i--) {
for (int j = 2; j * j < i; j++) {
if (i % j == 0) {
flag = false;
break;
}
}
if (flag) {
na = i;
break;
}
flag = true;
}
flag = true;
for (int i = n + 1;; i++) {
for (int j = 2; j * j < i; j++) {
if (i % j == 0) {
flag = false;
break;
}
}
if (flag) {
nb = i;
break;
}
flag = true;
}
cout << na << ' ' << nb << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int na, nb;
bool flag = true;
for (int i = n - 1;; i--) {
for (int j = 2; j * j <= i; j++) {
if (i % j == 0) {
flag = false;
break;
}
}
if (flag) {
na = i;
break;
}
flag = true;
}
flag = true;
for (int i = n + 1;; i++) {
for (int j = 2; j * j <= i; j++) {
if (i % j == 0) {
flag = false;
break;
}
}
if (flag) {
nb = i;
break;
}
flag = true;
}
cout << na << ' ' << nb << endl;
}
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 182
| 4
|
#include <iostream>
using namespace std;
int main() {
bool prime[100000];
for (int i = 0; i < 100000; i++) {
prime[i] = true;
}
prime[0] = prime[1] = false;
for (int i = 2; i < 1000; i++) {
for (int j = i * 2; j * i < 60000; j += i) {
prime[j] = false;
}
}
int n;
int cnt1, cnt2;
while (cin >> n) {
for (int i = 0; i < n; i++) {
if (prime[i])
cnt1 = i;
}
for (int i = n + 1;; i++) {
if (prime[i]) {
cnt2 = i;
break;
}
}
cout << cnt1 << " " << cnt2 << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
bool prime[100000];
for (int i = 0; i < 100000; i++) {
prime[i] = true;
}
prime[0] = prime[1] = false;
for (int i = 2; i <= 1000; i++) {
for (int j = i * 2; j < 100000; j += i) {
prime[j] = false;
}
}
int n;
int cnt1, cnt2;
while (cin >> n) {
for (int i = 0; i < n; i++) {
if (prime[i])
cnt1 = i;
}
for (int i = n + 1;; i++) {
if (prime[i]) {
cnt2 = i;
break;
}
}
cout << cnt1 << " " << cnt2 << endl;
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 185
| 6
|
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define PI 3.14159265359
#define INF 1000000;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
typedef long long ll;
using namespace std;
/*
class ElectronicPetEasy
{
public:
string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
{
}
};
*/
int prime[50000];
bool is_prime[50001];
void sieve(void) {
int p = 0;
REP(50001) is_prime[i] = true;
is_prime[0] = is_prime[1] = false;
for (int i = 2; i <= 60000; i++) {
if (is_prime[i]) {
prime[p++] = i;
for (int j = 2 * i; j <= 50000; j += i)
is_prime[j] = false;
}
}
}
int main() {
int n, less, more;
sieve();
while (cin >> n) {
for (int i = 0; i < 50000; i++) {
if (prime[i] > n) {
more = prime[i];
break;
}
}
for (int i = 0; i < 50000; i++) {
if (prime[i] >= n) {
less = prime[i - 1];
break;
}
}
cout << less << " " << more << endl;
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define PI 3.14159265359
#define INF 1000000;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
typedef long long ll;
using namespace std;
/*
class ElectronicPetEasy
{
public:
string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
{
}
};
*/
int prime[50000];
bool is_prime[60000];
void sieve(void) {
int p = 0;
REP(60000) is_prime[i] = true;
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 60000; i++) {
if (is_prime[i]) {
prime[p++] = i;
for (int j = 2 * i; j < 60000; j += i)
is_prime[j] = false;
}
}
}
int main() {
int n, less, more;
sieve();
while (cin >> n) {
for (int i = 0; i < 50000; i++) {
if (prime[i] > n) {
more = prime[i];
break;
}
}
for (int i = 0; i < 50000; i++) {
if (prime[i] >= n) {
less = prime[i - 1];
break;
}
}
cout << less << " " << more << endl;
}
return 0;
}
|
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 11, 31, 69, 28, 2, 3, 4, 0, 13], ["+", 0, 11, 31, 69, 28, 2, 3, 4, 0, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 270
| 10
|
#include <bits/stdc++.h>
#define _ \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
set<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223, 227};
bool isPrime(int n) {
for (int p : primes) {
if (p * p > n)
return true;
if (n % p == 0)
return false;
}
return true;
}
int main() {
for (int i = 229; i < 50040; i += 2)
if (isPrime(i))
primes.insert(i);
int n;
while (cin >> n) {
auto r = primes.lower_bound(n);
auto l = r;
if (primes.count(n) == 1) {
r++;
l--;
} else {
l--;
l--;
}
cout << (*l) << " " << (*r) << endl;
}
}
|
#include <bits/stdc++.h>
#define _ \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
set<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223, 227};
bool isPrime(int n) {
for (int p : primes) {
if (p * p > n)
return true;
if (n % p == 0)
return false;
}
return true;
}
int main() {
for (int i = 229; i < 50040; i += 2)
if (isPrime(i))
primes.insert(i);
int n;
while (cin >> n) {
auto r = primes.lower_bound(n);
auto l = r;
if (primes.count(n) == 1) {
r++;
l--;
} else {
l--;
}
cout << (*l) << " " << (*r) << endl;
}
}
|
[["-", 75, 76, 0, 9, 0, 1, 0, 27, 28, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 27, 17, 68], ["-", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
| 1
| 273
| 3
|
#include <cmath>
#include <iostream>
using namespace std;
int x[1000000];
int main() {
for (int i = 2; i < 1000000; i++) {
for (int j = 2; j <= sqrt(i); j++) {
if (i % j == 0) {
goto E;
}
}
x[i] = 1;
E:;
}
int a, b;
while (cin >> a >> b) {
for (int i = a - 1; i >= 0; i--) {
if (x[i] == 1) {
cout << i << ' ';
break;
}
}
for (int i = a + 1; i < 1000000; i++) {
if (x[i] == 1) {
cout << i << endl;
break;
}
}
}
}
|
#include <cmath>
#include <iostream>
using namespace std;
int x[1000000];
int main() {
for (int i = 2; i < 1000000; i++) {
for (int j = 2; j <= sqrt(i); j++) {
if (i % j == 0) {
goto E;
}
}
x[i] = 1;
E:;
}
int a, b;
while (cin >> a) {
for (int i = a - 1; i >= 0; i--) {
if (x[i] == 1) {
cout << i << ' ';
break;
}
}
for (int i = a + 1; i < 1000000; i++) {
if (x[i] == 1) {
cout << i << endl;
break;
}
}
}
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
| 1
| 169
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.