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
import sys n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]] n2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]] n3 = n2 + [[a*2, b*2] for a, b in n1] mas = [[0]*10 for i in range(10)] for i in sys.stdin: try: x, y, a = list(map(int, i.split(","))) mas[y][x] += 1 for k,l in eval("n"+str(a)): try: if y+l>= 0 and x+k >= 0: mas[y+l][x+k] += 1 except IndexError: continue except ValueError: break print(mas) print(len([i for x in mas for i in x if not i])) print(max([max(v) for v in mas]))
import sys n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]] n2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]] n3 = n2 + [[a*2, b*2] for a, b in n1] mas = [[0]*10 for i in range(10)] for i in sys.stdin: try: x, y, a = list(map(int, i.split(","))) mas[y][x] += 1 for k,l in eval("n"+str(a)): try: if y+l >= 0 and x+k >= 0: mas[y+l][x+k] += 1 except IndexError: continue except ValueError: break print(len([i for x in mas for i in x if not i])) print(max([max(v) for v in mas]))
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
230
4
#sheet...紙全体、sheet[x][y]は(x, y)のインクの濃さ sheet = [[0 for _ in range(10)] for _ in range(10)] #小、中、大のインクの範囲 small_range = ((0, 0), (1, 0), (0, 1), (-1, 0), (0, 1)) middle_range = ((0, 0), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)) large_range = ((0, 0), (1, 0), (2, 0), (1, 1), (0, 1), (0, 2), (-1, 1), (-1, 0), (-2, 0), (-1, -1), (0, -1), (0, -2), (1, -1)) #範囲内か判定してインクを足す def drop(x, y, drop_range): for dx, dy in drop_range: newx, newy = x + dx, y + dy if 0 <= newx <= 9 and 0 <= newy <= 9: sheet[newx][newy] += 1 while True: try: x, y, s = map(int, input().split(",")) if s == 1: drop(x, y, small_range) elif s == 2: drop(x, y, middle_range) else: drop(x, y, large_range) except EOFError: break #0の個数 zero_cnt = 0 #インクの最大値 max_ink = 0 for x in range(10): for y in range(10): ink = sheet[x][y] if ink == 0: zero_cnt += 1 if max_ink < ink: max_ink = ink print(zero_cnt) print(max_ink)
#sheet...紙全体、sheet[x][y]は(x, y)のインクの濃さ sheet = [[0 for _ in range(10)] for _ in range(10)] #小、中、大のインクの範囲 small_range = ((0, 0), (1, 0), (0, 1), (-1, 0), (0, -1)) middle_range = ((0, 0), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)) large_range = ((0, 0), (1, 0), (2, 0), (1, 1), (0, 1), (0, 2), (-1, 1), (-1, 0), (-2, 0), (-1, -1), (0, -1), (0, -2), (1, -1)) #範囲内か判定してインクを足す def drop(x, y, drop_range): for dx, dy in drop_range: newx, newy = x + dx, y + dy if 0 <= newx <= 9 and 0 <= newy <= 9: sheet[newx][newy] += 1 while True: try: x, y, s = map(int, input().split(",")) if s == 1: drop(x, y, small_range) elif s == 2: drop(x, y, middle_range) else: drop(x, y, large_range) except EOFError: break #0の個数 zero_cnt = 0 #インクの最大値 max_ink = 0 for x in range(10): for y in range(10): ink = sheet[x][y] if ink == 0: zero_cnt += 1 if max_ink < ink: max_ink = ink print(zero_cnt) print(max_ink)
[["+", 0, 662, 12, 660, 0, 660, 0, 664, 17, 33]]
5
383
1
def drop(x,y): global paper if 0<=x<10 and 0<=y<10: paper[y][x]+=1 return def ink(x,y,size): drop(x-1,y) drop(x+1,y) drop(x,y-1) drop(x,y+1) if size==1: return drop(x-1,y-1) drop(x-1,y+1) drop(x+1,y-1) drop(x+1,y+1) if size==2: return drop(x-2,y) drop(x+2,y) drop(x,y-2) drop(x,y+2) return paper = [[0 for i in range(10)] for j in range(10)] while True: try: x,y,size = list(map(int, input().split(","))) ink(x,y,size) except: break print(sum([e.count(0) for e in paper])) print(max([max(e) for e in paper]))
def drop(x,y): global paper if 0<=x<10 and 0<=y<10: paper[y][x]+=1 return def ink(x,y,size): drop(x,y) drop(x-1,y) drop(x+1,y) drop(x,y-1) drop(x,y+1) if size==1: return drop(x-1,y-1) drop(x-1,y+1) drop(x+1,y-1) drop(x+1,y+1) if size==2: return drop(x-2,y) drop(x+2,y) drop(x,y-2) drop(x,y+2) return paper = [[0 for i in range(10)] for j in range(10)] while True: try: x,y,size = list(map(int, input().split(","))) ink(x,y,size) except: break print(sum([e.count(0) for e in paper])) print(max([max(e) for e in paper]))
[["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22]]
5
255
6
i = require("fs").readFileSync("/dev/stdin", "utf8").split(/\s/); for (a = 0; + i[a]; a += 2) console.log([ 'Sun', 'Mon', 'Tues', 'Wednes', 'Thurs', 'Fri', 'Satur' ][new Date(16, i[a] - 1, i[a + 1]).getDay()] + 'day')
i = require("fs").readFileSync("/dev/stdin", "utf8").split(/\s/); for (a = 0; + i[a]; a += 2) console.log([ 'Sun', 'Mon', 'Tues', 'Wednes', 'Thurs', 'Fri', 'Satur' ][new Date(804, i[a] - 1, i[a + 1]).getDay()] + 'day')
[["-", 71, 2, 63, 558, 500, 350, 3, 3, 0, 555], ["+", 71, 2, 63, 558, 500, 350, 3, 3, 0, 555]]
2
106
2
i = require("fs").readFileSync("/dev/stdin", "utf8").split(/\s/); for (a = 0; b = +i[a]; a += 2) console.log([ 'Sun', 'Mon', 'Tues', 'Wednes', 'Thurs', 'Fri', 'Satur' ][new Date(3, b - 1, i[a + 1]).getDay()] + 'day')
i = require("fs").readFileSync("/dev/stdin", "utf8").split(/\s/); for (a = 0; b = +i[a]; a += 2) console.log([ 'Sun', 'Mon', 'Tues', 'Wednes', 'Thurs', 'Fri', 'Satur' ][new Date(76, b - 1, i[a + 1]).getDay()] + 'day')
[["-", 71, 2, 63, 558, 500, 350, 3, 3, 0, 555], ["+", 71, 2, 63, 558, 500, 350, 3, 3, 0, 555]]
2
105
2
function Main(input) { var week = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; inputLine = input.split("\n"); for (var i = 0;; i++) { var dateObj = new Date(); dateObj.setFullYear(2004); var date = inputLine[i].split(" "); var month = Int(date[0]); var day = Int(date[1]); if (month === 0) break; dateObj.setMonth(month - 1); dateObj.setDate(day); output(week[dateObj.getDay()]); dateObj = null; } } //??°??????????????¢??°??¨(??????) function ascendingOrder(val1, val2) { return val1 - val2; } //??°??????????????¢??°??¨(??????) function descendingOrder(val1, val2) { return val2 - val1; } //??°?????? function int(str) { return parseInt(str, 10); } //???????????? function str(num) { return num.toString(10); } function output(str) { if (_Isdebug) { document.getElementById("Console").value += (str + "\n"); } console.log(str); } //???????????°??¨ var _Isdebug = false; function debug() { _Isdebug = true; var input = document.getElementById("Console").value; document.getElementById("Console").value += "\n"; Main(input); } //??\?????????????????? Main(require("fs").readFileSync("/dev/stdin", "utf8"));
function Main(input) { var week = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; inputLine = input.split("\n"); for (var i = 0;; i++) { var dateObj = new Date(); dateObj.setFullYear(2004); var date = inputLine[i].split(" "); var month = int(date[0]); var day = int(date[1]); if (month === 0) break; dateObj.setMonth(month - 1); dateObj.setDate(day); output(week[dateObj.getDay()]); dateObj = null; } } //??°??????????????¢??°??¨(??????) function ascendingOrder(val1, val2) { return val1 - val2; } //??°??????????????¢??°??¨(??????) function descendingOrder(val1, val2) { return val2 - val1; } //??°?????? function int(str) { return parseInt(str, 10); } //???????????? function str(num) { return num.toString(10); } function output(str) { if (_Isdebug) { document.getElementById("Console").value += (str + "\n"); } console.log(str); } //???????????°??¨ var _Isdebug = false; function debug() { _Isdebug = true; var input = document.getElementById("Console").value; document.getElementById("Console").value += "\n"; Main(input); } //??\?????????????????? Main(require("fs").readFileSync("/dev/stdin", "utf8"));
[["-", 8, 556, 0, 198, 0, 200, 51, 2, 63, 22], ["+", 8, 556, 0, 198, 0, 200, 51, 2, 63, 22]]
2
329
4
x = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(/\s/); yobi = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); for (i = 0; i < x.length - 1;) { if (x[i] === 0) break; console.log(yobi[new Date('2004/0' + x[i++] + '/0' + x[i++]).getDay()]); }
x = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(/\s/); yobi = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); for (i = 0; i < x.length - 1;) { if (x[i] == 0) break; console.log(yobi[new Date('2004/0' + x[i++] + '/0' + x[i++]).getDay()]); }
[["-", 8, 556, 0, 57, 15, 23, 0, 16, 17, 565], ["+", 8, 556, 0, 57, 15, 23, 0, 16, 17, 60]]
2
129
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] w = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int[] d = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int sum = 0; while (true) { int a = sc.nextInt(); int b = sc.nextInt(); if (a == 0 && b == 0) { break; } for (int i = 0; i < a - 1; i++) { sum += d[i]; } sum = sum + b; System.out.println(w[sum % 7]); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] w = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int[] d = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int sum = 0; while (true) { sum = 0; int a = sc.nextInt(); int b = sc.nextInt(); if (a == 0 && b == 0) { break; } for (int i = 0; i < a - 1; i++) { sum += d[i]; } sum = sum + b; System.out.println(w[sum % 7]); } } }
[["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 499], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
3
189
4
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { // BufferedReader reader=new BufferedReader(new // InputStreamReader(System.in)); Scanner reader = new Scanner(System.in); // int in=reader.nextInt(); int[] tmp = {31, 29, 31, 30, 31, 30, 31, 31, 30, 30, 30, 31}; String[] ans = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int a, b; while (true) { a = reader.nextInt(); b = reader.nextInt(); if (a == 0 && b == 0) break; int h = 1; int co = 0; while (h != a) { co += tmp[h - 1]; h++; } co += b; System.out.println(ans[co % 7]); } } }
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { // BufferedReader reader=new BufferedReader(new // InputStreamReader(System.in)); Scanner reader = new Scanner(System.in); // int in=reader.nextInt(); int[] tmp = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] ans = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int a, b; while (true) { a = reader.nextInt(); b = reader.nextInt(); if (a == 0 && b == 0) break; int h = 1; int co = 0; while (h != a) { co += tmp[h - 1]; h++; } co += b; System.out.println(ans[co % 7]); } } }
[["-", 8, 196, 0, 503, 49, 200, 51, 518, 0, 499], ["+", 8, 196, 0, 503, 49, 200, 51, 518, 0, 499]]
3
200
2
import java.util.Scanner; class Main { static final int[] monthDay = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; static final String[] dayOfTheWeek = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; public static void main(String[] args) { Scanner sc = null; try { sc = new Scanner(System.in); while (sc.hasNextInt()) { int month = sc.nextInt(); int day = sc.nextInt(); if (month == 0 || day == 0) { break; } System.out.println(getDayOfTheWeek(month, day)); } } finally { sc.close(); } } public static String getDayOfTheWeek(int m, int d) { int sum = 0; for (int i = 0; i < m; i++) { sum += monthDay[i]; } sum += d; return dayOfTheWeek[sum % 7]; } }
import java.util.Scanner; class Main { static final int[] monthDay = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; static final String[] dayOfTheWeek = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; public static void main(String[] args) { Scanner sc = null; try { sc = new Scanner(System.in); while (sc.hasNextInt()) { int month = sc.nextInt(); int day = sc.nextInt(); if (month == 0 || day == 0) { break; } System.out.println(getDayOfTheWeek(month, day)); } } finally { sc.close(); } } public static String getDayOfTheWeek(int m, int d) { int sum = 0; for (int i = 0; i < m - 1; i++) { sum += monthDay[i]; } sum += d; return dayOfTheWeek[sum % 7]; } }
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
3
229
2
import java.util.Calendar; import java.util.Scanner; class Main { private static final int YEAR = 2004; private static final String SUNDAY = "Sunday"; private static final String MONDAY = "Monday"; private static final String TUESDAY = "Tuesday"; private static final String WEDNESDAY = "Wednesday"; private static final String THURSDAY = "Thursday"; private static final String FRIDAY = "Friday"; private static final String SATURDAY = "Saturday"; public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { while (sc.hasNextInt()) { int month = sc.nextInt(); int day = sc.nextInt(); if (month == 0 || day == 0) { break; } System.out.println(getDayOfTheWeek(month, day)); } } } private static String getDayOfTheWeek(int month, int day) { Calendar calendar = Calendar.getInstance(); calendar.set(YEAR, month, day); String dayOfTheWeek = null; switch (calendar.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: dayOfTheWeek = SUNDAY; break; case Calendar.MONDAY: dayOfTheWeek = MONDAY; break; case Calendar.TUESDAY: dayOfTheWeek = TUESDAY; break; case Calendar.WEDNESDAY: dayOfTheWeek = WEDNESDAY; break; case Calendar.THURSDAY: dayOfTheWeek = THURSDAY; break; case Calendar.FRIDAY: dayOfTheWeek = FRIDAY; break; case Calendar.SATURDAY: dayOfTheWeek = SATURDAY; break; } return dayOfTheWeek; } }
import java.util.Calendar; import java.util.Scanner; class Main { private static final int YEAR = 2004; private static final String SUNDAY = "Sunday"; private static final String MONDAY = "Monday"; private static final String TUESDAY = "Tuesday"; private static final String WEDNESDAY = "Wednesday"; private static final String THURSDAY = "Thursday"; private static final String FRIDAY = "Friday"; private static final String SATURDAY = "Saturday"; public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { while (sc.hasNextInt()) { int month = sc.nextInt(); int day = sc.nextInt(); if (month == 0 || day == 0) { break; } System.out.println(getDayOfTheWeek(month, day)); } } } private static String getDayOfTheWeek(int month, int day) { Calendar calendar = Calendar.getInstance(); calendar.set(YEAR, month - 1, day); String dayOfTheWeek = null; switch (calendar.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: dayOfTheWeek = SUNDAY; break; case Calendar.MONDAY: dayOfTheWeek = MONDAY; break; case Calendar.TUESDAY: dayOfTheWeek = TUESDAY; break; case Calendar.WEDNESDAY: dayOfTheWeek = WEDNESDAY; break; case Calendar.THURSDAY: dayOfTheWeek = THURSDAY; break; case Calendar.FRIDAY: dayOfTheWeek = FRIDAY; break; case Calendar.SATURDAY: dayOfTheWeek = SATURDAY; break; } return dayOfTheWeek; } }
[["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499]]
3
310
2
import java.util.Scanner; public class Main { public static void main(String[] args) throws java.io.IOException { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); int h = scan.nextInt(); String M[] = new String[366]; for (int i = 0; i < 366; i++) { if (i % 7 == 0) { M[i] = "Thursday"; } else if (i % 7 == 1) { M[i] = "Friday"; } else if (i % 7 == 2) { M[i] = "Saturday"; } else if (i % 7 == 3) { M[i] = "Sunday"; } else if (i % 7 == 4) { M[i] = "Monday"; } else if (i % 7 == 5) { M[i] = "Tuesday"; } else { M[i] = "Wednesday"; } } while (t != 0) { if (t == 1) { System.out.println(M[h - 1]); } else if (t == 2) { System.out.println(M[30 + h]); } else if (t == 3) { System.out.println(M[59 + h]); } else if (t == 4) { System.out.println(M[90 + h]); } else if (t == 5) { System.out.println(M[120 + h]); } else if (t == 6) { System.out.println(M[151 + h]); } else if (t == 7) { System.out.println(M[181]); } else if (t == 8) { System.out.println(M[212 + h]); } else if (t == 9) { System.out.println(M[243 + h]); } else if (t == 10) { System.out.println(M[273 + h]); } else if (t == 11) { System.out.println(M[304 + h]); } else { System.out.println(M[334 + h]); } t = scan.nextInt(); h = scan.nextInt(); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) throws java.io.IOException { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); int h = scan.nextInt(); String M[] = new String[366]; for (int i = 0; i < 366; i++) { if (i % 7 == 0) { M[i] = "Thursday"; } else if (i % 7 == 1) { M[i] = "Friday"; } else if (i % 7 == 2) { M[i] = "Saturday"; } else if (i % 7 == 3) { M[i] = "Sunday"; } else if (i % 7 == 4) { M[i] = "Monday"; } else if (i % 7 == 5) { M[i] = "Tuesday"; } else { M[i] = "Wednesday"; } } while (t != 0) { if (t == 1) { System.out.println(M[h - 1]); } else if (t == 2) { System.out.println(M[30 + h]); } else if (t == 3) { System.out.println(M[59 + h]); } else if (t == 4) { System.out.println(M[90 + h]); } else if (t == 5) { System.out.println(M[120 + h]); } else if (t == 6) { System.out.println(M[151 + h]); } else if (t == 7) { System.out.println(M[181 + h]); } else if (t == 8) { System.out.println(M[212 + h]); } else if (t == 9) { System.out.println(M[243 + h]); } else if (t == 10) { System.out.println(M[273 + h]); } else if (t == 11) { System.out.println(M[304 + h]); } else { System.out.println(M[334 + h]); } t = scan.nextInt(); h = scan.nextInt(); } } }
[["+", 0, 492, 3, 4, 0, 504, 71, 16, 17, 72], ["+", 0, 492, 3, 4, 0, 504, 71, 16, 12, 22]]
3
508
2
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] days = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] dayOfWeek = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; String line; String[] input; int month, day, numMonth, numDay; while ((line = br.readLine()) != null) { input = line.split(" "); month = Integer.parseInt(input[0]); day = Integer.parseInt(input[1]); if (month == 0 && day == 0) { break; } numMonth = month - 1; numDay = day; for (int i = 0; i < numMonth; i++) { numDay += days[i]; } System.out.println(dayOfWeek[numDay % 7 - 1]); } } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] days = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] dayOfWeek = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; String line; String[] input; int month, day, numMonth, numDay; while ((line = br.readLine()) != null) { input = line.split(" "); month = Integer.parseInt(input[0]); day = Integer.parseInt(input[1]); if (month == 0 && day == 0) { break; } numMonth = month - 1; numDay = day; for (int i = 0; i < numMonth; i++) { numDay += days[i]; } System.out.println(dayOfWeek[(numDay - 1) % 7]); } } }
[["+", 3, 4, 0, 504, 71, 16, 31, 23, 0, 24], ["-", 3, 4, 0, 504, 71, 16, 31, 16, 17, 109], ["-", 3, 4, 0, 504, 71, 16, 31, 16, 12, 499], ["+", 3, 4, 0, 504, 71, 16, 31, 23, 0, 25], ["+", 0, 492, 3, 4, 0, 504, 71, 16, 17, 109], ["+", 0, 492, 3, 4, 0, 504, 71, 16, 12, 499]]
3
252
6
import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); void run() { int[] map = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int[] dp = new int[12]; String[] str = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Monday", "Sunday", }; dp[0] = 2; for (int i = 1; i < 12; i++) { dp[i] = (dp[i - 1] + map[i - 1]) % 7; } for (;;) { int m = sc.nextInt(); int n = sc.nextInt(); if ((m | n) == 0) { break; } System.out.println(str[(dp[m - 1] + n) % 7]); } } public static void main(String[] args) { Main m = new Main(); m.run(); } }
import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); void run() { int[] map = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int[] dp = new int[12]; String[] str = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", }; dp[0] = 2; for (int i = 1; i < 12; i++) { dp[i] = (dp[i - 1] + map[i - 1]) % 7; } for (;;) { int m = sc.nextInt(); int n = sc.nextInt(); if ((m | n) == 0) { break; } System.out.println(str[(dp[m - 1] + n) % 7]); } } public static void main(String[] args) { Main m = new Main(); m.run(); } }
[["-", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491], ["+", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491]]
3
255
2
import java.util.Scanner; class Main { private static void solve() { Scanner scanner = new Scanner(System.in); int[] days = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] map = {"Wednesday", "Thursady", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; while (true) { int month = scanner.nextInt(); int day = scanner.nextInt(); if (month == 0 && day == 0) { break; } int total = 0; for (int i = 0; i < month - 1; i++) { total += days[i]; } total += day; System.out.println(map[total % 7]); } } public static void main(String... args) { solve(); } }
import java.util.Scanner; class Main { private static void solve() { Scanner scanner = new Scanner(System.in); int[] days = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] map = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; while (true) { int month = scanner.nextInt(); int day = scanner.nextInt(); if (month == 0 && day == 0) { break; } int total = 0; for (int i = 0; i < month - 1; i++) { total += days[i]; } total += day; System.out.println(map[total % 7]); } } public static void main(String... args) { solve(); } }
[["-", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491], ["+", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491]]
3
197
2
import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { static final List<String> WEEK_STR = Collections.unmodifiableList( Arrays.asList("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")); static final List<Integer> MONTH_DATE = Collections.unmodifiableList( Arrays.asList(31, 29, 31, 30, 30, 30, 31, 31, 30, 31, 30, 31)); public static void main(String[] args) { Scanner in = new Scanner(System.in); int month = in.nextInt(); int date = in.nextInt(); while (month > 0) { int weekDate = 2 + date; for (int m = 0; m < month - 1; m++) { weekDate += MONTH_DATE.get(m); } System.out.println(WEEK_STR.get(weekDate % 7)); month = in.nextInt(); date = in.nextInt(); } } }
import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { static final List<String> WEEK_STR = Collections.unmodifiableList( Arrays.asList("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")); static final List<Integer> MONTH_DATE = Collections.unmodifiableList( Arrays.asList(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)); public static void main(String[] args) { Scanner in = new Scanner(System.in); int month = in.nextInt(); int date = in.nextInt(); while (month > 0) { int weekDate = 2 + date; for (int m = 0; m < month - 1; m++) { weekDate += MONTH_DATE.get(m); } System.out.println(WEEK_STR.get(weekDate % 7)); month = in.nextInt(); date = in.nextInt(); } } }
[["-", 51, 492, 3, 4, 0, 492, 3, 4, 0, 499], ["+", 51, 492, 3, 4, 0, 492, 3, 4, 0, 499]]
3
236
2
import java.util.*; public class Main { private void doit() { Scanner sc = new Scanner(System.in); int[] month = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] date = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "wednesday"}; int[] monthAcc = new int[13]; for (int i = 1; i < 13; i++) { monthAcc[i] = monthAcc[i - 1] + month[i]; } while (true) { int a = sc.nextInt(); int b = sc.nextInt(); if ((a | b) == 0) break; int today = monthAcc[a - 1] + b; int ans = (today - 1) % 7; System.out.println(date[ans]); } } public static void main(String[] args) { Main obj = new Main(); obj.doit(); } }
import java.util.*; public class Main { private void doit() { Scanner sc = new Scanner(System.in); int[] month = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] date = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; int[] monthAcc = new int[13]; for (int i = 1; i < 13; i++) { monthAcc[i] = monthAcc[i - 1] + month[i]; } while (true) { int a = sc.nextInt(); int b = sc.nextInt(); if ((a | b) == 0) break; int today = monthAcc[a - 1] + b; int ans = (today - 1) % 7; System.out.println(date[ans]); } } public static void main(String[] args) { Main obj = new Main(); obj.doit(); } }
[["-", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491], ["+", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491]]
3
239
2
import java.io.*; import java.util.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> ans = new ArrayList<Integer>(); while (true) { StringTokenizer st = new StringTokenizer(br.readLine(), " "); int y = 2004; int m = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken()); if (m == 0) break; if (m == 1 || m == 2) { y--; if (m == 1) m = 13; if (m == 2) m = 14; } ans.add((y + (y / 4) - (y / 100) + (y / 400) + ((13 * m + 8) / 5) + d) % 7); } for (int a : ans) { switch (a) { case 0: System.out.println("Sunday"); break; case 1: System.out.println("Monday"); break; case 2: System.out.println("Thuesday"); break; case 3: System.out.println("Wednesday"); break; case 4: System.out.println("Thursday"); break; case 5: System.out.println("Friday"); break; case 6: System.out.println("Saturday"); break; } } } }
import java.io.*; import java.util.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> ans = new ArrayList<Integer>(); while (true) { StringTokenizer st = new StringTokenizer(br.readLine(), " "); int y = 2004; int m = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken()); if (m == 0) break; if (m == 1 || m == 2) { y--; if (m == 1) m = 13; if (m == 2) m = 14; } ans.add((y + (y / 4) - (y / 100) + (y / 400) + ((13 * m + 8) / 5) + d) % 7); } for (int a : ans) { switch (a) { case 0: System.out.println("Sunday"); break; case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; case 3: System.out.println("Wednesday"); break; case 4: System.out.println("Thursday"); break; case 5: System.out.println("Friday"); break; case 6: System.out.println("Saturday"); break; } } } }
[["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491]]
3
330
2
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); boolean exit = true; while (exit == true) { int a = sc.nextInt(); int b = sc.nextInt(); if (a == 0 && b == 0) exit = false; if (exit == true) { int count = 0; for (int j = 1; j < a; j++) { if (j == 4 || j == 6 || j == 9) { count += 30; } else if (j == 2) { count += 29; } else { count += 31; } } count += b; if (count % 7 == 1) { System.out.println("Thursday"); } else if (count % 7 == 2) { System.out.println("Friday"); } else if (count % 7 == 3) { System.out.println("Saturday"); } else if (count % 7 == 4) { System.out.println("Sunday"); } else if (count % 7 == 5) { System.out.println("Monday"); } else if (count % 7 == 6) { System.out.println("Tuesday"); } else if (count % 7 == 0) { System.out.println("Wednesday"); } } } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); boolean exit = true; while (exit == true) { int a = sc.nextInt(); int b = sc.nextInt(); if (a == 0 && b == 0) exit = false; if (exit == true) { int count = 0; for (int j = 1; j < a; j++) { if (j == 4 || j == 6 || j == 9 || j == 11) { count += 30; } else if (j == 2) { count += 29; } else { count += 31; } } count += b; if (count % 7 == 1) { System.out.println("Thursday"); } else if (count % 7 == 2) { System.out.println("Friday"); } else if (count % 7 == 3) { System.out.println("Saturday"); } else if (count % 7 == 4) { System.out.println("Sunday"); } else if (count % 7 == 5) { System.out.println("Monday"); } else if (count % 7 == 6) { System.out.println("Tuesday"); } else if (count % 7 == 0) { System.out.println("Wednesday"); } } } } }
[["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 106], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]]
3
306
4
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int[][] paper = new int[10][10]; int max = 0; int counter = 0; for (int i = 0; i < paper.length; i++) { for (int j = 0; j < paper[i].length; j++) { paper[i][j] = 0; } } while (scanner.hasNext()) { String strLine = scanner.next(); String[] str = strLine.split(","); int x = Integer.parseInt(str[0]); int y = Integer.parseInt(str[1]); int size = Integer.parseInt(str[2]); paper[x][y]++; if (isInsidePaper(x, y - 1)) paper[x][y - 1]++; if (isInsidePaper(x - 1, y)) paper[x - 1][y]++; if (isInsidePaper(x + 1, y)) paper[x + 1][y]++; if (isInsidePaper(x, y + 1)) paper[x][y + 1]++; if (size >= 2) { if (isInsidePaper(x - 1, y - 1)) paper[x - 1][y - 1]++; if (isInsidePaper(x + 1, y - 1)) paper[x + 1][y - 1]++; if (isInsidePaper(x - 1, y + 1)) paper[x - 1][y + 1]++; if (isInsidePaper(x + 1, y + 1)) paper[x + 1][y + 1]++; } if (size == 3) { if (isInsidePaper(x, y - 2)) paper[x][y - 2]++; if (isInsidePaper(x - 2, y)) paper[x - 2][y]++; if (isInsidePaper(x + 2, y)) paper[x - 2][y]++; if (isInsidePaper(x, y + 2)) paper[x][y + 2]++; } } for (int i = 0; i < paper.length; i++) { for (int j = 0; j < paper[i].length; j++) { if (paper[i][j] == 0) { counter++; } else { if (paper[i][j] > max) max = paper[i][j]; } } } System.out.println(counter); System.out.println(max); } public static boolean isInsidePaper(int x, int y) { if (x >= 0 && x <= 9 && y >= 0 && y <= 9) { return true; } else { return false; } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int[][] paper = new int[10][10]; int max = 0; int counter = 0; for (int i = 0; i < paper.length; i++) { for (int j = 0; j < paper[i].length; j++) { paper[i][j] = 0; } } while (scanner.hasNext()) { String strLine = scanner.nextLine(); String[] str = strLine.split(","); int x = Integer.parseInt(str[0]); int y = Integer.parseInt(str[1]); int size = Integer.parseInt(str[2]); paper[x][y]++; if (isInsidePaper(x, y - 1)) paper[x][y - 1]++; if (isInsidePaper(x - 1, y)) paper[x - 1][y]++; if (isInsidePaper(x + 1, y)) paper[x + 1][y]++; if (isInsidePaper(x, y + 1)) paper[x][y + 1]++; if (size >= 2) { if (isInsidePaper(x - 1, y - 1)) paper[x - 1][y - 1]++; if (isInsidePaper(x + 1, y - 1)) paper[x + 1][y - 1]++; if (isInsidePaper(x - 1, y + 1)) paper[x - 1][y + 1]++; if (isInsidePaper(x + 1, y + 1)) paper[x + 1][y + 1]++; } if (size == 3) { if (isInsidePaper(x, y - 2)) paper[x][y - 2]++; if (isInsidePaper(x - 2, y)) paper[x - 2][y]++; if (isInsidePaper(x + 2, y)) paper[x + 2][y]++; if (isInsidePaper(x, y + 2)) paper[x][y + 2]++; } } for (int i = 0; i < paper.length; i++) { for (int j = 0; j < paper[i].length; j++) { if (paper[i][j] == 0) { counter++; } else { if (paper[i][j] > max) max = paper[i][j]; } } } System.out.println(counter); System.out.println(max); } public static boolean isInsidePaper(int x, int y) { if (x >= 0 && x <= 9 && y >= 0 && y <= 9) { return true; } else { return false; } } }
[["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["-", 0, 27, 0, 504, 516, 504, 71, 16, 17, 33], ["+", 0, 27, 0, 504, 516, 504, 71, 16, 17, 72]]
3
628
4
#include <stdio.h> int max2(int a, int b); int main(void) { int area[10][10]; int x, y, size; int a, b, c; int white, max; for (a = 0; a <= 9; a++) { for (b = 0; b <= 9; b++) { area[a][b] = 0; } } while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { if (size == 1) { for (a = -1; a < 2; a++) { for (b = -1; b < 2; b++) { if (b == 0 || a == 0) { area[y + a][x + b]++; } } } } else if (size == 2) { for (a = -1; a < 2; a++) { for (b = -1; b < 2; b++) { area[y + a][x + b]++; } } } else { for (a = -1; a < 2; a++) { for (b = -1; b < 2; b++) { area[y + a][x + b]++; } } area[y - 2][x]++; area[y][x - 2]++; area[y + 2][x]++; area[y][x + 2]++; } } white = 0; max = area[0][0]; for (a = 0; a <= 9; a++) { for (b = 0; b <= 9; b++) { if (area[a][b] == 0) { white++; } max = max2(max, area[a][b]); } } printf("%d\n%d\n", white, max); return (0); } int max2(int a, int b) { if (a > b) { return (a); } else { return (b); } }
#include <stdio.h> int max2(int a, int b); int main(void) { int area[100][100] = {0}; int x, y, size; int a, b, c; int white, max; for (a = 0; a <= 9; a++) { for (b = 0; b <= 9; b++) { area[a][b] = 0; } } while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { if (size == 1) { for (a = -1; a < 2; a++) { for (b = -1; b < 2; b++) { if (b == 0 || a == 0) { area[y + a][x + b]++; } } } } else if (size == 2) { for (a = -1; a < 2; a++) { for (b = -1; b < 2; b++) { area[y + a][x + b]++; } } } else { for (a = -1; a < 2; a++) { for (b = -1; b < 2; b++) { area[y + a][x + b]++; } } area[y - 2][x]++; area[y][x - 2]++; area[y + 2][x]++; area[y][x + 2]++; } } white = 0; max = area[0][0]; for (a = 0; a <= 9; a++) { for (b = 0; b <= 9; b++) { if (area[a][b] == 0) { white++; } max = max2(max, area[a][b]); } } printf("%d\n%d\n", white, max); return (0); } int max2(int a, int b) { if (a > b) { return (a); } else { return (b); } }
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
0
441
8
#include <stdio.h> int main() { int x, y, size, i, j, count = 0, max = 0; int grid[10][10] = {}; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { grid[x][y]++; grid[x - 1][y]++; grid[x + 1][y]++; grid[x][y - 1]++; grid[x][y + 1]++; if (size > 1) { grid[x + 1][y + 1]++; grid[x + 1][y - 1]++; grid[x - 1][y + 1]++; grid[x - 1][y - 1]++; } if (size == 3) { grid[x][y + 2]++; grid[x + 2][y]++; grid[x][y - 2]++; grid[x - 2][y]++; } } for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (grid[i][j] == 0) count++; else if (grid[i][j] > max) max = grid[i][j]; } } printf("%d\n%d\n", count, max); return 0; }
#include <stdio.h> int main() { int x, y, size, i, j, count = 0, max = 0; int grid[12][12] = {}; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { grid[x][y]++; grid[x - 1][y]++; grid[x + 1][y]++; grid[x][y - 1]++; grid[x][y + 1]++; if (size > 1) { grid[x + 1][y + 1]++; grid[x + 1][y - 1]++; grid[x - 1][y + 1]++; grid[x - 1][y - 1]++; } if (size == 3) { grid[x][y + 2]++; grid[x + 2][y]++; grid[x][y - 2]++; grid[x - 2][y]++; } } for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (grid[i][j] == 0) count++; else if (grid[i][j] > max) max = grid[i][j]; } } printf("%d\n%d\n", count, max); return 0; }
[["-", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
0
311
4
#include <stdio.h> int main(void) { int i, j, x, y, s, max, count; int board[14][14] = {0}; int sibuki_x[3][13] = {{0, 1, 0, -1, 0}, {0, 1, 1, 1, 0, -1, -1, -1, 0}, {0, 1, 1, 1, 0, -1, -1, -1, 0, 0, 2, 0, -2}}; int sibuki_y[3][13] = {{-1, 0, 1, 0, 0}, {-1, -1, 0, 1, 1, 1, 0, -1, 0}, {-1, -1, 0, 1, 1, 1, 0, -1, 0, 2, 0, -2, 0}}; while (scanf("%d,", &x) != EOF) { scanf("%d,%d", &y, &s); for (i = 0; s == 1 ? i < 5 : s == 2 ? i < 9 : i < 13; i++) { board[2 + x + sibuki_x[s][i]][2 + y + sibuki_y[s][i]]++; // printf("%d %d\n",x+sibuki_x[s][i],y+sibuki_y[s][i]); } } for (i = 0, count = 0, max = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (max < board[2 + i][2 + j]) max = board[2 + i][2 + j]; if (board[2 + i][2 + j] == 0) count++; } } printf("%d\n%d\n", count, max); return 0; }
#include <stdio.h> int main(void) { int i, j, x, y, s, max, count; int board[14][14] = {0}; int sibuki_x[3][13] = {{0, 1, 0, -1, 0}, {0, 1, 1, 1, 0, -1, -1, -1, 0}, {0, 1, 1, 1, 0, -1, -1, -1, 0, 0, 2, 0, -2}}; int sibuki_y[3][13] = {{-1, 0, 1, 0, 0}, {-1, -1, 0, 1, 1, 1, 0, -1, 0}, {-1, -1, 0, 1, 1, 1, 0, -1, 0, 2, 0, -2, 0}}; while (scanf("%d,", &x) != EOF) { scanf("%d,%d", &y, &s); for (i = 0; s == 1 ? i < 5 : s == 2 ? i < 9 : i < 13; i++) { board[2 + x + sibuki_x[s - 1][i]][2 + y + sibuki_y[s - 1][i]]++; // printf("%d %d\n",x+sibuki_x[s][i],y+sibuki_y[s][i]); } } for (i = 0, count = 0, max = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (max < board[2 + i][2 + j]) max = board[2 + i][2 + j]; if (board[2 + i][2 + j] == 0) count++; } } printf("%d\n%d\n", count, max); return 0; }
[["+", 71, 16, 12, 69, 28, 69, 71, 16, 17, 33], ["+", 71, 16, 12, 69, 28, 69, 71, 16, 12, 13]]
0
373
4
#include <stdio.h> int board[10][10]; int main(void) { int i, j, size, x, y, count = 0, max = 0; int dx[12] = {-1, 0, 1, 0, -1, -1, 1, 1, -2, 0, 2, 0}; int dy[12] = {0, 1, 0, -1, 1, -1, 1, -1, 0, -2, 0, 2}; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { board[i][j] = 0; } } while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { board[x][y]++; if (size == 1) { for (i = 0; i < 4; i++) { if (0 <= x + dx[i] && x + dx[i] < 10 || 0 <= y + dy[i] && y + dy[i] < 10) { board[x + dx[i]][y + dy[i]]++; } } } else if (size == 2) { for (i = 0; i < 8; i++) { if (0 <= x + dx[i] && x + dx[i] < 10 || 0 <= y + dy[i] && y + dy[i] < 10) { board[x + dx[i]][y + dy[i]]++; } } } else if (size == 3) { for (i = 0; i < 12; i++) { if (0 <= x + dx[i] && x + dx[i] < 10 || 0 <= y + dy[i] && y + dy[i] < 10) { board[x + dx[i]][y + dy[i]]++; } } } } for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (!board[i][j]) { count++; } if (board[i][j] > max) { max = board[i][j]; } } } printf("%d\n%d\n", count, max); return 0; }
#include <stdio.h> int board[10][10]; int main(void) { int i, j, size, x, y, count = 0, max = 0; int dx[12] = {-1, 0, 1, 0, -1, -1, 1, 1, -2, 0, 2, 0}; int dy[12] = {0, 1, 0, -1, 1, -1, 1, -1, 0, -2, 0, 2}; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { board[i][j] = 0; } } while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { board[x][y]++; if (size == 1) { for (i = 0; i < 4; i++) { if (0 <= x + dx[i] && x + dx[i] < 10 && 0 <= y + dy[i] && y + dy[i] < 10) { board[x + dx[i]][y + dy[i]]++; } } } else if (size == 2) { for (i = 0; i < 8; i++) { if (0 <= x + dx[i] && x + dx[i] < 10 && 0 <= y + dy[i] && y + dy[i] < 10) { board[x + dx[i]][y + dy[i]]++; } } } else if (size == 3) { for (i = 0; i < 12; i++) { if (0 <= x + dx[i] && x + dx[i] < 10 && 0 <= y + dy[i] && y + dy[i] < 10) { board[x + dx[i]][y + dy[i]]++; } } } } for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (!board[i][j]) { count++; } if (board[i][j] > max) { max = board[i][j]; } } } printf("%d\n%d\n", count, max); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 106], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 98]]
0
507
6
main() { int i, j, x, y, s, a[14][14], b = 0, c = 0; for (i = 0; i < 14; i++) for (j = 0; j < 14; j++) a[i][j] = 0; while (scanf("%d,%d,%d", &x, &y, &s) != -1) switch (s) { case 3: a[x + 2][y]++; a[x + 3][y + 1]++; a[x + 4][y]++; a[x + 3][y + 3]++; a[x + 2][y + 4]++; a[x + 1][y + 3]++; a[x][y + 2]++; a[x + 1][y + 1]++; case 1: a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x + 2][y + 1]++; a[x + 3][y + 2]++; a[x + 2][y + 3]++; break; case 2: for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) a[x + i + 1][y + j + 1]++; break; } for (i = 2; i < 12; i++) for (j = 2; j < 12; j++) { if (a[i][j] == 0) b++; if (a[i][j] > c) c = a[i][j]; } printf("%d\n%d\n", b, c); return 0; }
main() { int i, j, x, y, s, a[14][14], b = 0, c = 0; for (i = 0; i < 14; i++) for (j = 0; j < 14; j++) a[i][j] = 0; while (scanf("%d,%d,%d", &x, &y, &s) != -1) switch (s) { case 3: a[x + 2][y]++; a[x + 3][y + 1]++; a[x + 4][y + 2]++; a[x + 3][y + 3]++; a[x + 2][y + 4]++; a[x + 1][y + 3]++; a[x][y + 2]++; a[x + 1][y + 1]++; case 1: a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x + 2][y + 1]++; a[x + 3][y + 2]++; a[x + 2][y + 3]++; break; case 2: for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) a[x + i + 1][y + j + 1]++; break; } for (i = 2; i < 12; i++) for (j = 2; j < 12; j++) { if (a[i][j] == 0) b++; if (a[i][j] > c) c = a[i][j]; } printf("%d\n%d\n", b, c); return 0; }
[["+", 0, 1, 0, 27, 28, 69, 71, 16, 17, 72], ["+", 0, 1, 0, 27, 28, 69, 71, 16, 12, 13]]
0
395
2
#define a(x, y) a[x][y]++ a[99][99], x, y, z, i; main() { for (; ~scanf("%d,%d,%d", &x, &y, &z);) { x += 10; y += 10; a(x, y); a(x - 1, y); a(x, y - 1); a(x + 1, y); a(x, y + 1); if (z > 1) a(x + 1, y + 1), a(x + 1, y - 1), a(x - 1, y + 1), a(x - 1, y - 1); if (z > 2) a(x - 2, y), a(x + 2, y), a(x, y - 2), a(x, y + 2); } for (z = 0, x = 9; x++ < 20;) for (y = 9; y++ < 20;) { a[x][y] && z++; if (a[x][y] > i) i = a[x][y]; } printf("%d\n%d\n", z, i); exit(0); }
#define a(x, y) a[x][y]++ a[99][99], x, y, z, i; main() { for (; ~scanf("%d,%d,%d", &x, &y, &z);) { x += 10; y += 10; a(x, y); a(x - 1, y); a(x, y - 1); a(x + 1, y); a(x, y + 1); if (z > 1) a(x + 1, y + 1), a(x + 1, y - 1), a(x - 1, y + 1), a(x - 1, y - 1); if (z > 2) a(x - 2, y), a(x + 2, y), a(x, y - 2), a(x, y + 2); } for (z = 0, x = 9; x++ < 19;) for (y = 9; y++ < 19;) { !a[x][y] && z++; if (a[x][y] > i) i = a[x][y]; } printf("%d\n%d\n", z, i); exit(0); }
[["-", 0, 30, 0, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 30, 0, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 9, 0, 7, 8, 7, 15, 16, 12, 13], ["+", 0, 9, 0, 7, 8, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 16, 31, 91, 17, 111]]
0
278
5
#include <math.h> #include <stdio.h> int f[168], z[] = {23, 25, 12, 36, 11, 13, 35, 37, 22, 26, 48, 0}, x, y, s; int main(void) { for (; ~scanf("%d,%d,%d", &x, &y, &s);) for (s *= 4; s--; ++f[y * 12 + x + z[s]]) ; for (x = y = 0, s = 23; ++s < 144; s % 12 < 10 ? y = fmax(y, f[s]), f[s] && ++x : 0) ; return !printf("%d\n%d\n", 100 - x, y); }
#include <math.h> #include <stdio.h> int f[168], z[] = {24, 23, 25, 12, 36, 11, 13, 35, 37, 22, 26, 48, 0}, x, y, s; int main(void) { for (; ~scanf("%d,%d,%d", &x, &y, &s);) for (s *= 4; s + 1; ++f[y * 12 + x + z[s--]]) ; for (x = y = 0, s = 23; ++s < 144; s % 12 < 10 ? y = fmax(y, f[s]), f[s] && ++x : 0) ; return !printf("%d\n%d\n", 100 - x, y); }
[["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 21], ["-", 8, 9, 0, 7, 8, 7, 15, 27, 17, 68], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 17, 72], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 12, 13], ["+", 28, 69, 71, 16, 12, 69, 71, 27, 17, 68]]
0
163
6
f[168], z[] = {23, 24, 25, 12, 36, 11, 13, 35, 37, 22, 26, 48}, x, s, m, i = 23, c = 100; main(y) { for (; s ? ++f[y * 12 + x + z[--s]] : ~scanf("%d,%d,%d", &x, &y, &s) ? s = s * 4 + 1 : ++i < 142 ? i % 12 < 10 ? m = fmax(m, f[i]), f[i] ? c-- : 1 : 1 : !printf("%d\n%d\n", c, m);) ; }
f[168], z[] = {23, 24, 25, 12, 36, 11, 13, 35, 37, 22, 26, 48, 0}, x, s, m, i = 23, c = 100; main(y) { for (; s ? ++f[y * 12 + x + z[--s]] : ~scanf("%d,%d,%d", &x, &y, &s) ? s = s * 4 + 1 : ++i < 142 ? i % 12 < 10 ? m = fmax(m, f[i]), f[i] ? c-- : 1 : 1 : !printf("%d\n%d\n", c, m);) ; }
[["+", 12, 34, 12, 34, 12, 34, 12, 34, 0, 21], ["+", 12, 34, 12, 34, 12, 34, 12, 34, 31, 13]]
0
155
2
#include <stdio.h> int main(void) { int i, j, x, y, size, paper[14][14], white, max; for (j = 0; j < 14; j++) for (i = 0; i < 14; i++) paper[i][j] = 0; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { x += 2; y += 2; switch (size) { case 1: paper[x - 1][y]++; paper[x + 1][y]++; paper[x][y]++; paper[x][y - 1]++; paper[x][y + 1]++; break; case 3: paper[x - 2][y]++; paper[x + 2][y]++; paper[x][y - 2]++; paper[x][y + 2]++; case 2: for (j = -1; j <= 1; j++) for (i = -1; i <= 1; i++) paper[x + i][y + j]++; } } for (j = 2; j < 12; j++) { for (i = 2; i < 12; i++) { if (paper[i][j] == 0) white++; if (paper[i][j] > max) max = paper[i][j]; } } printf("%d\n%d\n", white, max); return 0; }
#include <stdio.h> int main(void) { int i, j, x, y, size, paper[14][14], white, max; white = max = 0; for (j = 0; j < 14; j++) for (i = 0; i < 14; i++) paper[i][j] = 0; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { x += 2; y += 2; switch (size) { case 1: paper[x - 1][y]++; paper[x + 1][y]++; paper[x][y]++; paper[x][y - 1]++; paper[x][y + 1]++; break; case 3: paper[x - 2][y]++; paper[x + 2][y]++; paper[x][y - 2]++; paper[x][y + 2]++; case 2: for (j = -1; j <= 1; j++) for (i = -1; i <= 1; i++) paper[x + i][y + j]++; } } for (j = 2; j < 12; j++) { for (i = 2; i < 12; i++) { if (paper[i][j] == 0) white++; if (paper[i][j] > max) max = paper[i][j]; } } printf("%d\n%d\n", white, max); return 0; }
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 11, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 11, 12, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
0
335
6
#include <stdio.h> int main(void) { int x, y, s; int p[14][14]; int q[3][5][5] = {{ {0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }}; int i, j; int c = 100, m = 0; while (scanf("%d,%d,%d", &x, &y, &s) != EOF) for (i = 0; i < 5; ++i) for (j = 0; j < 5; ++j) p[x + i][y + j] += q[s - 1][i][j]; for (i = 0; i < 10; ++i) { for (j = 0; j < 10; ++j) { if (p[i + 2][j + 2] >= 1) { --c; if (p[i + 2][j + 2] > m) m = p[i + 2][j + 2]; } } } printf("%d\n%d\n", c, m); return 0; }
#include <stdio.h> int main(void) { int x, y, s; int p[14][14] = {0}; int q[3][5][5] = {{ {0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }}; int i, j; int c = 100, m = 0; while (scanf("%d,%d,%d", &x, &y, &s) != EOF) for (i = 0; i < 5; ++i) for (j = 0; j < 5; ++j) p[x + i][y + j] += q[s - 1][i][j]; for (i = 0; i < 10; ++i) { for (j = 0; j < 10; ++j) { if (p[i + 2][j + 2] >= 1) { --c; if (p[i + 2][j + 2] > m) m = p[i + 2][j + 2]; } } } printf("%d\n%d\n", c, m); return 0; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
0
411
4
#include <math.h> #include <stdio.h> int p[10][10]; void drop(int x, int y) { if (-1 < x < 10 && -1 < y < 10) p[x][y]++; } int main(void) { int i, j, x, y, size; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { p[i][j] = 0; } } while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { switch (size) { case 3: drop(x + 2, y); drop(x, y + 2); drop(x - 2, y); drop(x, y - 2); case 2: drop(x + 1, y + 1); drop(x + 1, y - 1); drop(x - 1, y + 1); drop(x - 1, y - 1); case 1: drop(x + 1, y); drop(x, y + 1); drop(x - 1, y); drop(x, y - 1); default: drop(x, y); } } x = 0; y = 0; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (p[i][j] == 0) x++; else if (p[i][j] > y) y = p[i][j]; } } printf("%d\n%d\n", x, y); return 0; }
#include <math.h> #include <stdio.h> int p[10][10]; void drop(int x, int y) { if (-1 < x && x < 10 && -1 < y && y < 10) p[x][y]++; } int main(void) { int i, j, x, y, size; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { p[i][j] = 0; } } while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { switch (size) { case 3: drop(x + 2, y); drop(x, y + 2); drop(x - 2, y); drop(x, y - 2); case 2: drop(x + 1, y + 1); drop(x + 1, y - 1); drop(x - 1, y + 1); drop(x - 1, y - 1); case 1: drop(x + 1, y); drop(x, y + 1); drop(x - 1, y); drop(x, y - 1); default: drop(x, y); } } x = 0; y = 0; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (p[i][j] == 0) x++; else if (p[i][j] > y) y = p[i][j]; } } printf("%d\n%d\n", x, y); return 0; }
[["+", 15, 23, 0, 16, 31, 16, 31, 16, 17, 98], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 23, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 98]]
0
360
4
#include <stdio.h> int main(void) { int a[100][100], x, y, ink, i, j, noc, max; for (i = 0; i < 10; i++) for (j = 0; j < 10; j++) a[i][j] = 0; while (scanf("%d", &x) != EOF) { scanf(",%d,%d", &y, &ink); a[x][y]++; a[x + 1][y]++; a[x][y - 1]++; if (x != 0) a[x - 1][y]++; if (y != 0) a[x][y - 1]++; if (ink == 1) continue; a[x + 1][y + 1]++; if (x != 0) a[x - 1][y + 1]++; if (y != 0) a[x + 1][y - 1]++; if (x != 0 && y != 0) a[x - 1][y - 1]++; if (ink == 2) continue; a[x][y + 2]++; a[x + 2][y]++; if (x > 1) a[x - 2][y]++; if (y > 1) a[x][y - 2]++; } noc = max = 0; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (a[i][j] == 0) noc++; else if (max < a[i][j]) max = a[i][j]; } } printf("%d\n%d\n", noc - 1, max - 1); return 0; }
#include <stdio.h> int main(void) { int a[100][100], x, y, ink, i, j, noc, max; for (i = 0; i < 10; i++) for (j = 0; j < 10; j++) a[i][j] = 0; while (scanf("%d", &x) != EOF) { scanf(",%d,%d", &y, &ink); a[x][y]++; a[x + 1][y]++; a[x][y + 1]++; if (x != 0) a[x - 1][y]++; if (y != 0) a[x][y - 1]++; if (ink == 1) continue; a[x + 1][y + 1]++; if (x != 0) a[x - 1][y + 1]++; if (y != 0) a[x + 1][y - 1]++; if (x != 0 && y != 0) a[x - 1][y - 1]++; if (ink == 2) continue; a[x][y + 2]++; a[x + 2][y]++; if (x > 1) a[x - 2][y]++; if (y > 1) a[x][y - 2]++; } noc = max = 0; for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (a[i][j] == 0) noc++; else if (max < a[i][j]) max = a[i][j]; } } printf("%d\n%d\n", noc, max); return 0; }
[["-", 0, 1, 0, 27, 28, 69, 71, 16, 17, 33], ["+", 0, 1, 0, 27, 28, 69, 71, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
0
403
6
#include <cstdio> #include <iostream> using namespace std; #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) for (int i = 0; i < a; i++) int maze[10][10]; int smallx[5] = {1, -1, 0, 0, 0}; int smally[5] = {0, 0, 0, 1, -1}; int midx[4] = {1, 1, -1, -1}; int midy[4] = {1, -1, 1, -1}; int largex[4] = {2, -2, 0, 0}; int largey[4] = {0, 0, 2, -2}; bool inmaze(int x, int y) { return (0 <= x && x < 10) && (0 <= y && y < 10); } void Fsmall(int x, int y) { rep(i, 5) if (inmaze(x + smallx[i], y + smally[i])) maze[x + smallx[i]][y + smally[i]]++; } void Fmid(int x, int y) { rep(i, 4) if (inmaze(x + midx[i], y + midy[i])) maze[x + midx[i]][y + midy[i]]++; } void Flarge(int x, int y) { rep(i, 5) if (inmaze(x + largex[i], y + largey[i])) maze[x + largex[i]][y + largey[i]]++; } int main(void) { int x, y, size; rep(i, 10) rep(j, 10) maze[i][j] = 0; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) switch (size) { case 3: Flarge(x, y); case 2: Fmid(x, y); case 1: Fsmall(x, y); } int no = 0, ma = -1; rep(i, 10) rep(j, 10) { if (maze[i][j] == 0) no++; ma = max(ma, maze[i][j]); } cout << no << endl << ma << endl; }
#include <cstdio> #include <iostream> using namespace std; #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) for (int i = 0; i < a; i++) int maze[10][10]; int smallx[5] = {1, -1, 0, 0, 0}; int smally[5] = {0, 0, 0, 1, -1}; int midx[4] = {1, 1, -1, -1}; int midy[4] = {1, -1, 1, -1}; int largex[4] = {2, -2, 0, 0}; int largey[4] = {0, 0, 2, -2}; bool inmaze(int x, int y) { return (0 <= x && x < 10) && (0 <= y && y < 10); } void Fsmall(int x, int y) { rep(i, 5) if (inmaze(x + smallx[i], y + smally[i])) maze[x + smallx[i]][y + smally[i]]++; } void Fmid(int x, int y) { rep(i, 4) if (inmaze(x + midx[i], y + midy[i])) maze[x + midx[i]][y + midy[i]]++; } void Flarge(int x, int y) { rep(i, 4) if (inmaze(x + largex[i], y + largey[i])) maze[x + largex[i]][y + largey[i]]++; } int main(void) { int x, y, size; rep(i, 10) rep(j, 10) maze[i][j] = 0; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) switch (size) { case 3: Flarge(x, y); case 2: Fmid(x, y); case 1: Fsmall(x, y); } int no = 0, ma = -1; rep(i, 10) rep(j, 10) { if (maze[i][j] == 0) no++; ma = max(ma, maze[i][j]); } cout << no << endl << ma << endl; }
[["-", 8, 9, 0, 42, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 42, 0, 2, 3, 4, 0, 13]]
1
490
2
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) #define X real() #define Y imag() typedef complex<double> P; int main() { const int N = 10; int masu[N][N] = {0}; int a, b, c; while (scanf("%d,%d,%d", &a, &b, &c) != EOF) { string hit[4][5] = { {"", "", "", "", ""}, { "00000", "00100", "01110", "00100", "00000", }, { "00000", "01110", "01110", "01110", "00000", }, { "00100", "01110", "11111", "01110", "00100", }, }; a -= 2; b -= 2; rep(i, 5) { rep(j, 5) { int x = a + i; int y = b + j; if (x < 0 || y < 0 || x >= N || y >= N) continue; masu[y][x] += hit[c][i][j] - '0'; } } } int z = 0; int p = 0; rep(i, N) rep(j, N) { if (masu[i][j] == 0) z++; p = max(p, masu[i][j]); } printf("%d %d\n", z, p); }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) #define X real() #define Y imag() typedef complex<double> P; int main() { const int N = 10; int masu[N][N] = {0}; int a, b, c; while (scanf("%d,%d,%d", &a, &b, &c) != EOF) { string hit[4][5] = { {"", "", "", "", ""}, { "00000", "00100", "01110", "00100", "00000", }, { "00000", "01110", "01110", "01110", "00000", }, { "00100", "01110", "11111", "01110", "00100", }, }; a -= 2; b -= 2; rep(i, 5) { rep(j, 5) { int x = a + i; int y = b + j; if (x < 0 || y < 0 || x >= N || y >= N) continue; masu[y][x] += hit[c][i][j] - '0'; } } } int z = 0; int p = 0; rep(i, N) rep(j, N) { if (masu[i][j] == 0) z++; p = max(p, masu[i][j]); } printf("%d\n%d\n", z, p); }
[["-", 0, 1, 0, 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, 44]]
1
358
4
#include <algorithm> #include <cstdio> using namespace std; int field[10][10], x, y, s, cnt, ma; void s1() { if (y - 1 >= 0) field[x][y - 1]++; if (x - 1 >= 0) field[x - 1][y]++; if (y + 1 < 10) field[x][y + 1]++; if (x + 1 < 10) field[x + 1][y]++; } void s2() { s1(); if (x - 1 >= 0 && y - 1 >= 0) field[x - 1][y - 1]++; if (x - 1 >= 0 && y + 1 < 10) field[x - 1][y + 1]++; if (x + 1 < 10 && y - 1 >= 0) field[x + 1][y - 1]++; if (x + 1 < 10 && y + 1 < 10) field[x + 1][y + 1]++; } void s3() { s2(); if (y - 2 >= 0) field[x][y - 2]++; if (x - 2 >= 0) field[x - 2][y]++; if (y + 2 < 10) field[x][y + 2]++; if (x + 2 < 10) field[x + 2][y]++; } int main() { while (scanf("%d,%d,%d", &x, &y, &s) != EOF) { field[x][y]++; if (s == 1) s1(); else if (s == 2) s2(); else if (s == 3) s3(); for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { if (!field[i][j]) ++cnt; else ma = max(ma, field[i][j]); } } } printf("%d\n%d\n", cnt, ma); return 0; }
#include <algorithm> #include <cstdio> using namespace std; int field[10][10], x, y, s, cnt, ma; void s1() { if (y - 1 >= 0) field[x][y - 1]++; if (x - 1 >= 0) field[x - 1][y]++; if (y + 1 < 10) field[x][y + 1]++; if (x + 1 < 10) field[x + 1][y]++; } void s2() { s1(); if (x - 1 >= 0 && y - 1 >= 0) field[x - 1][y - 1]++; if (x - 1 >= 0 && y + 1 < 10) field[x - 1][y + 1]++; if (x + 1 < 10 && y - 1 >= 0) field[x + 1][y - 1]++; if (x + 1 < 10 && y + 1 < 10) field[x + 1][y + 1]++; } void s3() { s2(); if (y - 2 >= 0) field[x][y - 2]++; if (x - 2 >= 0) field[x - 2][y]++; if (y + 2 < 10) field[x][y + 2]++; if (x + 2 < 10) field[x + 2][y]++; } int main() { while (scanf("%d,%d,%d", &x, &y, &s) != EOF) { field[x][y]++; if (s == 1) s1(); else if (s == 2) s2(); else if (s == 3) s3(); } for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { if (!field[i][j]) ++cnt; else ma = max(ma, field[i][j]); } } printf("%d\n%d\n", cnt, ma); return 0; }
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
1
461
2
#include <iostream> #include <string> using namespace std; int main() { int area[10][10] = {0}; int x, nx, ny, y, size; int count = 0; int max = 0; char ch1, ch2; while (cin >> x >> ch1 >> y >> ch2 >> size) { nx = x + 2; ny = y + 2; switch (size) { case 3: area[nx - 2][ny]++; area[nx + 2][ny]++; area[nx][ny - 2]++; area[nx][ny + 2]++; case 2: area[nx - 1][ny - 1]++; area[nx + 1][ny - 1]++; area[nx - 1][ny + 1]++; area[nx + 1][ny + 1]++; case 1: area[nx - 1][ny]++; area[nx + 1][ny]++; area[nx][ny - 1]++; area[nx][ny + 1]++; } area[nx][ny]++; } for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (area[i][j] == 0) { count++; } if (max < area[i][j]) { max = area[i][j]; } } } cout << count << endl; cout << max << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { int area[14][14] = {0}; int x, nx, ny, y, size; int count = 0; int max = 0; char ch1, ch2; while (cin >> x >> ch1 >> y >> ch2 >> size) { nx = x + 2; ny = y + 2; switch (size) { case 3: area[nx - 2][ny]++; area[nx + 2][ny]++; area[nx][ny - 2]++; area[nx][ny + 2]++; case 2: area[nx - 1][ny - 1]++; area[nx + 1][ny - 1]++; area[nx - 1][ny + 1]++; area[nx + 1][ny + 1]++; case 1: area[nx - 1][ny]++; area[nx + 1][ny]++; area[nx][ny - 1]++; area[nx][ny + 1]++; } area[nx][ny]++; } for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (area[i][j] == 0) { count++; } if (max < area[i][j]) { max = area[i][j]; } } } cout << count << endl; cout << max << endl; return 0; }
[["-", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
1
333
4
#include <algorithm> #include <array> #include <chrono> #include <fstream> #include <functional> #include <iostream> #include <map> #include <math.h> #include <memory.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #pragma warning(disable : 4996) using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) typedef long long Int; const double PI = 3.141592653589793238; const Int INF = 999999999999; typedef pair<int, int> P; int S[3][3] = { {0, 1, 0}, {1, 1, 1}, {0, 1, 0}, }; int M[3][3] = { {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, }; int L[5][5] = { {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }; int tile[10][10]; int main() { int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { int a = 0; int b = 0; int a_ = 0; int b_ = 0; if (size == 1) { while (x + a - 1 < 0) ++a; while (y + b - 1 < 0) ++b; while (x + 2 + a_ > 10) --a_; while (y + 2 + b_ > 10) --b_; for (int i = y - 1 + b; i < y + 2 + b_; ++i) { for (int j = x - 1 + a; j < x + 2 + a_; ++j) { tile[i][j] += S[i + 1 - y][j + 1 - x]; } } } if (size == 2) { while (x + a - 1 < 0) ++a; while (y + b - 1 < 0) ++b; while (x + 2 + a_ > 10) --a_; while (y + 2 + b_ > 10) --b_; for (int i = y - 1 + b; i < y + 2 + b_; ++i) { for (int j = x - 1 + a; j < x + 2 + a_; ++j) { tile[i][j] += M[i + 1 - y][j + 1 - x]; } } } if (size == 3) { while (x + a - 2 < 0) ++a; while (y + b - 2 < 0) ++b; while (x + 3 + a_ > 10) --a_; while (y + 3 + b_ > 10) --b_; for (int i = y - 2 + b; i < y + 3 + b_; ++i) { for (int j = x - 2 + a; j < x + 3 + a_; ++j) { tile[i][j] += L[i + 2 - y][j + 2 - x]; } } } int white = 0; int max_ = -1; REP(i, 10) { REP(j, 10) { if (!tile[i][j]) ++white; max_ = max(tile[i][j], max_); } } cout << white << endl << max_ << endl; } return 0; }
#include <algorithm> #include <array> #include <chrono> #include <fstream> #include <functional> #include <iostream> #include <map> #include <math.h> #include <memory.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #pragma warning(disable : 4996) using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) typedef long long Int; const double PI = 3.141592653589793238; const Int INF = 999999999999; typedef pair<int, int> P; int S[3][3] = { {0, 1, 0}, {1, 1, 1}, {0, 1, 0}, }; int M[3][3] = { {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, }; int L[5][5] = { {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }; int tile[10][10]; int main() { int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { int a = 0; int b = 0; int a_ = 0; int b_ = 0; if (size == 1) { while (x + a - 1 < 0) ++a; while (y + b - 1 < 0) ++b; while (x + 2 + a_ > 10) --a_; while (y + 2 + b_ > 10) --b_; for (int i = y - 1 + b; i < y + 2 + b_; ++i) { for (int j = x - 1 + a; j < x + 2 + a_; ++j) { tile[i][j] += S[i + 1 - y][j + 1 - x]; } } } if (size == 2) { while (x + a - 1 < 0) ++a; while (y + b - 1 < 0) ++b; while (x + 2 + a_ > 10) --a_; while (y + 2 + b_ > 10) --b_; for (int i = y - 1 + b; i < y + 2 + b_; ++i) { for (int j = x - 1 + a; j < x + 2 + a_; ++j) { tile[i][j] += M[i + 1 - y][j + 1 - x]; } } } if (size == 3) { while (x + a - 2 < 0) ++a; while (y + b - 2 < 0) ++b; while (x + 3 + a_ > 10) --a_; while (y + 3 + b_ > 10) --b_; for (int i = y - 2 + b; i < y + 3 + b_; ++i) { for (int j = x - 2 + a; j < x + 3 + a_; ++j) { tile[i][j] += L[i + 2 - y][j + 2 - x]; } } } } int white = 0; int max_ = -1; REP(i, 10) { REP(j, 10) { if (!tile[i][j]) ++white; max_ = max(tile[i][j], max_); } } cout << white << endl << max_ << endl; return 0; }
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
745
2
#include <stdio.h> void tyu(int x, int y, int N[15][15]) { int xt, yt; xt = x - 1; yt = y - 1; for (int i = yt; i <= yt + 2; i++) for (int j = xt; j <= xt + 2; j++) N[i][j]++; } void syo(int x, int y, int N[15][15]) { N[y][x]++; N[y + 1][x]++; N[y - 1][x]++; N[y][x + 1]++; N[y][x - 1]++; } void dai(int x, int y, int N[15][15]) { int xt, yt; xt = x - 1; yt = y - 1; for (int i = yt; i <= yt + 2; i++) for (int j = xt; j <= xt + 2; j++) N[i][j]++; N[y + 2][x]++; N[y - 2][x]++; N[y][x + 2]++; N[y][x - 2]++; } int main() { int x, y, z, PP[15][15] = {}, xt = 0, yt = 0; while (scanf("%d,%d,%d", &x, &y, &z) != EOF) { xt = x + 2; yt = y + 2; if (z == 1) syo(xt, yt, PP); else if (z == 2) tyu(xt, yt, PP); else if (z == 3) dai(xt, yt, PP); } int SUM1 = 0, SUM2 = 0, max = 0; for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (PP[i][j] == 0) SUM1++; if (PP[i][j] > max) { max = PP[i][j]; SUM2 = 1; } else if (PP[i][j] == max) SUM2++; } } printf("%d\n%d\n", SUM1, SUM2); return 0; }
#include <stdio.h> void tyu(int x, int y, int N[15][15]) { int xt, yt; xt = x - 1; yt = y - 1; for (int i = yt; i <= yt + 2; i++) for (int j = xt; j <= xt + 2; j++) N[i][j]++; } void syo(int x, int y, int N[15][15]) { N[y][x]++; N[y + 1][x]++; N[y - 1][x]++; N[y][x + 1]++; N[y][x - 1]++; } void dai(int x, int y, int N[15][15]) { int xt, yt; xt = x - 1; yt = y - 1; for (int i = yt; i <= yt + 2; i++) for (int j = xt; j <= xt + 2; j++) N[i][j]++; N[y + 2][x]++; N[y - 2][x]++; N[y][x + 2]++; N[y][x - 2]++; } int main() { int x, y, z, PP[15][15] = {}, xt = 0, yt = 0; while (scanf("%d,%d,%d", &x, &y, &z) != EOF) { xt = x + 2; yt = y + 2; if (z == 1) syo(xt, yt, PP); else if (z == 2) tyu(xt, yt, PP); else if (z == 3) dai(xt, yt, PP); } int SUM1 = 0, SUM2 = 0, max = 0; for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (PP[i][j] == 0) SUM1++; if (PP[i][j] > max) { max = PP[i][j]; SUM2 = 1; } else if (PP[i][j] == max) SUM2++; } } printf("%d\n%d\n", SUM1, max); return 0; }
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
509
2
#include <stdio.h> #include <stdlib.h> int main() { int table[10][10] = {{0}}; int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { switch (size) { case 1: { table[y][x]++; if (x - 1 >= 0) table[y][x - 1]++; if (x + 1 <= 9) table[y][x + 1]++; if (y - 1 >= 0) table[y - 1][x]++; if (y + 1 <= 9) table[y + 1][x]++; } break; case 2: { table[y][x]++; if (x - 1 >= 0) { table[y][x - 1]++; if (y - 1 >= 0) table[y - 1][x - 1]++; if (y + 1 <= 9) table[y + 1][x - 1]++; } if (x + 1 <= 9) { table[y][x + 1]++; if (y - 1 >= 0) table[y - 1][x + 1]++; if (y + 1 <= 9) table[y + 1][x + 1]++; } if (y - 1 >= 0) table[y - 1][x]++; if (y + 1 <= 9) table[y + 1][x]++; } break; default: { table[y][x]++; if (x - 1 >= 0) { table[y][x - 1]++; if (y - 1 >= 0) table[y - 1][x - 1]++; if (y + 1 <= 9) table[y + 1][x - 1]++; if (x - 2 >= 0) table[y][x - 2]++; } if (x + 1 <= 9) { table[y][x + 1]++; if (y - 1 >= 0) table[y - 1][x + 1]++; if (y + 1 <= 9) table[y + 1][x + 1]++; if (x + 2 <= 9) table[y][x + 2]++; } if (y - 1 >= 0) { table[y - 1][x]++; if (y - 2 >= 0) table[y - 2][x]++; } if (y + 1 <= 9) { table[y + 1][x]++; if (y + 2 <= 9) table[y + 2][x]++; } } break; } } int cnt = 0, i, j, max = 0; for (j = 0; j < 10; j++) { for (i = 0; i < 10; i++) { if (table[j][i] > max) max = table[j][i]; if (table[j][i] == 0) cnt++; } } printf("%d\n%d\n", max, cnt); return 0; }
#include <stdio.h> #include <stdlib.h> int main() { int table[10][10] = {{0}}; int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { switch (size) { case 1: { table[y][x]++; if (x - 1 >= 0) table[y][x - 1]++; if (x + 1 <= 9) table[y][x + 1]++; if (y - 1 >= 0) table[y - 1][x]++; if (y + 1 <= 9) table[y + 1][x]++; } break; case 2: { table[y][x]++; if (x - 1 >= 0) { table[y][x - 1]++; if (y - 1 >= 0) table[y - 1][x - 1]++; if (y + 1 <= 9) table[y + 1][x - 1]++; } if (x + 1 <= 9) { table[y][x + 1]++; if (y - 1 >= 0) table[y - 1][x + 1]++; if (y + 1 <= 9) table[y + 1][x + 1]++; } if (y - 1 >= 0) table[y - 1][x]++; if (y + 1 <= 9) table[y + 1][x]++; } break; default: { table[y][x]++; if (x - 1 >= 0) { table[y][x - 1]++; if (y - 1 >= 0) table[y - 1][x - 1]++; if (y + 1 <= 9) table[y + 1][x - 1]++; if (x - 2 >= 0) table[y][x - 2]++; } if (x + 1 <= 9) { table[y][x + 1]++; if (y - 1 >= 0) table[y - 1][x + 1]++; if (y + 1 <= 9) table[y + 1][x + 1]++; if (x + 2 <= 9) table[y][x + 2]++; } if (y - 1 >= 0) { table[y - 1][x]++; if (y - 2 >= 0) table[y - 2][x]++; } if (y + 1 <= 9) { table[y + 1][x]++; if (y + 2 <= 9) table[y + 2][x]++; } } break; } } int cnt = 0, i, j, max = 0; for (j = 0; j < 10; j++) { for (i = 0; i < 10; i++) { if (table[j][i] > max) max = table[j][i]; if (table[j][i] == 0) cnt++; } } printf("%d\n%d\n", cnt, max); return 0; }
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
688
4
#include <cstdio> #include <iostream> using namespace std; int main() { int x, y, s; char com; int a[10][10]; for (int i = 0; i < 100; i++) a[i / 10][i % 10] = 0; while (cin >> x >> com >> y >> com >> s) { a[x][y]++; if (x > 0) a[x - 1][y]++; if (x < 9) a[x + 1][y]++; if (y > 0) a[x][y - 1]++; if (y < 9) a[x][y + 1]++; if (s > 1) { if (x > 0 and y > 0) a[x - 1][y - 1]++; if (x > 0 and y < 9) a[x - 1][y + 1]++; if (x < 9 and y > 0) a[x + 1][y - 1]++; if (x < 9 and y < 9) a[x + 1][y + 1]++; } if (s == 3) { if (x > 1) a[x - 2][y]++; if (x < 8) a[x + 2][y]++; if (y > 1) a[x][y - 2]++; if (y < 8) a[x][y + 2]++; } } int c = 0; int b = 0; for (int i = 0; i < 100; i++) { int t = a[i / 10][i % 10]; if (t == 0) c++; if (b < t) b = t; } cout << c << " " << b << endl; }
#include <cstdio> #include <iostream> using namespace std; int main() { int x, y, s; char com; int a[10][10]; for (int i = 0; i < 100; i++) a[i / 10][i % 10] = 0; while (cin >> x >> com >> y >> com >> s) { a[x][y]++; if (x > 0) a[x - 1][y]++; if (x < 9) a[x + 1][y]++; if (y > 0) a[x][y - 1]++; if (y < 9) a[x][y + 1]++; if (s > 1) { if (x > 0 and y > 0) a[x - 1][y - 1]++; if (x > 0 and y < 9) a[x - 1][y + 1]++; if (x < 9 and y > 0) a[x + 1][y - 1]++; if (x < 9 and y < 9) a[x + 1][y + 1]++; } if (s == 3) { if (x > 1) a[x - 2][y]++; if (x < 8) a[x + 2][y]++; if (y > 1) a[x][y - 2]++; if (y < 8) a[x][y + 2]++; } } int c = 0; int b = 0; for (int i = 0; i < 100; i++) { int t = a[i / 10][i % 10]; if (t == 0) c++; if (b < t) b = t; } cout << c << endl; cout << b << endl; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22]]
1
402
6
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define fi first #define se second #define fcout(n) cout << fixed << setprecision((n)) #define cinl(str) getline(cin, (str)) using namespace std; bool value(int y, int x, int R, int C) { return 0 <= y && y < R && 0 <= x && x < C; } typedef pair<int, int> pii; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vll; typedef vector<vi> vvi; double pie = acos(-1); int INF = 10000009; int dx[4] = {0, -1, 0, 1}; int dy[4] = {-1, 0, 1, 0}; int dx2[4] = {0, -2, 0, 2}; int dy2[4] = {-2, 0, 2, 0}; int m[15][15]; int main() { int x[10000], y[10000], z[10000]; char s, t; int count = 0, M = 0; int n = 0; while (true) { cin >> x[n] >> s >> y[n] >> t >> z[n]; if (cin.eof()) break; n++; } for (int i = 0; i <= n; i++) { if (z[i] == 1) { m[y[i]][x[i]]++; for (int j = 0; j < 4; j++) { if (value(y[i] + dy[j], x[i] + dx[j], 10, 10)) { m[y[i] + dy[j]][x[i] + dx[j]]++; } } } else if (z[i] == 2) { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (value(y[i] + k, x[i] + j, 10, 10)) { m[y[i] + k][x[i] + j]++; } } } } else { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (value(y[i] + k, x[i] + j, 10, 10)) { m[y[i] + k][x[i] + j]++; } } } for (int j = 0; j < 4; j++) { if (value(y[i] + dy2[j], x[i] + dx2[j], 10, 10)) { m[y[i] + dy2[j]][x[i] + dx2[j]]++; } } } } for (int i = 0; i <= 9; i++) { for (int j = 0; j <= 9; j++) { if (m[i][j] == 0) count++; if (m[i][j] > M) M = m[i][j]; } } cout << count << endl; cout << M << endl; }
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define fi first #define se second #define fcout(n) cout << fixed << setprecision((n)) #define cinl(str) getline(cin, (str)) using namespace std; bool value(int y, int x, int R, int C) { return 0 <= y && y < R && 0 <= x && x < C; } typedef pair<int, int> pii; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vll; typedef vector<vi> vvi; double pie = acos(-1); int INF = 10000009; int dx[4] = {0, -1, 0, 1}; int dy[4] = {-1, 0, 1, 0}; int dx2[4] = {0, -2, 0, 2}; int dy2[4] = {-2, 0, 2, 0}; int m[15][15]; int main() { int x[10000], y[10000], z[10000]; char s, t; int count = 0, M = 0; int n = 0; while (true) { cin >> x[n] >> s >> y[n] >> t >> z[n]; if (cin.eof()) break; n++; } n--; // cout<<n<<endl; for (int i = 0; i <= n; i++) { if (z[i] == 1) { m[y[i]][x[i]]++; for (int j = 0; j < 4; j++) { if (value(y[i] + dy[j], x[i] + dx[j], 10, 10)) { m[y[i] + dy[j]][x[i] + dx[j]]++; } } } else if (z[i] == 2) { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (value(y[i] + k, x[i] + j, 10, 10)) { m[y[i] + k][x[i] + j]++; } } } } else { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (value(y[i] + k, x[i] + j, 10, 10)) { m[y[i] + k][x[i] + j]++; } } } for (int j = 0; j < 4; j++) { if (value(y[i] + dy2[j], x[i] + dx2[j], 10, 10)) { m[y[i] + dy2[j]][x[i] + dx2[j]]++; } } } /*for(int i=0;i<10;i++){ for(int j=0;j<10;j++){ cout<<m[i][j]<<" "; } cout<<endl; }*/ } for (int i = 0; i <= 9; i++) { for (int j = 0; j <= 9; j++) { if (m[i][j] == 0) count++; if (m[i][j] > M) M = m[i][j]; } } cout << count << endl; cout << M << endl; }
[["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
719
3
#include <algorithm> #include <cctype> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; int size(string x) { string::size_type size = x.size(); return size; } #define fu(l, k) for (int i = l; i < k; i++) #define fd(l, k) for (int i = l; i > k; i--) #define fi first #define se second typedef vector<string> vs; typedef vector<int> vi; double pi() { return M_PI; } typedef set<int> set_i; typedef set<string> set_s; int INF = 1000000; int main() { int dp[11][11] = {}; int x, y, ss; string s; while (cin >> x >> s >> y >> s >> ss) { dp[x][y]++; if (ss == 1) { if (y - 1 >= 0) dp[x][y - 1]++; if (y + 1 <= 9) dp[x][y + 1]++; if (x - 1 >= 0) dp[x - 1][y]++; if (x + 1 <= 9) dp[x + 1][y]++; } if (ss == 2) { if (y - 1 >= 0) dp[x][y - 1]++; if (y + 1 <= 9) dp[x][y + 1]++; if (x - 1 >= 0) dp[x - 1][y]++; if (x + 1 <= 9) dp[x + 1][y]++; if (x - 1 >= 0 && y - 1 >= 0) dp[x - 1][y - 1]++; if (x + 1 <= 9 && y - 1 >= 0) dp[x + 1][y - 1]++; if (x - 1 >= 0 && y + 1 <= 9) dp[x - 1][y + 1]++; if (x + 1 <= 9 && y + 1 <= 9) dp[x + 1][y + 1]++; } if (ss == 3) { if (y - 1 >= 0) dp[x][y - 1]++; if (y + 1 <= 9) dp[x][y + 1]++; if (x - 1 >= 0) dp[x - 1][y]++; if (x + 1 <= 9) dp[x + 1][y]++; if (x - 1 >= 0 && y - 1 >= 0) dp[x - 1][y - 1]++; if (x + 1 <= 9 && y - 1 >= 0) dp[x + 1][y - 1]++; if (x - 1 >= 0 && y + 1 <= 9) dp[x - 1][y + 1]++; if (x + 1 <= 9 && y + 1 <= 9) dp[x + 1][y + 1]++; if (x + 2 <= 9) dp[x + 2][y]++; if (x - 2 >= 0) dp[x - 2][y]++; if (y + 2 <= 9) dp[x][y + 2]++; if (y - 2 >= 0) dp[x][y - 2]++; } } int ans = 0, max = 0; for (int a = 0; a < 10; a++) { for (int b = 0; b < 10; b++) { if (dp[a][b] == 0) ans++; if (dp[a][b] >= max) max = dp[a][b]; } } cout << ans << endl; cout << max << endl; }
#include <algorithm> #include <cctype> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; int size(string x) { string::size_type size = x.size(); return size; } #define fu(l, k) for (int i = l; i < k; i++) #define fd(l, k) for (int i = l; i > k; i--) #define fi first #define se second typedef vector<string> vs; typedef vector<int> vi; double pi() { return M_PI; } typedef set<int> set_i; typedef set<string> set_s; int INF = 1000000; int main() { int dp[11][11] = {}; int x, y, ss; char s; while (cin >> x >> s >> y >> s >> ss) { dp[x][y]++; if (ss == 1) { if (y - 1 >= 0) dp[x][y - 1]++; if (y + 1 <= 9) dp[x][y + 1]++; if (x - 1 >= 0) dp[x - 1][y]++; if (x + 1 <= 9) dp[x + 1][y]++; } if (ss == 2) { if (y - 1 >= 0) dp[x][y - 1]++; if (y + 1 <= 9) dp[x][y + 1]++; if (x - 1 >= 0) dp[x - 1][y]++; if (x + 1 <= 9) dp[x + 1][y]++; if (x - 1 >= 0 && y - 1 >= 0) dp[x - 1][y - 1]++; if (x + 1 <= 9 && y - 1 >= 0) dp[x + 1][y - 1]++; if (x - 1 >= 0 && y + 1 <= 9) dp[x - 1][y + 1]++; if (x + 1 <= 9 && y + 1 <= 9) dp[x + 1][y + 1]++; } if (ss == 3) { if (y - 1 >= 0) dp[x][y - 1]++; if (y + 1 <= 9) dp[x][y + 1]++; if (x - 1 >= 0) dp[x - 1][y]++; if (x + 1 <= 9) dp[x + 1][y]++; if (x - 1 >= 0 && y - 1 >= 0) dp[x - 1][y - 1]++; if (x + 1 <= 9 && y - 1 >= 0) dp[x + 1][y - 1]++; if (x - 1 >= 0 && y + 1 <= 9) dp[x - 1][y + 1]++; if (x + 1 <= 9 && y + 1 <= 9) dp[x + 1][y + 1]++; if (x + 2 <= 9) dp[x + 2][y]++; if (x - 2 >= 0) dp[x - 2][y]++; if (y + 2 <= 9) dp[x][y + 2]++; if (y - 2 >= 0) dp[x][y - 2]++; } } int ans = 0, max = 0; for (int a = 0; a < 10; a++) { for (int b = 0; b < 10; b++) { if (dp[a][b] == 0) ans++; if (dp[a][b] >= max) max = dp[a][b]; } } cout << ans << endl; cout << max << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
797
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> #define ll long long int #define ld long double #define INF 1000000000 #define EPS 0.0000000001 #define rep(i, n) for (i = 0; i < n; i++) using namespace std; typedef pair<int, int> P; string str; int main() { int x, y, size; int paper[15][15] = {}; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { x += 2; y += 2; paper[y][x]++; paper[y + 1][x]++; paper[y - 1][x]++; paper[y][x - 1]++; paper[y][x + 1]++; if (size > 1) { paper[y - 1][x - 1]++; paper[y - 1][x + 1]++; paper[y + 1][x - 1]++; paper[y + 1][x + 1]++; if (size == 2) { paper[y][x - 2]++; paper[y][x + 2]++; paper[y - 2][x]++; paper[y + 2][x]++; } } } int white = 0; int m = 0; int i, j; for (i = 2; i < 12; i++) for (j = 2; j < 12; j++) { if (paper[i][j] == 0) white++; m = max(m, paper[i][j]); } cout << white << endl; cout << m << endl; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> #define ll long long int #define ld long double #define INF 1000000000 #define EPS 0.0000000001 #define rep(i, n) for (i = 0; i < n; i++) using namespace std; typedef pair<int, int> P; string str; int main() { int x, y, size; int paper[15][15] = {}; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { x += 2; y += 2; paper[y][x]++; paper[y + 1][x]++; paper[y - 1][x]++; paper[y][x - 1]++; paper[y][x + 1]++; if (size > 1) { paper[y - 1][x - 1]++; paper[y - 1][x + 1]++; paper[y + 1][x - 1]++; paper[y + 1][x + 1]++; if (size == 3) { paper[y][x - 2]++; paper[y][x + 2]++; paper[y - 2][x]++; paper[y + 2][x]++; } } } int white = 0; int m = 0; int i, j; for (i = 2; i < 12; i++) for (j = 2; j < 12; j++) { if (paper[i][j] == 0) white++; m = max(m, paper[i][j]); } cout << white << endl; cout << m << endl; }
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
359
2
#include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; int main() { int i, j, k, l, m, n, o, x, y, z; int max = 0; int count = 0; vector<vector<int>> s; s.resize(10); for (i = 0; i < 14; i++) { s[i].resize(14); } for (j = 0; j < 14; j++) { for (k = 0; k < 14; k++) { s[j][k] = 0; } } while (scanf("%d,%d,%d", &x, &y, &z) != EOF) { if (z == 1) { s[x + 2][y + 2] += 1; s[x + 1][y + 2] += 1; s[x + 3][y + 2] += 1; s[x + 2][y + 1] += 1; s[x + 2][y + 3] += 1; } else if (z == 2) { for (l = x + 1; l <= x + 3; l++) { for (m = y + 1; m <= y + 3; m++) { s[l][m] += 1; } } } else if (z == 3) { for (l = x + 1; l <= x + 3; l++) { for (m = y + 1; m <= y + 3; m++) { s[l][m] += 1; s[x][y + 2] += 1; s[x + 4][y + 2] += 1; s[x + 2][y] += 1; s[x + 2][y + 4] += 1; } } } } for (n = 2; n < 12; n++) { for (o = 2; o < 12; o++) { if (max < s[n][o]) { max = s[n][o]; } if (s[n][o] == 0) { count += 1; } } } cout << count << endl; cout << max << endl; return 0; }
#include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; int main() { int i, j, k, l, m, n, o, x, y, z; int max = 0; int count = 0; vector<vector<int>> s; s.resize(14); for (i = 0; i < 14; i++) { s[i].resize(14); } for (j = 0; j < 14; j++) { for (k = 0; k < 14; k++) { s[j][k] = 0; } } while (scanf("%d,%d,%d", &x, &y, &z) != EOF) { if (z == 1) { s[x + 2][y + 2] += 1; s[x + 1][y + 2] += 1; s[x + 3][y + 2] += 1; s[x + 2][y + 1] += 1; s[x + 2][y + 3] += 1; } else if (z == 2) { for (l = x + 1; l <= x + 3; l++) { for (m = y + 1; m <= y + 3; m++) { s[l][m] += 1; } } } else if (z == 3) { for (l = x + 1; l <= x + 3; l++) { for (m = y + 1; m <= y + 3; m++) { s[l][m] += 1; } } s[x][y + 2] += 1; s[x + 4][y + 2] += 1; s[x + 2][y] += 1; s[x + 2][y + 4] += 1; } } for (n = 2; n < 12; n++) { for (o = 2; o < 12; o++) { if (max < s[n][o]) { max = s[n][o]; } if (s[n][o] == 0) { count += 1; } } } cout << count << endl; cout << max << endl; return 0; }
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46], ["+", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]]
1
483
6
#include <bits/stdc++.h> using namespace std; int main() { int a[15][15] = {0}, b = 0, c = 0, x, y, t; string s[50]; while (scanf("%d,%d,%d", &x, &y, &t) != EOF) { if (t == 3) { a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x][y + 2]++; a[x + 3][y + 2]++; a[x + 4][y + 2]++; a[x + 2][y + 1]++; a[x + 2][y]++; a[x + 2][y + 3]++; a[x + 2][y + 4]++; a[x + 3][y + 3]++; a[x + 3][y + 1]++; a[x + 1][y + 3]++; a[x + 1][y + 1]++; } if (t == 2) { a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x + 3][y + 2]++; a[x + 2][y + 1]++; a[x + 2][y + 3]++; a[x + 3][y + 3]++; a[x + 3][y + 1]++; a[x + 1][y + 3]++; a[x + 1][y + 1]++; } else { a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x + 3][y + 2]++; a[x + 2][y + 1]++; a[x + 2][y + 3]++; } } for (int i = 2; i < 13; i++) { for (int j = 2; j < 13; j++) { if (!a[i][j]) c++; b = max(b, a[i][j]); } } cout << b << endl << c << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a[15][15] = {0}, b = 0, c = 0, x, y, t; string s[50]; while (scanf("%d,%d,%d", &x, &y, &t) != EOF) { if (t == 3) { a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x][y + 2]++; a[x + 3][y + 2]++; a[x + 4][y + 2]++; a[x + 2][y + 1]++; a[x + 2][y]++; a[x + 2][y + 3]++; a[x + 2][y + 4]++; a[x + 3][y + 3]++; a[x + 3][y + 1]++; a[x + 1][y + 3]++; a[x + 1][y + 1]++; } else if (t == 2) { a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x + 3][y + 2]++; a[x + 2][y + 1]++; a[x + 2][y + 3]++; a[x + 3][y + 3]++; a[x + 3][y + 1]++; a[x + 1][y + 3]++; a[x + 1][y + 1]++; } else { a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x + 3][y + 2]++; a[x + 2][y + 1]++; a[x + 2][y + 3]++; } } for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (!a[i][j]) c++; b = max(b, a[i][j]); } } cout << c << endl << b << endl; }
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 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], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
504
9
#include <iostream> #include <map> #include <vector> class DrawAreaStrategy { public: DrawAreaStrategy() {} virtual ~DrawAreaStrategy() {} DrawAreaStrategy(const DrawAreaStrategy &) = delete; DrawAreaStrategy &operator=(const DrawAreaStrategy &) = delete; DrawAreaStrategy(DrawAreaStrategy &&) = delete; DrawAreaStrategy &operator=(DrawAreaStrategy &&) = delete; virtual void Draw(std::vector<std::vector<int>> &draw_sheet, int x, int y) = 0; }; class DrawAreaSmallStrategy { public: DrawAreaSmallStrategy() {} virtual ~DrawAreaSmallStrategy() {} DrawAreaSmallStrategy(const DrawAreaSmallStrategy &) = delete; DrawAreaSmallStrategy &operator=(const DrawAreaSmallStrategy &) = delete; DrawAreaSmallStrategy(DrawAreaSmallStrategy &&) = delete; DrawAreaSmallStrategy &operator=(DrawAreaSmallStrategy &&) = delete; virtual void Draw(std::vector<std::vector<int>> &draw_sheet, int x, int y) { static const std::vector<std::pair<int, int>> draw_list{{0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}}; for (auto draw_point : draw_list) { int draw_x = draw_point.first + x; if (draw_x < 0 || draw_x >= 10) { continue; } int draw_y = draw_point.first + y; if (draw_y < 0 || draw_y >= 10) { continue; } draw_sheet[x + draw_point.first][y + draw_point.second]++; } } }; class DrawAreaMiddleStrategy { public: DrawAreaMiddleStrategy() {} virtual ~DrawAreaMiddleStrategy() {} DrawAreaMiddleStrategy(const DrawAreaMiddleStrategy &) = delete; DrawAreaMiddleStrategy &operator=(const DrawAreaMiddleStrategy &) = delete; DrawAreaMiddleStrategy(DrawAreaMiddleStrategy &&) = delete; DrawAreaMiddleStrategy &operator=(DrawAreaMiddleStrategy &&) = delete; virtual void Draw(std::vector<std::vector<int>> &draw_sheet, int x, int y) { static const std::vector<std::pair<int, int>> draw_list{ {0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}}; for (auto draw_point : draw_list) { int draw_x = draw_point.first + x; if (draw_x < 0 || draw_x >= 10) { continue; } int draw_y = draw_point.first + y; if (draw_y < 0 || draw_y >= 10) { continue; } draw_sheet[x + draw_point.first][y + draw_point.second]++; } } }; class DrawAreaLargeStrategy { public: DrawAreaLargeStrategy() {} virtual ~DrawAreaLargeStrategy() {} DrawAreaLargeStrategy(const DrawAreaLargeStrategy &) = delete; DrawAreaLargeStrategy &operator=(const DrawAreaLargeStrategy &) = delete; DrawAreaLargeStrategy(DrawAreaLargeStrategy &&) = delete; DrawAreaLargeStrategy &operator=(DrawAreaLargeStrategy &&) = delete; virtual void Draw(std::vector<std::vector<int>> &draw_sheet, int x, int y) { static const std::vector<std::pair<int, int>> draw_list{ {0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}, {-2, 0}, {2, 0}, {0, -2}, {0, 2}}; for (auto draw_point : draw_list) { int draw_x = draw_point.first + x; if (draw_x < 0 || draw_x >= 10) { continue; } int draw_y = draw_point.first + y; if (draw_y < 0 || draw_y >= 10) { continue; } draw_sheet[x + draw_point.first][y + draw_point.second]++; } } }; int main() { DrawAreaSmallStrategy small; DrawAreaMiddleStrategy middle; DrawAreaLargeStrategy large; std::vector<std::vector<int>> sheet(10, std::vector<int>(10)); int x = 0, y = 0, s = 0; char a = 0; while (std::cin >> x >> a >> y >> a >> s) { switch (s) { case 1: { small.Draw(sheet, x, y); break; } case 2: { middle.Draw(sheet, x, y); break; } case 3: { large.Draw(sheet, x, y); break; } default: break; } } int empty_num = 0; int max_num = 0; for (auto line : sheet) { for (auto cell : line) { if (0 == cell) { empty_num++; continue; } if (max_num < cell) { max_num = cell; } } } std::cout << empty_num << "\n" << max_num << std::endl; return 0; }
#include <iostream> #include <map> #include <vector> class DrawAreaStrategy { public: DrawAreaStrategy() {} virtual ~DrawAreaStrategy() {} DrawAreaStrategy(const DrawAreaStrategy &) = delete; DrawAreaStrategy &operator=(const DrawAreaStrategy &) = delete; DrawAreaStrategy(DrawAreaStrategy &&) = delete; DrawAreaStrategy &operator=(DrawAreaStrategy &&) = delete; virtual void Draw(std::vector<std::vector<int>> &draw_sheet, int x, int y) = 0; }; class DrawAreaSmallStrategy { public: DrawAreaSmallStrategy() {} virtual ~DrawAreaSmallStrategy() {} DrawAreaSmallStrategy(const DrawAreaSmallStrategy &) = delete; DrawAreaSmallStrategy &operator=(const DrawAreaSmallStrategy &) = delete; DrawAreaSmallStrategy(DrawAreaSmallStrategy &&) = delete; DrawAreaSmallStrategy &operator=(DrawAreaSmallStrategy &&) = delete; virtual void Draw(std::vector<std::vector<int>> &draw_sheet, int x, int y) { static const std::vector<std::pair<int, int>> draw_list{{0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}}; for (auto draw_point : draw_list) { int draw_x = draw_point.first + x; if (draw_x < 0 || draw_x >= 10) { continue; } int draw_y = draw_point.second + y; if (draw_y < 0 || draw_y >= 10) { continue; } draw_sheet[x + draw_point.first][y + draw_point.second]++; } } }; class DrawAreaMiddleStrategy { public: DrawAreaMiddleStrategy() {} virtual ~DrawAreaMiddleStrategy() {} DrawAreaMiddleStrategy(const DrawAreaMiddleStrategy &) = delete; DrawAreaMiddleStrategy &operator=(const DrawAreaMiddleStrategy &) = delete; DrawAreaMiddleStrategy(DrawAreaMiddleStrategy &&) = delete; DrawAreaMiddleStrategy &operator=(DrawAreaMiddleStrategy &&) = delete; virtual void Draw(std::vector<std::vector<int>> &draw_sheet, int x, int y) { static const std::vector<std::pair<int, int>> draw_list{ {0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}}; for (auto draw_point : draw_list) { int draw_x = draw_point.first + x; if (draw_x < 0 || draw_x >= 10) { continue; } int draw_y = draw_point.second + y; if (draw_y < 0 || draw_y >= 10) { continue; } draw_sheet[x + draw_point.first][y + draw_point.second]++; } } }; class DrawAreaLargeStrategy { public: DrawAreaLargeStrategy() {} virtual ~DrawAreaLargeStrategy() {} DrawAreaLargeStrategy(const DrawAreaLargeStrategy &) = delete; DrawAreaLargeStrategy &operator=(const DrawAreaLargeStrategy &) = delete; DrawAreaLargeStrategy(DrawAreaLargeStrategy &&) = delete; DrawAreaLargeStrategy &operator=(DrawAreaLargeStrategy &&) = delete; virtual void Draw(std::vector<std::vector<int>> &draw_sheet, int x, int y) { static const std::vector<std::pair<int, int>> draw_list{ {0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}, {-2, 0}, {2, 0}, {0, -2}, {0, 2}}; for (auto draw_point : draw_list) { int draw_x = draw_point.first + x; if (draw_x < 0 || draw_x >= 10) { continue; } int draw_y = draw_point.second + y; if (draw_y < 0 || draw_y >= 10) { continue; } draw_sheet[x + draw_point.first][y + draw_point.second]++; } } }; int main() { DrawAreaSmallStrategy small; DrawAreaMiddleStrategy middle; DrawAreaLargeStrategy large; std::vector<std::vector<int>> sheet(10, std::vector<int>(10)); int x = 0, y = 0, s = 0; char a = 0; while (std::cin >> x >> a >> y >> a >> s) { switch (s) { case 1: { small.Draw(sheet, x, y); break; } case 2: { middle.Draw(sheet, x, y); break; } case 3: { large.Draw(sheet, x, y); break; } default: break; } } int empty_num = 0; int max_num = 0; for (auto line : sheet) { for (auto cell : line) { if (0 == cell) { empty_num++; continue; } if (max_num < cell) { max_num = cell; } } } std::cout << empty_num << "\n" << max_num << std::endl; return 0; }
[["-", 0, 43, 49, 50, 51, 16, 31, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 16, 31, 118, 119, 120]]
1
992
6
#include "bits/stdc++.h" using namespace std; int main() { int x, y, s; char b; int n = 10; int x1[] = {1, 0, -1, 0}; int y1[] = {0, 1, 0, -1}; int x2[] = {1, 1, -1, -1}; int y2[] = {1, -1, 1, -1}; int x3[] = {2, 0, -2, 0}; int y3[] = {0, 2, 0, -2}; vector<vector<int>> a(n, vector<int>(n, 0)); while (cin >> x >> b >> y >> b >> s) { // if(x==-1)break; a[x][y]++; for (int i = 0; i < 4; i++) { if (x + x1[i] > -1 && y + y1[i] > -1 && x + x1[i] < 10 && y + y1[i] < 10) { a[x + x1[i]][y + y1[i]]++; } } if (s > 1) { for (int i = 0; i < 4; i++) { if (x + x2[i] > -1 && y + y2[i] > -1 && x + x2[i] < 10 && y + y2[i] < 10) { a[x + x2[i]][y + y2[i]]++; } } } if (s > 2) { for (int i = 0; i < 4; i++) { if (x + x3[i] > -1 && y + y3[i] > -1 && x + x3[i] < 10 && y + y3[i] < 10) { a[x + x3[i]][y + y3[i]]++; } } } } int ans = 0; int ans2 = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (a[i][j] == 0) ans++; ans2 = max(ans2, a[i][j]); } } cout << ans << " " << ans2 << endl; return 0; }
#include "bits/stdc++.h" using namespace std; int main() { int x, y, s; char b; int n = 10; int x1[] = {1, 0, -1, 0}; int y1[] = {0, 1, 0, -1}; int x2[] = {1, 1, -1, -1}; int y2[] = {1, -1, 1, -1}; int x3[] = {2, 0, -2, 0}; int y3[] = {0, 2, 0, -2}; vector<vector<int>> a(n, vector<int>(n, 0)); while (cin >> x >> b >> y >> b >> s) { // if(x==-1)break; a[x][y]++; for (int i = 0; i < 4; i++) { if (x + x1[i] > -1 && y + y1[i] > -1 && x + x1[i] < 10 && y + y1[i] < 10) { a[x + x1[i]][y + y1[i]]++; } } if (s > 1) { for (int i = 0; i < 4; i++) { if (x + x2[i] > -1 && y + y2[i] > -1 && x + x2[i] < 10 && y + y2[i] < 10) { a[x + x2[i]][y + y2[i]]++; } } } if (s > 2) { for (int i = 0; i < 4; i++) { if (x + x3[i] > -1 && y + y3[i] > -1 && x + x3[i] < 10 && y + y3[i] < 10) { a[x + x3[i]][y + y3[i]]++; } } } } int ans = 0; int ans2 = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (a[i][j] == 0) ans++; ans2 = max(ans2, a[i][j]); } } cout << ans << endl << ans2 << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
495
4
#include <cstdio> #include <iostream> using namespace std; int main() { int masu[13][13], x, y, s; while (scanf("%d,%d,%d", &x, &y, &s) != EOF) { x += 2, y += 2; if (s == 1) { for (int i = x - 1; i <= x + 1; i++) masu[i][y]++; masu[x][y - 1]++; masu[x][y + 1]++; } else if (s == 2) { for (int i = x - 1; i <= x + 1; i++) { for (int j = y - 1; j <= y + 1; j++) { masu[i][j]++; } } } else { for (int i = x - 1; i <= x + 1; i++) { for (int j = y - 1; j <= y + 1; j++) { masu[i][j]++; } } masu[x - 2][y]++, masu[x + 2][y]++; masu[x][y - 2]++, masu[x][y + 2]++; } } int siro = 0, koi = 0; for (int i = 2; i <= 11; i++) { for (int j = 2; j <= 11; j++) { if (masu[i][j] == 0) siro++; if (koi < masu[i][j]) koi = masu[i][j]; } } cout << siro << endl << koi << endl; return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int masu[13][13] = {0}, x, y, s; while (scanf("%d,%d,%d", &x, &y, &s) != EOF) { x += 2, y += 2; if (s == 1) { for (int i = x - 1; i <= x + 1; i++) masu[i][y]++; masu[x][y - 1]++; masu[x][y + 1]++; } else if (s == 2) { for (int i = x - 1; i <= x + 1; i++) { for (int j = y - 1; j <= y + 1; j++) { masu[i][j]++; } } } else { for (int i = x - 1; i <= x + 1; i++) { for (int j = y - 1; j <= y + 1; j++) { masu[i][j]++; } } masu[x - 2][y]++, masu[x + 2][y]++; masu[x][y - 2]++, masu[x][y + 2]++; } } int siro = 0, koi = 0; for (int i = 2; i <= 11; i++) { for (int j = 2; j <= 11; j++) { if (masu[i][j] == 0) siro++; if (koi < masu[i][j]) koi = masu[i][j]; } } cout << siro << endl << koi << endl; return 0; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
1
361
4
arg = [] while (get = gets) arg << get end max = 0 suspection = [] temp = 0 count = 0 arg.sort.each{|i| if temp == i count += 1 if max < count suspection = [i] max = count elsif max == count suspection << i end else temp = i count = 1 end} puts suspection
arg = [] while (get = gets) arg << get.to_i end max = 0 suspection = [] temp = 0 count = 0 arg.sort.each{|i| if temp == i count += 1 if max < count suspection = [i] max = count elsif max == count suspection << i end else temp = i count = 1 end} puts suspection
[["+", 0, 89, 8, 170, 0, 738, 12, 652, 17, 131], ["+", 0, 89, 8, 170, 0, 738, 12, 652, 735, 22]]
4
74
2
count = Hash.new(0) $<.each{|x| count[x] += 1} max = count.values.max puts count.select{|x, c| c == max}.map(&:first).sort
count = Hash.new(0) $<.each{|x| count[x.to_i] += 1} max = count.values.max puts count.select{|x, c| c == max}.map(&:first).sort
[["+", 8, 734, 0, 755, 31, 742, 0, 652, 17, 131], ["+", 8, 734, 0, 755, 31, 742, 0, 652, 735, 22]]
4
51
2
data = Array.new() i = 0 while data[i] = gets do i += 1 end j = 0 number = Array.new() while out = data[j] out = out.chomp number[j] = out.to_i j += 1 end ten = Array.new(100,0) number = number.sort score = number.uniq i=0 j=0 k=0 for i in score do for j in number do if i == j ten[k] = ten[k] + 1 end end k += 1; end max = ten.max i = 0 k = 0 for i in ten do if i == max p score[k + 1] end k += 1 end
data = Array.new() i = 0 while data[i] = gets do i += 1 end j = 0 number = Array.new() while out = data[j] out = out.chomp number[j] = out.to_i j += 1 end ten = Array.new(100,0) number = number.sort score = number.uniq i=0 j=0 k=0 for i in score do for j in number do if i == j ten[k] = ten[k] + 1 end end k += 1; end max = ten.max i = 0 k = 0 for i in ten do if i == max p score[k] end k += 1 end
[["-", 0, 652, 3, 4, 0, 742, 0, 738, 17, 72], ["-", 0, 652, 3, 4, 0, 742, 0, 738, 12, 612]]
4
149
2
arr = Array.new(100){0} while gets do arr[i-1]+=1 end max = arr.max arr.each_with_index {|v, n| puts(n+1) if v == max}
arr = Array.new(100){0} while gets do arr[$_.to_i-1]+=1 end max = arr.max arr.each_with_index {|v, n| puts(n+1) if v == max}
[["-", 8, 170, 0, 755, 31, 742, 0, 738, 31, 22], ["+", 0, 755, 31, 742, 0, 738, 31, 652, 486, 744], ["+", 0, 755, 31, 742, 0, 738, 31, 652, 17, 131], ["+", 0, 755, 31, 742, 0, 738, 31, 652, 735, 22]]
4
48
4
h={};$<.map{|s|h[n==s.to_i]||=0;h[n]+=1};puts h.select{|x,y|y==h.values.max}.keys.sort
h={};$<.map{|s|h[n=s.to_i]||=0;h[n]+=1};puts h.select{|x,y|y==h.values.max}.keys.sort
[["-", 8, 734, 0, 755, 31, 742, 0, 738, 17, 60], ["+", 8, 734, 0, 755, 31, 742, 0, 662, 0, 32]]
4
53
2
a=Array.new(10,0) $<.map{|n|a[n.to_i]+=1} a.map.with_index{|n,i|n==a.max&&p(i)}
a=Array.new(101,0) $<.map{|n|a[n.to_i]+=1} a.map.with_index{|n,i|n==a.max&&p(i)}
[["-", 0, 493, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 493, 0, 662, 12, 652, 3, 4, 0, 612]]
4
48
2
count = (0..9).map{ 0 } while (line = gets) n = line.chop.to_i count[n] += 1 end max = count.max puts (0..9).select{|k| count[k] == max}
count = (0..100).map{ 0 } while (line = gets) n = line.chop.to_i count[n] += 1 end max = count.max puts (0..100).select{|k| count[k] == max}
[["-", 0, 662, 12, 652, 486, 739, 0, 475, 444, 612], ["+", 0, 662, 12, 652, 486, 739, 0, 475, 444, 612], ["-", 3, 4, 0, 652, 486, 739, 0, 475, 444, 612], ["+", 3, 4, 0, 652, 486, 739, 0, 475, 444, 612]]
4
56
4
hist = [0 for i in range(100)] l = [] while True: try: hist[eval(input()) - 1] += 1 except: break; for k in [x for x in enumlate(hist) if max(hist) == x[1]]: print(k[0] + 1)
hist = [0 for i in range(100)] l = [] while True: try: hist[eval(input()) - 1] += 1 except: break; for k in [x for x in enumerate(hist) if max(hist) == x[1]]: print(k[0] + 1)
[["-", 0, 7, 12, 658, 0, 659, 12, 652, 63, 22], ["+", 0, 7, 12, 658, 0, 659, 12, 652, 63, 22]]
5
71
2
A=[] while True: try: x=int(input()) A.append(x) except EOFError: break num=[] for i in range(10): num.append((A.count(i),i)) num.sort(reverse=True) mode_value=num[0][0] B=[] for i in num: if i[0]==mode_value: B.append(i[1]) B.sort() for i in B: print(i)
A=[] while True: try: x=int(input()) A.append(x) except EOFError: break num=[] for i in range(101): num.append((A.count(i),i)) num.sort(reverse=True) mode_value=num[0][0] B=[] for i in num: if i[0]==mode_value: B.append(i[1]) B.sort() for i in B: print(i)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
111
2
import collections import sys cntr = collections.Counter for line in sys.stdin: cntr[int(line)] += 1 lst = [] for k,v in cntr.items(): lst.append((v,k)) lst.sort() t = len(lst)-1 while t>0 and lst[t][0] == lst[t-1][0]: t -= 1 for i in range(t,len(lst)): print(lst[i][1])
import collections import sys cntr = collections.Counter() for line in sys.stdin: cntr[int(line)] += 1 lst = [] for k,v in cntr.items(): lst.append((v,k)) lst.sort() t = len(lst)-1 while t>0 and lst[t][0] == lst[t-1][0]: t -= 1 for i in range(t,len(lst)): print(lst[i][1])
[["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
112
2
numdict = dict() while True: try: num = input() if num not in numdict: numdict[num] = 0 else: numdict[num] += 1 except EOFError: break most = max(numdict.values()) mostlist = list() for key in numdict: if most == numdict[key]: mostlist.append(key) mostlist.sort() for item in mostlist: print(item)
numdict = dict() while True: try: num = input() if num not in numdict: numdict[num] = 0 else: numdict[num] += 1 except EOFError: break most = max(numdict.values()) mostlist = list() for key in numdict: if most == numdict[key]: mostlist.append(int(key)) mostlist.sort() for item in mostlist: print(item)
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
87
3
kosu = [0] * 100 k = 1 while True: try: n = int(input()) kosu[n - 1] += 1 except (EOFError,ValueError): ma = max(kosu) num = kosu.index(ma) + k print(num) kosu.remove(max(kosu)) while True: if ma > max(kosu): break k += 1 num = kosu.index(ma) + k kosu.remove(max(kosu)) print(num)
kosu = [0] * 100 k = 1 while True: try: n = int(input()) kosu[n - 1] += 1 except (EOFError,ValueError): ma = max(kosu) num = kosu.index(ma) + k print(num) kosu.remove(max(kosu)) while True: if ma > max(kosu): break k += 1 num = kosu.index(ma) + k kosu.remove(max(kosu)) print(num) break
[["+", 0, 246, 0, 671, 0, 196, 0, 93, 0, 94]]
5
105
1
import sys from collections import Counter if __name__ == '__main__': # ??????????????\??? # data = [5, 6, 3, 5, 8, 7, 5, 3, 9, 7, 3, 4] data = [] for line in sys.stdin: data.append(int(line.strip())) print(data) # ?????????????¢???? c = Counter(data) max_freq = c.most_common(1)[0][1] # ???????????????????????°????¨???¶ modes = [] for val, freq in c.most_common(): if freq != max_freq: break modes.append(val) # ???????????¨??? modes.sort() for i in modes: print(i)
import sys from collections import Counter if __name__ == '__main__': # ??????????????\??? # data = [5, 6, 3, 5, 8, 7, 5, 3, 9, 7, 3, 4] data = [] for line in sys.stdin: data.append(int(line.strip())) # print(data) # ?????????????¢???? c = Counter(data) max_freq = c.most_common(1)[0][1] # ???????????????????????°????¨???¶ modes = [] for val, freq in c.most_common(): if freq != max_freq: break modes.append(val) # ???????????¨??? modes.sort() for i in modes: print(i)
[["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
107
4
import sys c=[0 for i in range(101)] for n in sys.stdin: n=int(n) counter[n]+=1 m=max(c) for i in range(101): if c[i]==m: print(i)
import sys c=[0 for i in range(101)] for n in sys.stdin: n=int(n) c[n]+=1 m=max(c) for i in range(101): if c[i]==m: print(i)
[["-", 8, 196, 0, 1, 0, 677, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 51, 22]]
5
59
11
import sys from collections import defaultdict d = defaultdict(int) for i in sys.stdin: d[i] +=1 m = max(v for v in d.values()) for _ in sorted([k for k, v in d.items() if v == m]): print(_)
import sys from collections import defaultdict d = defaultdict(int) for i in sys.stdin: d[int(i)] +=1 m = max(v for v in d.values()) for i in sorted([k for k, v in d.items() if v == m]): print(i)
[["+", 0, 1, 0, 677, 31, 206, 206, 652, 63, 22], ["+", 0, 677, 31, 206, 206, 652, 3, 4, 0, 24], ["+", 0, 677, 31, 206, 206, 652, 3, 4, 0, 25], ["-", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
67
7
import sys a = {} ma = 0 m = [] for u in sys.stdin: i = int(u) if not (i in a): a[i] = 1 else: a[i] += 1 if ma <= a[i]: if ma < i: ma = a[i] m.clear() m.append(i) m = sorted(m) for k in m: print(k)
import sys a = {} ma = 0 m = [] for u in sys.stdin: i = int(u) if not (i in a): a[i] = 1 else: a[i] += 1 # ???????????§????????±??? if ma <= a[i]: if ma < a[i]: ma = a[i] m.clear() m.append(i) m = sorted(m) for k in m: print(k)
[["+", 64, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 0, 70], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 0, 73]]
5
93
3
import sys def ModeValue(): mode=[0 for i in range(0,101)] for n in sys.stdin: mode[int(n)]+=1 maxN=max(mode) for i in mode: if mode[i]==maxN: print(i) ModeValue()
import sys def ModeValue(): mode=[0 for i in range(0,101)] for n in sys.stdin: mode[int(n)]+=1 maxN=max(mode) for i in range(0,101): if mode[i]==maxN: print(i) ModeValue()
[["-", 0, 656, 0, 14, 8, 196, 0, 7, 12, 22], ["+", 0, 14, 8, 196, 0, 7, 12, 652, 63, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 25]]
5
63
7
# 0028 array = [] while True: try: a = input() array.append(int(a)) except EOFError: break s = set(array) mx = max(list(map(lambda a: array.count(a), s))) modes = list(filter(lambda a: array.count(a) == mx), sorted(s)) print(*modes, sep = '\n')
# 0028 array = [] while True: try: a = input() array.append(int(a)) except EOFError: break s = set(array) mx = max(list(map(lambda a: array.count(a), s))) modes = list(filter(lambda a: array.count(a) == mx, sorted(s))) print(*modes, sep = '\n')
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
91
2
# 0028 array = [] while True: try: a = input() array.append(int(a)) except EOFError: break s = set(array) count= list(map(lambda a: array.count(a), s)) mx = max(count) modes = list(array[i] for i, x in enumerate(count) if x == mx) print(*sorted(modes), sep = '\n')
# 0028 array = [] while True: try: a = input() array.append(int(a)) except EOFError: break s = set(array) count= list(map(lambda a: array.count(a), s)) mx = max(count) modes = list(list(s)[i] for i, x in enumerate(count) if x == mx) print(*sorted(modes), sep = '\n')
[["-", 0, 662, 12, 652, 3, 668, 8, 206, 51, 22], ["+", 12, 652, 3, 668, 8, 206, 51, 652, 63, 22], ["+", 3, 668, 8, 206, 51, 652, 3, 4, 0, 24], ["+", 3, 668, 8, 206, 51, 652, 3, 4, 0, 22], ["+", 3, 668, 8, 206, 51, 652, 3, 4, 0, 25]]
5
95
8
a = [], m = l = 0, c = ''; require("fs") .readFileSync("/dev/stdin", "utf8") .trim() .split(' ') .some(function(i) { a[j = i.toLowerCase()] ? (++a[j] > m ? m = a[j] : 0) : a[j] = 1; (t = j.length) > l ? (c = j, l = t) : 0 }); console.log(m + ' ' + c)
a = [], m = l = 0, n = c = ''; require("fs") .readFileSync("/dev/stdin", "utf8") .trim() .split(' ') .some(function(i) { a[j = i.toLowerCase()] ? (++a[j] > m ? m = a[n = j] : 0) : a[j] = 1; (t = j.length) > l ? (c = j, l = t) : 0 }); console.log(n + ' ' + c)
[["+", 0, 1, 0, 563, 12, 563, 12, 11, 31, 22], ["+", 0, 1, 0, 563, 12, 563, 12, 11, 0, 32], ["+", 0, 510, 64, 11, 12, 69, 71, 11, 31, 22], ["+", 0, 510, 64, 11, 12, 69, 71, 11, 0, 32], ["-", 0, 2, 3, 3, 0, 16, 31, 16, 31, 22], ["+", 0, 2, 3, 3, 0, 16, 31, 16, 31, 22]]
2
125
6
import java.io.*; class Main { public static void main(String args[]) throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String str = input.readLine(); String str_ary[] = str.split(" "); int a[] = new int[str_ary.length]; for (int i = 0; i < str_ary.length; i++) { for (int j = 0; j < str_ary.length; j++) { if (str_ary[i].equals(str_ary[j])) a[i]++; } } int max = 0; for (int i = 0; i < a.length; i++) { if (max < a[i]) max = i; } max = 0; int y = 0; int b[] = new int[str_ary.length]; for (int j = 0; j < str_ary.length; j++) { b[j] = str_ary[j].length(); if (max < b[j]) { max = b[j]; y = j; } } System.out.println(str_ary[max] + " " + str_ary[y]); } }
import java.io.*; class Main { public static void main(String args[]) throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String str = input.readLine(); String str_ary[] = str.split(" "); int a[] = new int[str_ary.length]; for (int i = 0; i < str_ary.length; i++) { for (int j = 0; j < str_ary.length; j++) { if (str_ary[i].equals(str_ary[j])) a[i]++; } } int max = 0; for (int i = 0; i < a.length; i++) { if (max < a[i]) max = i; } int x = 0, y = 0; int b[] = new int[str_ary.length]; for (int j = 0; j < str_ary.length; j++) { b[j] = str_ary[j].length(); if (x < b[j]) { x = b[j]; y = j; } } System.out.println(str_ary[max] + " " + str_ary[y]); } }
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 49, 200, 141, 22], ["-", 8, 498, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 8, 498, 0, 195, 8, 196, 0, 503, 0, 21], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22]]
3
266
10
#include <stdio.h> #include <string.h> int main(void) { int i = 0, j; char word_list[501][33]; while (scanf("%s", word_list[i]) != EOF) { i++; } int word_num = i; int word_cnt[501] = {0}; int len; int longest_len = 0; char longest_word[33]; for (i = 0; i < word_num; i++) { len = strlen(word_list[i]); if (len > longest_len) { longest_len = len; strcpy(longest_word, word_list[i]); } for (j = 0; j < i; j++) { if (strcmp(word_list[i], word_list[j]) == 0) { word_cnt[i]++; } } } int cnt_max = 0; char mode_word[33]; for (i = 0; i < word_num; i++) { if (word_cnt[i] > cnt_max) { cnt_max = word_cnt[i]; strcpy(mode_word, word_list[i]); } } printf("%s\n%s\n", mode_word, longest_word); return 0; }
#include <stdio.h> #include <string.h> int main(void) { int i = 0, j; char word_list[501][33]; while (scanf("%s", word_list[i]) != EOF) { i++; } int word_num = i; int word_cnt[501] = {0}; int len; int longest_len = 0; char longest_word[33]; for (i = 0; i < word_num; i++) { len = strlen(word_list[i]); if (len > longest_len) { longest_len = len; strcpy(longest_word, word_list[i]); } for (j = 0; j < i; j++) { if (strcmp(word_list[i], word_list[j]) == 0) { word_cnt[i]++; } } } int cnt_max = 0; char mode_word[33]; for (i = 0; i < word_num; i++) { if (word_cnt[i] > cnt_max) { cnt_max = word_cnt[i]; strcpy(mode_word, word_list[i]); } } printf("%s %s\n", mode_word, longest_word); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
235
4
#include <stdio.h> #include <string.h> struct s { char *word; int freq, len; }; int main() { int i = 0; int Max_f, Max_l, f, l, j; Max_f = 0; Max_l = 0; struct s w[500]; while (scanf("%s", w[i++].word) != EOF) { w[i - 1].len = strlen(w[i - 1].word); ++(w[i - 1].freq); if (Max_l < w[i - 1].len) { Max_l = w[i - 1].len; l = i - 1; } for (j = 0; j < i - 1; j++) { if (!(strcmp(w[j].word, w[i - 1].word))) ++(w[j].freq); if (Max_f < w[j].freq) { Max_f = w[j].freq; f = j; } } } printf("%s %s", w[f].word, w[l].word); return 0; }
#include <stdio.h> #include <string.h> struct s { char word[32]; int freq, len; }; int main() { int i = 0; int Max_f, Max_l, f, l, j; Max_f = 0; Max_l = 0; struct s w[500]; while (scanf("%s", w[i++].word) != EOF) { w[i - 1].len = strlen(w[i - 1].word); ++(w[i - 1].freq); if (Max_l < w[i - 1].len) { Max_l = w[i - 1].len; l = i - 1; } for (j = 0; j < i - 1; j++) { if (!(strcmp(w[j].word, w[i - 1].word))) ++(w[j].freq); if (Max_f < w[j].freq) { Max_f = w[j].freq; f = j; } } } printf("%s %s\n", w[f].word, w[l].word); return 0; }
[["-", 0, 122, 8, 123, 0, 124, 49, 84, 0, 48], ["+", 0, 122, 8, 123, 0, 124, 49, 80, 0, 70], ["+", 0, 122, 8, 123, 0, 124, 49, 80, 81, 13], ["+", 0, 122, 8, 123, 0, 124, 49, 80, 0, 73], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
242
5
#include <stdio.h> #include <string.h> int main() { int i, j, k, count[200] = {0}, max, midx, lidx; char s[1000], tmp[200][32]; fgets(s, 1000, stdin); i = 0; j = 0; k = 0; max = 0; while (s[i] != '\0') { if (s[i] == ' ') { tmp[j][k] = '\0'; j++; i++; k = 0; continue; } tmp[j][k++] = s[i++]; } tmp[j++][k - 1] = '\0'; for (i = 0; i < j; i++) { for (k = i + 1; k < j; k++) { if (!strcmp(tmp[i], tmp[k])) count[i]++; } } for (i = 0; i < j; i++) { if (count[i] > max) { max = count[i]; midx = i; } } max = 0; for (i = 0; i < j; i++) { if (strlen(tmp[i]) > max) { max = strlen(tmp[i]); lidx = i; } } printf("%s\n%s\n", tmp[midx], tmp[lidx]); return 0; }
#include <stdio.h> #include <string.h> int main() { int i, j, k, count[200] = {0}, max, midx, lidx; char s[1000], tmp[200][32]; fgets(s, 1000, stdin); i = 0; j = 0; k = 0; max = 0; while (s[i] != '\0') { if (s[i] == ' ') { tmp[j][k] = '\0'; j++; i++; k = 0; continue; } tmp[j][k++] = s[i++]; } tmp[j++][k - 1] = '\0'; for (i = 0; i < j; i++) { for (k = i + 1; k < j; k++) { if (!strcmp(tmp[i], tmp[k])) count[i]++; } } for (i = 0; i < j; i++) { if (count[i] > max) { max = count[i]; midx = i; } } max = 0; for (i = 0; i < j; i++) { if (strlen(tmp[i]) > max) { max = strlen(tmp[i]); lidx = i; } } printf("%s %s\n", tmp[midx], tmp[lidx]); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
312
4
#include <algorithm> #include <iostream> #include <map> #include <string> using namespace std; int main() { string s, t; map<string, int> p; while (cin >> s) { if (p.find(s) != p.end()) p[s]++; else p[s] = 1; if (s.size() > t.size()) t = s; } int m = 0; for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++) m = max(m, itr->second); for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++) if (itr->second == m) cout << itr->first << endl; cout << t << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <string> using namespace std; int main() { string s, t; map<string, int> p; while (cin >> s) { if (p.find(s) != p.end()) p[s]++; else p[s] = 1; if (s.size() > t.size()) t = s; } int m = 0; for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++) m = max(m, itr->second); for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++) if (itr->second == m) cout << itr->first << " " << t << endl; return 0; }
[["-", 0, 7, 8, 57, 64, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 7, 8, 57, 64, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
185
6
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) #define X real() #define Y imag() typedef complex<double> P; int main() { typedef pair<int, string> pis; vector<pis> a; vector<pis> b; map<string, int> m; string str; while (cin >> str) { a.push_back(pis((int)str.size(), str)); m[str]++; } map<string, int>::iterator it = m.begin(); while (it != m.end()) { b.push_back(pis(-it->second, it->first)); it++; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); cout << b[0].second << endl << a[a.size() - 1].second << endl; }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) #define X real() #define Y imag() typedef complex<double> P; int main() { typedef pair<int, string> pis; vector<pis> a; vector<pis> b; map<string, int> m; string str; while (cin >> str) { a.push_back(pis((int)str.size(), str)); m[str]++; } map<string, int>::iterator it = m.begin(); while (it != m.end()) { b.push_back(pis(-it->second, it->first)); it++; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); cout << b[0].second << " " << a[a.size() - 1].second << endl; }
[["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
232
4
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double real; typedef pair<int, int> duo; #define TT template <typename T> TT T sq(T x) { return x * x; } TT int ubnd(vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin(); } TT int lbnd(vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } TT void sort(T &v) { sort(v.begin(), v.end()); } TT void revs(T &v) { reverse(v.begin(), v.end()); } TT void uniq(T &v) { sort(v); v.erase(unique(v.begin(), v.end()), v.end()); } TT void show(T &v, char d = ' ', char e = '\n') { for (int i = 0; i < v.size(); ++i) cout << v[i] << ((i == v.size() - 1) ? e : d); } TT void inpt(vector<T> &v, int n) { v.reserve(n); for (int i = 0; i < n; ++i) { T x; cin >> x; v.push_back(x); } } TT T In() { T x; cin >> x; return x; } static inline void fast_io() { ios::sync_with_stdio(0); cin.tie(0); } static inline int in() { int x; scanf("%d", &x); return x; } static inline string instr() { string x; cin >> x; return x; } static inline ll pow_mod(ll a, ll k, ll m) { ll r = 1; for (; k > 0; a = a * a % m, k >>= 1) if (k & 1) r = r * a % m; return r; } static inline ll mod_inv(ll a, ll p) { return pow_mod(a, p - 2, p); } static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; static const int Mod = 1000000000; int main() { map<string, int> cnt; string word; while (cin >> word) { cnt[word]++; } int freq, length; string freq_s, length_s; length = freq = -1; for (const auto &v : cnt) { if (freq < v.second) { freq = v.second; freq_s = v.first; } if (length < v.first.size()) { length = v.first.size(); length_s = v.first; } } cout << freq_s << " " << length_s << endl; return (0); } // priority_queue queue deque first second front top push pop map set // stringstream max_element min_element insert count find
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double real; typedef pair<int, int> duo; #define TT template <typename T> TT T sq(T x) { return x * x; } TT int ubnd(vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin(); } TT int lbnd(vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } TT void sort(T &v) { sort(v.begin(), v.end()); } TT void revs(T &v) { reverse(v.begin(), v.end()); } TT void uniq(T &v) { sort(v); v.erase(unique(v.begin(), v.end()), v.end()); } TT void show(T &v, char d = ' ', char e = '\n') { for (int i = 0; i < v.size(); ++i) cout << v[i] << ((i == v.size() - 1) ? e : d); } TT void inpt(vector<T> &v, int n) { v.reserve(n); for (int i = 0; i < n; ++i) { T x; cin >> x; v.push_back(x); } } TT T In() { T x; cin >> x; return x; } static inline void fast_io() { ios::sync_with_stdio(0); cin.tie(0); } static inline int in() { int x; scanf("%d", &x); return x; } static inline string instr() { string x; cin >> x; return x; } static inline ll pow_mod(ll a, ll k, ll m) { ll r = 1; for (; k > 0; a = a * a % m, k >>= 1) if (k & 1) r = r * a % m; return r; } static inline ll mod_inv(ll a, ll p) { return pow_mod(a, p - 2, p); } static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; static const int Mod = 1000000000; int main() { map<string, int> cnt; string word; while (cin >> word) { cnt[word]++; } int freq, length; string freq_s, length_s; length = freq = -1; for (const auto &v : cnt) { if (freq < v.second) { freq = v.second; freq_s = v.first; } if (length < (int)v.first.size()) { length = v.first.size(); length_s = v.first; } } cout << freq_s << " " << length_s << endl; return (0); } // priority_queue queue deque first second front top push pop map set // stringstream max_element min_element insert count find
[["+", 0, 57, 15, 339, 51, 16, 12, 74, 0, 24], ["+", 15, 339, 51, 16, 12, 74, 39, 77, 39, 40], ["+", 0, 57, 15, 339, 51, 16, 12, 74, 0, 25]]
1
682
3
#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) using namespace std; map<string, int> aa; set<string> dic; int main() { string a; while (cin >> a) { dic.insert(a); ++aa[a]; } int m = 0; string ms; int m2 = 0; string ms2; for (auto x : dic) { if (m < x.length()) { m = x.length(); ms = x; } } for (auto x : aa) { if (m2 < x.second) { ms2 = x.first; m2 = x.second; } } cout << ms << " " << ms2 << endl; return 0; }
#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) using namespace std; map<string, int> aa; set<string> dic; int main() { string a; while (cin >> a) { dic.insert(a); ++aa[a]; } int m = 0; string ms; int m2 = 0; string ms2; for (auto x : dic) { if (m < x.length()) { m = x.length(); ms = x; } } for (auto x : aa) { if (m2 < x.second) { ms2 = x.first; m2 = x.second; } } cout << ms2 << " " << ms << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
178
4
#include <cstring> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; #define rep2(x, from, to) for (int x = (from); x < (to); (x)++) #define rep(x, to) rep2(x, 0, to) int main() { string s; vector<string> str1; set<string> str2; while (cin >> s) { str1.push_back(s); str2.insert(s); } int w = 0; string ret; rep(i, str1.size()) { if (w < str1[i].length()) { w = str1[i].length(); ret = str1[i]; } } int cnt[1000]; rep(i, 1000) { cnt[i] = 0; } int c = 0; for (auto it = str2.begin(); it != str2.end(); ++it) { rep(j, str1.size()) { if (*it == str1[j]) cnt[c]++; } c++; } int max = 0, r = 0; string ret2; for (auto it = str2.begin(); it != str2.end(); ++it) { if (max < cnt[r]) { max = cnt[r]; ret2 = *it; } r++; } cout << ret << " " << ret2 << endl; return 0; }
#include <cstring> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; #define rep2(x, from, to) for (int x = (from); x < (to); (x)++) #define rep(x, to) rep2(x, 0, to) int main() { string s; vector<string> str1; set<string> str2; while (cin >> s) { str1.push_back(s); str2.insert(s); } int w = 0; string ret; rep(i, str1.size()) { if (w < str1[i].length()) { w = str1[i].length(); ret = str1[i]; } } int cnt[1000]; rep(i, 1000) { cnt[i] = 0; } int c = 0; for (auto it = str2.begin(); it != str2.end(); ++it) { rep(j, str1.size()) { if (*it == str1[j]) cnt[c]++; } c++; } int max = 0, r = 0; string ret2; for (auto it = str2.begin(); it != str2.end(); ++it) { if (max < cnt[r]) { max = cnt[r]; ret2 = *it; } r++; } cout << ret2 << " " << ret << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
289
4
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> using namespace std; int main() { string p[1001], s; int c; int st[1001] = {0}, l = 0, i, maxl = 0, maxn = 0; while ((c = getchar()) != '\n') { if (c == ' ') { for (i = 0; i < l; i++) { if (p[i] == s) { st[i]++; s.clear(); break; } } if (i == l) { int size = s.size(); p[l] = s; maxl = max(maxl, size); if (maxl == s.size()) maxn = l; s.clear(); l++; } } else { s += c; } } for (i = 0; i < l; i++) { if (p[i] == s) { st[i]++; break; } } if (i == l) { int size = s.size(); p[l] = s; maxl = max(maxl, size); if (maxl == s.size()) maxn = l; s.clear(); l++; } int maxb = 0, maxnum; for (int i = 0; i < l; i++) { maxb = max(maxb, st[i]); if (maxb == st[i]) { maxnum = i; } } cout << p[maxnum] << endl; cout << p[maxn] << endl; }
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> using namespace std; int main() { string p[1001], s; int c; int st[1001] = {0}, l = 0, i, maxl = 0, maxn = 0; while ((c = getchar()) != '\n') { if (c == ' ') { for (i = 0; i < l; i++) { if (p[i] == s) { st[i]++; s.clear(); break; } } if (i == l) { int size = s.size(); p[l] = s; maxl = max(maxl, size); if (maxl == s.size()) maxn = l; s.clear(); l++; } } else { s += c; } } for (i = 0; i < l; i++) { if (p[i] == s) { st[i]++; break; } } if (i == l) { int size = s.size(); p[l] = s; maxl = max(maxl, size); if (maxl == s.size()) maxn = l; s.clear(); l++; } int maxb = 0, maxnum; for (int i = 0; i < l; i++) { maxb = max(maxb, st[i]); if (maxb == st[i]) { maxnum = i; } } cout << p[maxnum] << " "; cout << p[maxn] << endl; }
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
340
4
#include "bits/stdc++.h" using namespace std; typedef vector<int> vi; typedef pair<int, int> pii; typedef long long ll; #define dump(x) cerr << #x << " = " << (x) << endl #define rep(i, n) for (int i = 0; i < (n); i++) #define all(a) (a).begin(), (a).end() #define pb push_back int main() { map<string, int> mp; string s; getline(cin, s); vector<string> sent; int len = s.size(); string maxStr = ""; int maxNum = -1; string tmp = ""; rep(i, len) { if (s[i] != ' ') { tmp += s[i]; } else { mp[tmp] += 1; sent.pb(tmp); if (maxNum < (int)tmp.size()) { sent.pb(tmp); maxStr = tmp; maxNum = tmp.size(); } tmp = ""; } } mp[tmp] += 1; sent.pb(tmp); if (maxNum < (int)tmp.size()) { sent.pb(tmp); maxStr = tmp; maxNum = tmp.size(); } string str = ""; int num = -1; for (int i = 0; i < sent.size(); i++) { if (num < mp[sent[i]]) { str = sent[i]; num = mp[sent[i]]; } } cout << str << endl; cout << maxStr << endl; return 0; }
#include "bits/stdc++.h" using namespace std; typedef vector<int> vi; typedef pair<int, int> pii; typedef long long ll; #define dump(x) cerr << #x << " = " << (x) << endl #define rep(i, n) for (int i = 0; i < (n); i++) #define all(a) (a).begin(), (a).end() #define pb push_back int main() { map<string, int> mp; string s; getline(cin, s); vector<string> sent; int len = s.size(); string maxStr = ""; int maxNum = -1; string tmp = ""; rep(i, len) { if (s[i] != ' ') { tmp += s[i]; } else { mp[tmp] += 1; sent.pb(tmp); if (maxNum < (int)tmp.size()) { sent.pb(tmp); maxStr = tmp; maxNum = tmp.size(); } tmp = ""; } } mp[tmp] += 1; sent.pb(tmp); if (maxNum < (int)tmp.size()) { sent.pb(tmp); maxStr = tmp; maxNum = tmp.size(); } string str = ""; int num = -1; for (int i = 0; i < sent.size(); i++) { if (num < mp[sent[i]]) { str = sent[i]; num = mp[sent[i]]; } } cout << str << " " << maxStr << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
317
6
#include <algorithm> #include <iostream> #include <map> #include <string.h> #include <vector> using namespace std; int main() { map<string, int> m; string s; getline(cin, s); string tem = ""; for (int i = 0; i < s.length(); i++) { if (s[i] != ' ' && s[i] != '\n') tem += s[i]; else { if (m.find(tem) != m.end()) { (m.find(tem))->second++; } else { m.insert(pair<string, int>(tem, 1)); } tem = ""; } } if (m.find(tem) != m.end()) { (m.find(tem))->second++; } else { m.insert(pair<string, int>(tem, 1)); } string most, longest; map<string, int>::iterator it = m.begin(); int mo = 0; for (; it != m.end(); it++) { if (it->first.length() > longest.length()) longest = it->first; if (it->second > mo) { most = it->first; mo = it->second; } // cout<<it->first<<" "<<it->second<<endl; } cout << most << endl << longest << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <string.h> #include <vector> using namespace std; int main() { map<string, int> m; string s; getline(cin, s); string tem = ""; for (int i = 0; i < s.length(); i++) { if (s[i] != ' ' && s[i] != '\n') tem += s[i]; else { if (m.find(tem) != m.end()) { (m.find(tem))->second++; } else { m.insert(pair<string, int>(tem, 1)); } tem = ""; } } if (m.find(tem) != m.end()) { (m.find(tem))->second++; } else { m.insert(pair<string, int>(tem, 1)); } string most, longest; map<string, int>::iterator it = m.begin(); int mo = 0; for (; it != m.end(); it++) { if (it->first.length() > longest.length()) longest = it->first; if (it->second > mo) { most = it->first; mo = it->second; } // cout<<it->first<<" "<<it->second<<endl; } cout << most << " " << longest << endl; return 0; }
[["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
297
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <stack> #include <string.h> #include <string> #include <utility> #define mp make_pair #define pii pair<int, int> #define ff first #define ss second #define ll long long #define vi vector<int> using namespace std; int counts[1000]; char str[1000][1000]; int maxl, i, indexml, indexma; int main() { maxl = 0; indexml = 0; indexma = 0; i = 0; memset(counts, 0, sizeof(counts)); while (scanf("%s", str[i]) != EOF) { if (maxl < strlen(str[i])) { maxl = strlen(str[i]); indexml = i; } for (int z = 0; z <= i; z++) { if (strcmp(str[i], str[z]) == 0) { counts[z]++; i--; break; } } i++; } for (int c = 0; c < i; c++) { if (counts[indexma] < counts[c]) indexma = c; } printf("%s %s\n", str[indexma], str[indexml]); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <stack> #include <string.h> #include <string> #include <utility> #define mp make_pair #define pii pair<int, int> #define ff first #define ss second #define ll long long #define vi vector<int> using namespace std; int counts[1000]; char str[1000][100]; int maxl, i, indexml, indexma; int main() { maxl = 0; indexml = 0; indexma = 0; i = 0; memset(counts, 0, sizeof(counts)); while (scanf("%s", str[i]) != EOF) { // if(str[i][0]=='z')break; if (maxl < strlen(str[i])) { maxl = strlen(str[i]); indexml = i; } for (int z = 0; z < i; z++) { if (strcmp(str[i], str[z]) == 0) { counts[z]++; i--; break; } } i++; } for (int c = 0; c < i; c++) { if (counts[indexma] < counts[c]) indexma = c; } printf("%s %s\n", str[indexma], str[indexml]); return 0; }
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
1
250
4
//?\???°?????? // 10??? #include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { map<string, int> m; string s; vector<string> v; while (cin >> s) { if ('A' <= s[0] && s[0] <= 'Z') { s[0] = s[0] - 'A' + 'a'; } m[s]++; v.push_back(s); } int ans1 = -1; int ans2 = -1; string ans1s; string ans2s; for (int i = 0; i < v.size(); i++) { if (ans1 < m[v[i]]) { ans1 = m[v[i]]; ans1s = v[i]; } if (ans2 < v[i].size()) { ans2 = v[i].size(); ans2s = v[i]; } } cout << ans1s << " " << ans2s << endl; }
#include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { map<string, int> m; string s; vector<string> v; while (cin >> s) { if ('A' <= s[0] && s[0] <= 'Z') { s[0] = s[0] - 'A' + 'a'; } m[s]++; v.push_back(s); } int ans1 = -1; int ans2 = -1; string ans1s; string ans2s; for (int i = 0; i < v.size(); i++) { if (ans1 < m[v[i]]) { ans1 = m[v[i]]; ans1s = v[i]; } if (ans2 < (int)v[i].size()) { ans2 = v[i].size(); ans2s = v[i]; } } cout << ans1s << " " << ans2s << endl; }
[["+", 0, 57, 15, 339, 51, 16, 12, 74, 0, 24], ["+", 15, 339, 51, 16, 12, 74, 39, 77, 39, 40], ["+", 0, 57, 15, 339, 51, 16, 12, 74, 0, 25]]
1
210
3
#include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> using namespace std; int main() { map<string, int> str; string word; int big = 0; int cnt = 0; string keepword; string keepstr = ""; string many = ""; while (!cin.eof()) { cin >> word; string kari(word); str[kari]++; if (cnt < str[kari]) { cnt = str[kari]; keepstr = kari; } if (big < word.size()) { big = word.size(); keepword = word; } } cout << keepstr << " " << big << endl; }
#include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> using namespace std; int main() { map<string, int> str; string word; int big = 0; int cnt = 0; string keepword; string keepstr = ""; string many = ""; while (!cin.eof()) { cin >> word; string kari(word); str[kari]++; if (cnt < str[kari]) { cnt = str[kari]; keepstr = kari; } if (big < word.size()) { big = word.size(); keepword = word; } } cout << keepstr << " " << keepword << endl; }
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
141
2
#include <iostream> #include <map> #include <string> using namespace std; map<string, int> table; int main() { string word, frequent, longest; // input, max frequency, and longest size_t N = 0; // frequency of the string "frequent" while (cin >> word) { table["word"] += 1; if (table["word"] > N) { N = table["word"]; frequent = word; } if (word.size() > longest.size()) longest = word; } cout << frequent << " " << longest << endl; }
#include <iostream> #include <map> #include <string> using namespace std; map<string, int> table; int main() { string word, frequent, longest; // input, max frequency, and longest size_t N = 0; // frequency of the string "frequent" while (cin >> word) { table[word] += 1; if (table[word] > N) { N = table[word]; frequent = word; } if (word.size() > longest.size()) longest = word; } cout << frequent << " " << longest << endl; }
[["-", 0, 11, 31, 69, 341, 342, 0, 5, 0, 62], ["-", 51, 16, 31, 69, 341, 342, 0, 5, 0, 62], ["-", 0, 11, 12, 69, 341, 342, 0, 5, 0, 62]]
1
111
6
#include <iostream> #include <map> #include <string> using namespace std; int main() { string s, nmax, gmax; map<string, int> m; map<string, int>::iterator it; int nm = -1, gm = -1; while (cin >> s) { if (nm < s.length()) { nm = s.length(); nmax = s; } if (m.count(s)) m[s]++; else m[s] = 0; } for (it = m.begin(); it != m.end(); it++) { if (gm < it->second) { gm = it->second; gmax = it->first; } } cout << gmax << ' ' << nmax << endl; }
#include <iostream> #include <map> #include <string> using namespace std; int main() { string s, nmax, gmax; map<string, int> m; map<string, int>::iterator it; int nm = -1, gm = -1; while (cin >> s) { if (nm < (int)s.length()) { nm = (int)s.length(); nmax = s; } if (m.count(s)) m[s]++; else m[s] = 0; } for (it = m.begin(); it != m.end(); it++) { if (gm < it->second) { gm = it->second; gmax = it->first; } } cout << gmax << ' ' << nmax << endl; }
[["+", 0, 57, 15, 339, 51, 16, 12, 74, 0, 24], ["+", 15, 339, 51, 16, 12, 74, 39, 77, 39, 40], ["+", 0, 57, 15, 339, 51, 16, 12, 74, 0, 25], ["+", 64, 9, 0, 1, 0, 11, 12, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 74, 39, 77, 39, 40], ["+", 64, 9, 0, 1, 0, 11, 12, 74, 0, 25]]
1
162
23
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define PRINT(STR) cout << STR << endl; #define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define REG(i, a, b) for (int(i) = ((int)(a)); (i) < ((int)(b)); i++) #define ALL(V) (V).begin(), (V).end() #define SPACE " " typedef long long ll; using namespace std; int nextInt() { int n = -1; cin >> n; return n; } double nextDouble() { double d = -1; cin >> d; return d; } ll nextll() { ll n = -1; cin >> n; return n; } string nextString() { string str; cin >> str; return str; } int INF = 1LL << 25; double EPS = 1e-9; // BEGIN ////////////////////////////////////////////////////////////// int main() { map<string, int> d; string str; while (cin >> str) { d[str]++; } int d_max = -1; string ans = ""; for (auto it = d.begin(); it != d.end(); it++) { d_max = max(d_max, it->second); if (ans.size() < it->first.size()) { ans.assign(it->first); } } for (auto it = d.begin(); it != d.end(); it++) { if (it->second == d_max) { PRINT(it->first); break; } } PRINT(ans); return 0; } // END //////////////////////////////////////////////////////////////
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define PRINT(STR) cout << STR << endl; #define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define REG(i, a, b) for (int(i) = ((int)(a)); (i) < ((int)(b)); i++) #define ALL(V) (V).begin(), (V).end() #define SPACE " " typedef long long ll; using namespace std; int nextInt() { int n = -1; cin >> n; return n; } double nextDouble() { double d = -1; cin >> d; return d; } ll nextll() { ll n = -1; cin >> n; return n; } string nextString() { string str; cin >> str; return str; } int INF = 1LL << 25; double EPS = 1e-9; // BEGIN ////////////////////////////////////////////////////////////// int main() { map<string, int> d; string str; while (cin >> str) { d[str]++; } int d_max = -1; string ans = ""; for (auto it = d.begin(); it != d.end(); it++) { d_max = max(d_max, it->second); if (ans.size() < it->first.size()) { ans.assign(it->first); } } for (auto it = d.begin(); it != d.end(); it++) { if (it->second == d_max) { cout << it->first << SPACE; break; } } PRINT(ans); return 0; } // END //////////////////////////////////////////////////////////////
[["-", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
1
311
7
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s[1000]; int n = 0; while (cin >> s[n]) n++; sort(s, s + n); int m, c; m = c = 0; string t, ms, l; ms = t = s[0]; for (int i = 0; i < n; i++) { if (t == s[i]) c++; else { if (c > m) { m = c; ms = t; } c = 1; t = s[i]; if (t.length() > l.length()) l = t; } } ms = t; cout << ms << " " << l << endl; return 0; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s[1000]; int n = 0; while (cin >> s[n]) n++; sort(s, s + n); int m, c; m = c = 0; string t, ms, l; ms = t = s[0]; for (int i = 0; i < n + 1; i++) { if (t == s[i]) c++; else { if (c > m) { m = c; ms = t; } c = 1; t = s[i]; if (t.length() > l.length()) l = t; } } cout << ms << " " << l << endl; return 0; }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
170
6
#include <bits/stdc++.h> using namespace std; typedef pair<string, int> p; vector<p> ls(0); int find(string s) { for (int i = 0; i < (int)ls.size(); i++) { if (s == ls[i].first) return true; } return -1; } int main() { string in; int max = 0, indx = 0; string maxs = ""; while (cin >> in) { int tmp = find(in); if (tmp == -1) { ls.push_back(p(in, 1)); if (in.size() > maxs.size()) { maxs = in; } } else { ls[tmp].second++; if (ls[tmp].second > max) { max = ls[tmp].second; indx = tmp; } } } cout << ls[indx].first << " " << maxs << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef pair<string, int> p; vector<p> ls(0); int find(string s) { for (int i = 0; i < (int)ls.size(); i++) { if (s == ls[i].first) { return i; } } return -1; } int main() { string in; int max = 0, indx = 0; string maxs = ""; while (cin >> in) { int tmp = find(in); if (tmp == -1) { ls.push_back(p(in, 1)); if (in.size() > maxs.size()) { maxs = in; } } else { ls[tmp].second++; if (ls[tmp].second > max) { max = ls[tmp].second; indx = tmp; } } /* for(int i=0; i<(int)ls.size(); i++) cout << ls[i].first << " "; cout << endl; for(int i=0; i<(int)ls.size(); i++) cout << ls[i].second << " "; cout << endl; */ } cout << ls[indx].first << " " << maxs << endl; return 0; }
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 7, 8, 9, 0, 57, 64, 37, 0, 146], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 22], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
209
4
#include <cstdio> #include <cstring> #include <iostream> using namespace std; class Word { public: char w[33]; int length; int freq; public: Word() { strcpy(w, ""); length = 0; freq = 0; } }; int main() { char str[1001]; char buf[32]; char *p, *q; fgets(str, 1001, stdin); Word wl[32]; for (p = str; (q = strstr(p, " ")) != NULL;) { *q = '\0'; strcpy(buf, p); for (int i = 0; i < 32; i++) { if (strcmp(wl[i].w, "") == 0) { strcpy(wl[i].w, buf); wl[i].length = strlen(buf); wl[i].freq = 1; break; } else if (strcmp(wl[i].w, buf) == 0) { wl[i].freq++; break; } } p = q + 1; } strcpy(buf, p); for (int i = 0; i < 32; i++) { if (strcmp(wl[i].w, "") == 0) { strcpy(wl[i].w, buf); wl[i].length = strlen(buf); wl[i].freq = 1; break; } else if (strcmp(wl[i].w, buf) == 0) { wl[i].freq++; break; } } int max_freq = 0; int max_length = 0; char max_freq_w[32]; char max_length_w[32]; for (int i = 0; i < 32; i++) { if (max_freq < wl[i].freq) { max_freq = wl[i].freq; strcpy(max_freq_w, wl[i].w); } if (max_length < wl[i].length) { max_length = wl[i].length; strcpy(max_length_w, wl[i].w); } } cout << max_freq_w << endl << max_length_w << endl; return 0; }
#include <cstdio> #include <cstring> #include <iostream> using namespace std; class Word { public: char w[33]; int length; int freq; public: Word() { strcpy(w, ""); length = 0; freq = 0; } }; int main() { char str[1001]; char buf[32]; char *p, *q; fgets(str, 1001, stdin); Word wl[32]; for (p = str; (q = strstr(p, " ")) != NULL;) { *q = '\0'; strcpy(buf, p); for (int i = 0; i < 32; i++) { if (strcmp(wl[i].w, "") == 0) { strcpy(wl[i].w, buf); wl[i].length = strlen(buf); wl[i].freq = 1; break; } else if (strcmp(wl[i].w, buf) == 0) { wl[i].freq++; break; } } p = q + 1; } strcpy(buf, p); for (int i = 0; i < 32; i++) { if (strcmp(wl[i].w, "") == 0) { strcpy(wl[i].w, buf); wl[i].length = strlen(buf); wl[i].freq = 1; break; } else if (strcmp(wl[i].w, buf) == 0) { wl[i].freq++; break; } } int max_freq = 0; int max_length = 0; char max_freq_w[32]; char max_length_w[32]; for (int i = 0; i < 32; i++) { if (max_freq < wl[i].freq) { max_freq = wl[i].freq; strcpy(max_freq_w, wl[i].w); } if (max_length < wl[i].length) { max_length = wl[i].length; strcpy(max_length_w, wl[i].w); } } cout << max_freq_w << " " << max_length_w << endl; return 0; }
[["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
460
4
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<long long> vl; typedef vector<double> vd; typedef vector<pair<int, int>> vpii; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (n); ++i) #define foreach(itr, c) \ for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++) #define dbg(x) cout << #x "=" << (x) << endl #define mp(a, b) make_pair((a), (b)) #define pb(a) push_back(a) #define in(x) cin >> x; #define all(x) (x).begin(), (x).end() #define INF 2147483600 #define fi first #define se second using namespace std; map<string, int> ans; int l = 0; int k = 0; int main() { string str; string a, b; while (cin >> str) { if (str.size() >= l) { b = str; l = str.size(); } ans[str]++; if (ans[str] >= k) { k = ans[str]; a = ans[str]; } } cout << a << " " << b << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<long long> vl; typedef vector<double> vd; typedef vector<pair<int, int>> vpii; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (n); ++i) #define foreach(itr, c) \ for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++) #define dbg(x) cout << #x "=" << (x) << endl #define mp(a, b) make_pair((a), (b)) #define pb(a) push_back(a) #define in(x) cin >> x; #define all(x) (x).begin(), (x).end() #define INF 2147483600 #define fi first #define se second using namespace std; map<string, int> ans; int l = 0; int k = 0; int main() { string str; string a, b; while (cin >> str) { if (str.size() >= l) { b = str; l = str.size(); } ans[str]++; if (ans[str] >= k) { k = ans[str]; a = str; } } cout << a << " " << b << endl; }
[["-", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]]
1
271
3
#include <algorithm> #include <cctype> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; int main() { multiset<string> kk; int max = 0; int fre = -100000000; string str; string str_max; string str_fre; multiset<string>::iterator iter; while (cin >> str) { if (str.length() > max) { max = str.length(); str_max = str; } kk.insert(str); } for (iter = kk.begin(); iter != kk.end(); iter++) { string str = *iter; int num = kk.count(str); if (num > fre) { fre = num; str_fre = str; } } cout << str_max << " " << str_fre << endl; // while(1); return 0; }
#include <algorithm> #include <cctype> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; int main() { multiset<string> kk; int max = 0; int fre = -100000000; string str; string str_max; string str_fre; multiset<string>::iterator iter; while (cin >> str) { if (str.length() > max) { max = str.length(); str_max = str; } kk.insert(str); } for (iter = kk.begin(); iter != kk.end(); iter++) { string str = *iter; int num = kk.count(str); if (num > fre) { fre = num; str_fre = str; } } cout << str_fre << " " << str_max << endl; // while(1); return 0; }
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
181
4
#include <algorithm> #include <cctype> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; int main() { map<string, int> mymap; int max = 0; int fre = -100000000; string str; string str_max; string str_fre; while (cin >> str) { if (str.length() > max) { max = str.length(); str_max = str; } mymap[str]++; } map<string, int>::iterator iter; for (iter = mymap.begin(); iter != mymap.end(); iter++) { if (iter->second > fre) { str_fre = iter->first; fre = iter->second; } } cout << str_max << " " << str_fre << endl; // while(1); return 0; }
#include <algorithm> #include <cctype> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; int main() { map<string, int> mymap; int max = 0; int fre = -100000000; string str; string str_max; string str_fre; while (cin >> str) { if (str.length() > max) { max = str.length(); str_max = str; } mymap[str]++; } map<string, int>::iterator iter; for (iter = mymap.begin(); iter != mymap.end(); iter++) { if (iter->second > fre) { str_fre = iter->first; fre = iter->second; } } cout << str_fre << " " << str_max << endl; // while(1); return 0; }
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
174
4
#include <iostream> #include <map> using namespace std; int main(void) { map<string, int> m; map<string, int>::iterator it, cit, sit; string s; int maxS = 0, maxC = 0; while (cin >> s) { m[s] += 1; } for (it = m.begin(); it != m.end(); it++) { int size = (*it).first.size(); if (size > maxS) sit = it; maxS = size; int cou = (*it).second; if (cou > maxC) cit = it; maxC = cou; } cout << (*cit).first << " " << (*sit).first << endl; }
#include <iostream> #include <map> using namespace std; int main(void) { map<string, int> m; map<string, int>::iterator it, cit, sit; string s; int maxS = 0, maxC = 0; while (cin >> s) { m[s] += 1; } for (it = m.begin(); it != m.end(); it++) { int size = (*it).first.size(); if (size > maxS) { sit = it; maxS = size; } int cou = (*it).second; if (cou > maxC) { cit = it; maxC = cou; } } /* for(it=m.begin();it!=m.end();it++){ cout <<(*it).first.size() <<" "<<(*it).second<<endl; } */ cout << (*cit).first << " " << (*sit).first << endl; }
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
161
4
#include <iostream> #include <map> #include <string> using namespace std; map<string, int> table; int main() { string word, frequent, longest; int frequent_length = 0; while (cin >> word) { table[word] += 1; if (table[word] > frequent_length) { frequent_length = table[word]; frequent = word; } longest = (word.size() > longest.size()) ? word : longest; } cout << frequent << longest << endl; return 0; }
#include <iostream> #include <map> #include <string> using namespace std; map<string, int> table; int main() { string word, frequent, longest; int frequent_length = 0; while (cin >> word) { table[word] += 1; if (table[word] > frequent_length) { frequent_length = table[word]; frequent = word; } longest = (word.size() > longest.size()) ? word : longest; } cout << frequent << ' ' << longest << endl; return 0; }
[["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
104
4
#include <iostream> #include <map> #include <string> using namespace std; int main() { map<string, int> table; string word; int k1 = 0; int k2 = 0; string answer1; string answer2; while (cin >> word) { table[word] += 1; if (table[word] > k1) { k1 = table[word]; answer1 = word; } int len = sizeof(word); if (len > k2) { k2 = len; answer2 = word; } } cout << answer1 << " " << answer2 << endl; }
#include <iostream> #include <map> #include <string> using namespace std; int main() { map<string, int> table; string word; int k1 = 0; int k2 = 0; string answer1; string answer2; while (cin >> word) { table[word] += 1; if (table[word] > k1) { k1 = table[word]; answer1 = word; } int len = word.length(); if (len > k2) { k2 = len; answer2 = word; } } cout << answer1 << " " << answer2 << endl; }
[["-", 8, 9, 0, 43, 49, 50, 51, 105, 0, 150], ["-", 0, 43, 49, 50, 51, 105, 51, 23, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 17, 131], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24]]
1
116
5
#include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { // word[s] ‚Å •¶Žš—ñs‚̏oŒ»‰ñ”‚ª•Ô‚Á‚Ä‚­‚é map<string, int> word; vector<string> v; string s; while (cin >> s) { v.push_back(s); //“ü—Í‚µ‚½’PŒê‚ª‚·‚łɂ ‚é‚©’T‚· if (word.count(s)) { word[s]++; } else { word[s] = 1; } } // Å•po‚Ì’PŒê‚𒲂ׂé int mode = 0; for (int i = 0; i < v.size(); i++) { mode = max(mode, word[v[i]]); } for (int i = 0; i < v.size(); i++) { if (mode == word[v[i]]) { cout << v[i]; } } // Å’·‚Ì’PŒê‚ð‹‚ß‚é int length = 0; for (int i = 0; i < v.size(); i++) { length = max(length, (int)v[i].size()); } for (int i = 0; i < v.size(); i++) { if (length == v[i].size()) { cout << " " << v[i] << endl; } } }
#include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { // word[s] ‚Å •¶Žš—ñs‚̏oŒ»‰ñ”‚ª•Ô‚Á‚Ä‚­‚é map<string, int> word; vector<string> v; string s; while (cin >> s) { v.push_back(s); //“ü—Í‚µ‚½’PŒê‚ª‚·‚łɂ ‚é‚©’T‚· if (word.count(s)) { word[s]++; } else { word[s] = 1; } } // Å•po‚Ì’PŒê‚𒲂ׂé int mode = 0; for (int i = 0; i < v.size(); i++) { mode = max(mode, word[v[i]]); } for (int i = 0; i < v.size(); i++) { if (mode == word[v[i]]) { cout << v[i]; break; } } // Å’·‚Ì’PŒê‚ð‹‚ß‚é int length = 0; for (int i = 0; i < v.size(); i++) { length = max(length, (int)v[i].size()); } for (int i = 0; i < v.size(); i++) { if (length == v[i].size()) { cout << " " << v[i] << endl; } } }
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
254
2
import java.io.*; class Main { static int count; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; while (!(line = br.readLine()).equals("0 0")) { String[] value = line.split(" "); int n = Integer.parseInt(value[0]); int s = Integer.parseInt(value[1]); count = 0; search(0, n, 0, s); System.out.println(count); } } static void search(int i, int n, int sum, int s) { if (n == 0) { if (sum == s) { count++; return; } } if (i > 9) { return; } for (int a = i; a <= 9; a++) { search(i + 1, n - 1, sum + a, s); } } }
import java.io.*; class Main { static int count; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; while (!(line = br.readLine()).equals("0 0")) { String[] value = line.split(" "); int n = Integer.parseInt(value[0]); int s = Integer.parseInt(value[1]); count = 0; search(0, n, 0, s); System.out.println(count); } } static void search(int i, int n, int sum, int s) { if (n == 0) { if (sum == s) { count++; return; } } if (i > 9) { return; } for (int a = i; a <= 9; a++) { search(a + 1, n - 1, sum + a, s); } } }
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 31, 22]]
3
215
2
import java.util.*; public class Main { public static void main(String[] args) { int n, s, max, count; max = 100; Scanner sc = new Scanner(System.in); for (;;) { n = sc.nextInt(); s = sc.nextInt(); if (n == 0 && s == 0) break; if (s > 864) s = 864; count = check(n - 1, s, max); System.out.println(count); } } private static int check(int n, int s, int max) { int count = 0; if (s < max) max = s; if (n == 0 && s == max) return 1; else if (n == 0) return 0; for (; max >= 0; max--) if (s - max <= n * (max - 1)) count += check(n - 1, s - max, max - 1); return count; } }
import java.util.*; public class Main { public static void main(String[] args) { int n, s, max, count; max = 9; Scanner sc = new Scanner(System.in); for (;;) { n = sc.nextInt(); s = sc.nextInt(); if (n == 0 && s == 0) break; if (s > 864) s = 864; count = check(n - 1, s, max); System.out.println(count); } } private static int check(int n, int s, int max) { int count = 0; if (s < max) max = s; if (n == 0 && s == max) return 1; else if (n == 0) return 0; for (; max >= 0; max--) if (s - max <= n * (max - 1)) count += check(n - 1, s - max, max - 1); return count; } }
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 499], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 499]]
3
213
2
import java.util.*; class Main { static int cnt = 0; private static void re(int i, int n, int v, int t, int s) { // i????????¨????????°?????°,n?????????????±?,v????´??????°???,s???????¨???°,t???????????§??§?????§????????° if (i == n) { for (int j = t + 1; j <= 9; j++) { int tempv = v + j; if (tempv == s) { cnt++; break; } } } else { for (int j = t + 1; j <= 9; j++) { int tempv = v + j; if (tempv < s) { re(i + 1, n, tempv, j, s); } } } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); while (true) { int n = scan.nextInt(); int s = scan.nextInt(); if (n == 0 && s == 0) { break; } re(1, n, 0, -1, s); System.out.println(cnt); } } }
import java.util.*; class Main { static int cnt = 0; private static void re(int i, int n, int v, int t, int s) { // i????????¨????????°?????°,n?????????????±?,v????´??????°???,s???????¨???°,t???????????§??§?????§????????° if (i == n) { for (int j = t + 1; j <= 9; j++) { int tempv = v + j; if (tempv == s) { cnt++; break; } } } else { for (int j = t + 1; j <= 9; j++) { int tempv = v + j; if (tempv < s) { re(i + 1, n, tempv, j, s); } } } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); while (true) { cnt = 0; int n = scan.nextInt(); int s = scan.nextInt(); if (n == 0 && s == 0) { break; } re(1, n, 0, -1, s); System.out.println(cnt); } } }
[["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 499], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
3
221
4
import java.util.*; class Main { static void main(String[] q) { Scanner c = new Scanner(System.in); for (;;) { int n = c.nextInt(), s = c.nextInt(); if (n == 0 && s == 0) break; System.out.println(f(0, 0, s, n)); } } static int f(int x, int a, int t, int n) { return n == 0 ? x == t ? 1 : 0 : a > 9 ? 0 : f(x + a, a + 1, t, n - 1) + f(x, a + 1, t, n); } }
import java.util.*; class Main { public static void main(String[] q) { Scanner c = new Scanner(System.in); for (;;) { int n = c.nextInt(), s = c.nextInt(); if (n == 0 && s == 0) break; System.out.println(f(0, 0, s, n)); } } static int f(int x, int a, int t, int n) { return n == 0 ? x == t ? 1 : 0 : a > 9 ? 0 : f(x + a, a + 1, t, n - 1) + f(x, a + 1, t, n); } }
[["+", 0, 235, 8, 498, 0, 195, 0, 494, 0, 259]]
3
154
1