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
while (n = gets.chomp.to_i) != 0 pa,pb = [0, 0] n.times do a,b = gets.chomp.split.map(&:to_i) if a > b pa += a + b elsif a == b pa += a pa += b elsif a < b pb += a + b end end puts "#{pa} #{pb}" end
while (n = gets.chomp.to_i) != 0 pa,pb = [0, 0] n.times do a,b = gets.chomp.split.map(&:to_i) if a > b pa += a + b elsif a == b pa += a pb += b elsif a < b pb += a + b end end puts "#{pa} #{pb}" end
[["-", 0, 121, 75, 759, 64, 749, 0, 755, 31, 22], ["+", 0, 121, 75, 759, 64, 749, 0, 755, 31, 22]]
4
81
2
while true n = gets.to_i break if n == 0 a,b = 0,0 n.times do ca,cb = gets.split.map{|s|s.to_i} ca == cb ? (a+=ca;b+=cb) : (ca>cb ? a += ca+cb : b += ca+cb) end puts"#{ca} #{cb}" end
while true n = gets.to_i break if n == 0 a,b = 0,0 n.times do ca,cb = gets.split.map{|s|s.to_i} ca == cb ? (a+=ca;b+=cb) : (ca>cb ? a += ca+cb : b += ca+cb) end puts"#{a} #{b}" end
[["-", 0, 652, 3, 4, 0, 557, 0, 284, 0, 22], ["+", 0, 652, 3, 4, 0, 557, 0, 284, 0, 22]]
4
83
4
while str = gets do num = str.chomp.to_i a = 0 b = 0 num.times do |n| x, y = gets.chomp.split(" ").map(&:to_i) if x > y a += x + y elsif x < y b += x + y else a += x b += y end end puts [a, b].join(" ") end
while str = gets do num = str.chomp.to_i break if num == 0 a = 0 b = 0 num.times do |n| x, y = gets.chomp.split(" ").map(&:to_i) if x > y a += x + y elsif x < y b += x + y else a += x b += y end end puts [a, b].join(" ") end
[["+", 0, 89, 8, 170, 0, 751, 8, 94, 0, 94], ["+", 0, 493, 0, 89, 8, 170, 0, 751, 0, 121], ["+", 0, 89, 8, 170, 0, 751, 15, 738, 31, 22], ["+", 0, 89, 8, 170, 0, 751, 15, 738, 17, 60], ["+", 0, 89, 8, 170, 0, 751, 15, 738, 12, 612]]
4
86
5
def main(): sum_a = 0 sum_b = 0 while True: n = input() if n == '0': return for i in range(int(n)): a,b = list(map(int, input().split())) if a > b: sum_a += a+b elif a < b: sum_b += a+b else:...
# coding: utf-8 # Your code here! def main(): while True: sum_a = 0 sum_b = 0 n = input() if n == '0': return for i in range(int(n)): a,b = list(map(int, input().split())) if a > b: sum_a += a+b elif a < b: ...
[["+", 0, 656, 0, 14, 8, 196, 0, 52, 0, 89], ["+", 0, 656, 0, 14, 8, 196, 0, 52, 15, 146], ["+", 0, 656, 0, 14, 8, 196, 0, 52, 0, 102], ["-", 0, 656, 0, 14, 8, 196, 0, 52, 0, 89], ["-", 0, 656, 0, 14, 8, 196, 0, 52, 15, 146], ["-", 0, 656, 0, 14, 8, 196, 0, 52, 0, 102]]
5
101
6
while 1: n = input() if n == 0: break sum_a = 0 sum_b = 0 for i in range(n): a,b = map(int, raw_input().split()) if a > b: sum_a = sum_a + a + b elif a < b: sum_b = sum_b + a + b elif a == b: sum_a = sum_a...
while 1: n = int(input()) if n == 0: break sum_a = 0 sum_b = 0 for i in range(n): a,b = map(int, input().split()) if a > b: sum_a = sum_a + a + b elif a < b: sum_b = sum_b + a + b elif a == b: sum_a = sum_...
[["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22]]
5
95
5
while True: n = eval(input()) if n == 0: break ATen = 0 BTen = 0 for i in range(n): A, B = list(map(int, input().split())) if A > B: ATen += A + B elif A < B: BTen += A + B elif A == B: ATen = A BTen = B prin...
while True: n = eval(input()) if n == 0: break ATen = 0 BTen = 0 for i in range(n): A, B = list(map(int, input().split())) if A > B: ATen += A + B elif A < B: BTen += A + B elif A == B: ATen += A BTen += B pr...
[["-", 75, 665, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 665, 64, 196, 0, 1, 0, 677, 17, 107]]
5
87
4
while True: n = int(input()) if n == 0: break score = {"A": 0, "B": 0} for _ in range(n): A, B = map(int, input().split()) if A > B: score["A"] += A elif A < B: score["B"] += B else: score["A"] += A score["B"] += B ...
while True: n = int(input()) if n == 0: break score = {"A": 0, "B": 0} for _ in range(n): A, B = map(int, input().split()) if A > B: score["A"] += A+B elif A < B: score["B"] += A+B else: score["A"] += A score["B"] +=...
[["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 72], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 31, 22]]
5
116
4
n = int(input()) while n != 0: A = 0 B = 0 for i in range(n): a, b = map(int, input().split()) if a > b: A += a + b elif a < b: B += a + b else: A += a B += b print("{0} {1}".format(A, B)) n = int(input())
n = int(input()) while n != 0: A = 0 B = 0 for i in range(n): a, b = map(int, input().split()) if a > b: A += (a + b) elif a < b: B += (a + b) else: A += a B += b print("{0} {1}".format(A, B)) n = int(input())
[["+", 64, 196, 0, 1, 0, 677, 12, 23, 0, 24], ["+", 64, 196, 0, 1, 0, 677, 12, 23, 0, 25]]
5
92
4
while 1: n=int(input()) if n==0: break a=b=0 while n: c,d=map(int,input().split()) if c<b:b+=c+d elif c>d:a+=c+d else: a+=c b+=c n-=1 print(a,b)
while 1: n=int(input()) if n==0: break a=b=0 while n: c,d=map(int,input().split()) if c<d:b+=c+d elif c>d:a+=c+d else: a+=c b+=c n-=1 print(a,b)
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22]]
5
78
2
import sys def calc(): while True: n = int(input()) if n <= 0: break a = 0 b = 0 while n > 0: ans = list(map(int, input().split())) if ans[0] > ans[1]: a += ans[0] + ans[1] elif ans[1] < ans[0]: ...
import sys def calc(): while True: n = int(input()) if n <= 0: break a = 0 b = 0 while n > 0: ans = list(map(int, input().split())) if ans[0] > ans[1]: a += ans[0] + ans[1] elif ans[0] < ans[1]: ...
[["-", 0, 57, 75, 665, 15, 666, 0, 206, 206, 612], ["+", 0, 57, 75, 665, 15, 666, 0, 206, 206, 612]]
5
129
4
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; public class Main { MyScanner sc; PrintWriter writer; public void solve() { int n = sc.nextInt(); if (n == 0) { return; ...
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; public class Main { MyScanner sc; PrintWriter writer; public void solve() { while (true) { int n = sc.nextInt(); if (n == ...
[["+", 8, 498, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 0, 195, 8, 196, 0, 52, 15, 15, 0, 24], ["+", 0, 195, 8, 196, 0, 52, 15, 15, 0, 146], ["+", 0, 195, 8, 196, 0, 52, 15, 15, 0, 25], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
3
812
6
import java.io.PrintWriter; import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); while (sc.hasNext()) { int m = sc.nextInt(); if (m == 0) break; String temp[][] = new St...
import java.io.PrintWriter; import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); while (sc.hasNext()) { int m = sc.nextInt(); if (m == 0) break; String temp[][] = new St...
[["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
3
240
4
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; int roop = 0; StringBuilder[] ans = new StringBuilder[1000]; String tmpData; while ((n = sc.nextInt()) != 0) { String[][] str = new String[n][2]; for (int j ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; int roop = 0; StringBuilder[] ans = new StringBuilder[1000]; String tmpData; while ((n = sc.nextInt()) != 0) { String[][] str = new String[n][2]; for (int j ...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 230, 3, 4, 0, 499], ["+", 0, 1, 0, 11, 12, 230, 3, 4, 0, 22], ["-", 75, 196, 0, 1, 0, 492, 3, 4, 0, 22], ["+", 75, 196, 0, 1, 0, 492, 3, 4, 0, 22], ["-", 0, 492, 3, 4, 0, 492, 500, 504, 71, 22], ["+", 0, 49...
3
286
8
import java.util.*; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n; HashMap<String, String> hm = new HashMap<String, String>(); while (true) { n = scan.nextInt(); if (n == 0) { break; } for (int i = 0; i < n; i++) { ...
import java.util.*; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n; HashMap<String, String> hm = new HashMap<String, String>(); while (true) { n = scan.nextInt(); if (n == 0) { break; } for (int i = 0; i < n; i++) { ...
[["+", 0, 52, 8, 196, 0, 1, 0, 492, 500, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 0, 131], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
3
192
6
#include <stdio.h> char conv[10000]; char ans[100000005]; int main(void) { int i, j, n, m; char c, a, b; while (1) { scanf("%d", &n); if (n == 0) break; for (i = 0; i < n; i++) conv[i] = 0; for (i = 0; i < n; i++) { scanf(" %c %c", &a, &b); conv[a] = b; } sca...
#include <stdio.h> char conv[10000]; char ans[100000005]; int main(void) { int i, j, n, m; char c, a, b; while (1) { scanf("%d", &n); if (n == 0) break; for (i = 0; i < 10000; i++) conv[i] = 0; for (i = 0; i < n; i++) { scanf(" %c %c", &a, &b); conv[a] = b; } ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
0
206
2
#include <stdio.h> #include <string.h> int main(void) { int dice[6]; int i, j; int n; char str[5]; char str_t[6][6] = {"North", "East", "West", "South", "Right", "Left"}; int sum; int m; int tmp; while (1) { sum = 0; for (i = 0; i < 6; i++) { dice[i] = i + 1; } scanf("%d", &...
#include <stdio.h> #include <string.h> int main(void) { int dice[6]; int i, j; int n; char str[5]; char str_t[6][6] = {"North", "East", "West", "South", "Right", "Left"}; int sum; int m; int tmp; while (1) { sum = 1; for (i = 0; i < 6; i++) { dice[i] = i + 1; } scanf("%d", &...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
0
546
2
#include <stdio.h> int main(void) { int i, n, sum, dice[6], d; char inst[6]; scanf("%d", &n); while (n != 0) { sum = 1; dice[0] = 1; dice[1] = 2; dice[2] = 3; dice[3] = 4; dice[4] = 5; dice[5] = 6; for (i = 0; i < n; i++) { scanf("%s", inst); switch (inst[0]) { ...
#include <stdio.h> int main(void) { int i, n, sum, dice[6], d; char inst[6]; scanf("%d", &n); while (n != 0) { sum = 1; dice[0] = 1; dice[1] = 2; dice[2] = 3; dice[3] = 4; dice[4] = 5; dice[5] = 6; for (i = 0; i < n; i++) { scanf("%s", inst); switch (inst[0]) { ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
461
1
#include <stdio.h> int main() { int i, n, gou = 1; int f, v, t, r, q, s; int a[6]; char moji[10] = {'\0'}; while (1) { scanf("%d", &n); if (n == 0) break; a[0] = 1; a[1] = 2; a[2] = 6; a[3] = 5; a[4] = 4; a[5] = 3; for (i = 0; i < n; i++) { scanf("%s", moji); ...
#include <stdio.h> int main() { int i, n, gou = 1; int f, v, t, r, q, s; int a[6]; char moji[10] = {'\0'}; while (1) { scanf("%d", &n); if (n == 0) break; a[0] = 1; a[1] = 2; a[2] = 6; a[3] = 5; a[4] = 4; a[5] = 3; gou = 1; for (i = 0; i < n; i++) { scanf(...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
780
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int main() { int n, dice[7] = {0, 1, 2, 3, 4, 5, 6}, sum = 1; char order[6]; while (1) { scanf("%d\n", &n); if (n == ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int main() { int n, dice[7] = {0, 1, 2, 3, 4, 5, 6}, sum = 1; char order[6]; while (1) { scanf("%d", &n); if (n == 0)...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13]]
1
508
3
#include <iostream> #include <string> #include <vector> using namespace std; int main() { while (1) { int ans = 1, k, ue = 1, migi = 3, hidari = 2; cin >> k; if (k == 0) break; while (k--) { string a; int s, d; cin >> a; if (a == "North") { s = ue; ue =...
#include <iostream> #include <string> #include <vector> using namespace std; int main() { while (1) { int ans = 1, k, ue = 1, migi = 3, hidari = 2; cin >> k; if (k == 0) break; while (k--) { string a; int s, d; cin >> a; if (a == "North") { s = ue; ue =...
[["-", 0, 57, 15, 339, 51, 16, 12, 5, 0, 6], ["+", 0, 57, 15, 339, 51, 16, 12, 5, 0, 6]]
1
234
4
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; string list[] = {"North", "East", "South", "West", "Right", "Left"}; enum { UE, TEMAE, MIGI }; int main() { int n; while (cin >> n, n != 0) { int dice[3] = {1, 2, 3}; int score = 1; for (int i = 0; i < ...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; string list[] = {"North", "East", "West", "South", "Right", "Left"}; enum { UE, TEMAE, MIGI }; int main() { int n; while (cin >> n, n != 0) { int dice[3] = {1, 2, 3}; int score = 1; for (int i = 0; i < ...
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
363
4
#include <iostream> using namespace std; int main() { int t, n, sam; string comand; while (cin >> n, n != 0) { sam = 0; int dice[6] = {1, 2, 3, 5, 4, 6}; for (int i = 0; i < n; i++) { cin >> comand; if (comand == "North") { t = dice[0]; dice[0] = dice[1]; dice[1] =...
#include <iostream> using namespace std; int main() { int t, n, sam; string comand; while (cin >> n, n != 0) { sam = 1; int dice[6] = {1, 2, 3, 5, 4, 6}; for (int i = 0; i < n; i++) { cin >> comand; if (comand == "North") { t = dice[0]; dice[0] = dice[1]; dice[1] =...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
1
423
2
#include <algorithm> #include <cmath> #include <iostream> #include <string> using namespace std; int dice[6], kari[6], sum, n; string str; int main() { while (1) { for (int i = 0; i < 6; i++) { dice[i] = i + 1; kari[i] = dice[i]; } sum += dice[0]; cin >> n; if (n == 0) { break;...
#include <algorithm> #include <cmath> #include <iostream> #include <string> using namespace std; int dice[6], kari[6], sum, n; string str; int main() { while (1) { sum = 0; for (int i = 0; i < 6; i++) { dice[i] = i + 1; kari[i] = dice[i]; } sum += dice[0]; cin >> n; if (n == 0) {...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
465
4
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(10) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef...
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(10) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
781
2
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define pb(a) push_back(a) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; using namespace std; void order(int d[6], string str) { int temp; if (str == "North") { ...
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define pb(a) push_back(a) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; using namespace std; void order(int d[6], string str) { int temp; if (str == "North") { ...
[["+", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 25]]
1
458
4
#include <iostream> #include <string> #include <vector> class Sai { public: int up; int down; int north; int east; int west; int south; Sai() { up = 1; down = 6; south = 2; east = 3; north = 5; west = 4; } void North() { int temp = up; up = south; south = down; ...
#include <iostream> #include <string> #include <vector> class Sai { public: int up; int down; int north; int east; int west; int south; Sai() { up = 1; down = 6; south = 2; east = 3; north = 5; west = 4; } void North() { int temp = up; up = south; south = down; ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 0, 35], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 49, 22]]
1
477
6
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class t> using table = vector<vector<t>>; const ld eps = 1e-9; //< "d:\d_download\visual studio //2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_d...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class t> using table = vector<vector<t>>; const ld eps = 1e-9; //< "d:\d_download\visual studio //2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_d...
[["-", 0, 1, 0, 2, 3, 4, 0, 343, 141, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 343, 141, 22], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 23, 0, 25]]
1
566
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define RREP(i, n) for (i...
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define RREP(i, n) for (i...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 14, 8, 9, 0, 1, 0, 35]]
1
402
4
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include ...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include ...
[["-", 0, 99, 8, 9, 0, 100, 51, 103, 0, 125], ["+", 0, 99, 8, 9, 0, 100, 51, 103, 0, 125]]
1
483
4
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <string> #include <utility> #include <vector> using namespace std; int main() { while (true) { int n; cin >> n; if (n == 0) { break; } int ue = 1, sita = 6, temae = 2, oku = 5, migi = 3, hidari = 4; ...
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <string> #include <utility> #include <vector> using namespace std; int main() { while (true) { int n; cin >> n; if (n == 0) { break; } int ue = 1, sita = 6, temae = 2, oku = 5, migi = 3, hidari = 4; ...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
295
2
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <string.h> using namespace std; int main() { int n = 5, s = 2, e = 3, w = 4, t = 1, b = 6; int y, z; int p = 1; char sn[10]; while (1) { cin >> y; if (y == 0) { break; } for (int i = 0; i < y; i++) {...
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <string.h> using namespace std; int main() { int n = 5, s = 2, e = 3, w = 4, t = 1, b = 6; int y, z; int p = 1; char sn[10]; while (1) { cin >> y; if (y == 0) { break; } for (int i = 0; i < y; i++) {...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
377
6
// dice #include <stdio.h> int dice[6]; void swap(int a, int b, int c, int d) { int temp; temp = dice[a]; dice[a] = dice[b]; dice[b] = dice[c]; dice[c] = dice[d]; dice[d] = temp; } int main(void) { int n, i, r; char s[8]; while (1) { scanf("%d", &n); if (n == 0) { break; } r = ...
// dice #include <stdio.h> int dice[6]; void swap(int a, int b, int c, int d) { int temp; temp = dice[a]; dice[a] = dice[b]; dice[b] = dice[c]; dice[c] = dice[d]; dice[d] = temp; } int main(void) { int n, i, r; char s[8]; while (1) { scanf("%d", &n); if (n == 0) { break; } r = ...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
1
347
2
#include <stdio.h> int main() { int dice[] = {1, 2, 3}, aa, x, t; char a[10]; while (1) { dice[0] = 1; dice[1] = 2; dice[2] = 3; scanf("%d", &aa); if (aa == 0) break; t = 1; for (int i = 0; i < aa; i++) { scanf("%s", &a); if (a[0] == 'N') { x = dice[0]; ...
#include <stdio.h> int main() { int dice[] = {1, 2, 3}, aa, x, t; char a[10]; while (1) { dice[0] = 1; dice[1] = 2; dice[2] = 3; scanf("%d", &aa); if (aa == 0) break; t = 1; for (int i = 0; i < aa; i++) { scanf("%s", &a); if (a[0] == 'N') { x = dice[0]; ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
363
1
#include <stdio.h> int a[6], t; #define f(A, B, C, D) \ (t = a[D], a[D] = a[C], a[C] = a[B], a[B] = a[A], a[A] = t) int main(void) { int n, r, i; char s[9]; while (scanf("%d", &n), n) { for (r = i = 0; i < 6; ++i) a[i] = i + 1; while (n--) {...
#include <stdio.h> int a[6], t; #define f(A, B, C, D) \ (t = a[D], a[D] = a[C], a[C] = a[B], a[B] = a[A], a[A] = t) int main(void) { int n, r, i; char s[9]; while (scanf("%d", &n), n) { for (r = i = 1; i < 7; ++i) a[i - 1] = i; while (n--) {...
[["-", 8, 9, 0, 7, 10, 11, 12, 11, 12, 13], ["+", 8, 9, 0, 7, 10, 11, 12, 11, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 7, 8, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 7, 8...
1
251
8
#include <cstdio> using namespace std; int sai[6] = {1, 2, 3, 4, 5, 6}; int fun(char c) { int fsai[6]; if (c == 'N') { fsai[0] = sai[1]; fsai[1] = sai[5]; fsai[2] = sai[2]; fsai[3] = sai[3]; fsai[4] = sai[0]; fsai[5] = sai[4]; } if (c == 'E') { fsai[0] = sai[3]; fsai[1] = sai[...
#include <cstdio> using namespace std; int sai[6] = {1, 2, 3, 4, 5, 6}; int fun(char c) { int fsai[6]; if (c == 'N') { fsai[0] = sai[1]; fsai[1] = sai[5]; fsai[2] = sai[2]; fsai[3] = sai[3]; fsai[4] = sai[0]; fsai[5] = sai[4]; } if (c == 'E') { fsai[0] = sai[3]; fsai[1] = sai[...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
607
2
#include <iostream> #include <string> using namespace std; int main() { string a; int n; int b; //上面 int c; //前面 int d; //右面 int e; int f; int g; while (cin >> n) { if (n != 0) { b = 1; c = 2; d = 3; e = 0; g = 0; while (e < n) { cin >> a; if (a ...
#include <iostream> #include <string> using namespace std; int main() { string a; int n; int b; //上面 int c; //前面 int d; //右面 int e; int f; int g; while (cin >> n) { if (n != 0) { b = 1; c = 2; d = 3; e = 0; g = 1; while (e < n) { cin >> a; if (a ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
251
2
#include <cstdio> #include <iostream> #include <string> using namespace std; int main() { while (1) { string str; int a, buf, N = 5, E = 3, S = 2, W = 4, U = 1, D = 6, answer = 0; cin >> a; if (a == 0) return 0; for (int i = 0; i < a; i++) { cin >> str; if (str == "North") { ...
#include <cstdio> #include <iostream> #include <string> using namespace std; int main() { while (1) { string str; int a, buf, N = 5, E = 3, S = 2, W = 4, U = 1, D = 6, answer = 0; cin >> a; if (a == 0) return 0; for (int i = 0; i < a; i++) { cin >> str; if (str == "North") { ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
282
2
#include <iostream> #include <string> #include <vector> int main() { int a = 0; int z = 1; while (1) { std::cin >> a; if (a == 0) break; std::vector<int> vec(7); std::vector<int> vec1(7); for (int i = 1; i < 7; i++) { vec[i] = i; vec1[i] = i; } std::string str; f...
#include <iostream> #include <string> #include <vector> int main() { int a = 0; int z = 1; while (1) { std::cin >> a; if (a == 0) break; std::vector<int> vec(7); std::vector<int> vec1(7); for (int i = 1; i < 7; i++) { vec[i] = i; vec1[i] = i; } std::string str; f...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
1,102
4
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static class Pair implements Comparable<Pair> { public int first = 0, second = 0; @Override public int compareTo(Pair other) { return this.second - other.second; } } public static voi...
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static class Pair implements Comparable<Pair> { public int first = 0, second = 0; @Override public int compareTo(Pair other) { return other.second - this.second; } } public static voi...
[["-", 8, 196, 0, 37, 0, 16, 31, 509, 500, 274], ["+", 8, 196, 0, 37, 0, 16, 31, 509, 500, 22], ["-", 8, 196, 0, 37, 0, 16, 12, 509, 500, 22], ["+", 8, 196, 0, 37, 0, 16, 12, 509, 500, 274]]
3
282
4
#include <algorithm> #include <iostream> using namespace std; int N, M, v; pair<int, int> vote_area[110]; int main() { while (cin >> N >> M && N > 0) { for (int l = 0; l < M; ++l) { vote_area[l].first = 0; vote_area[l].second = -(l + 1); } for (int i = 0; i < N; ++i) { for (int j = 0; j...
#include <algorithm> #include <iostream> using namespace std; int N, M, v; pair<int, int> vote_area[110]; int main() { while (cin >> N >> M && N > 0) { for (int l = 0; l < M; ++l) { vote_area[l].first = 0; vote_area[l].second = -(l + 1); } for (int i = 0; i < N; ++i) { for (int j = 0; j...
[["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151]]
1
230
4
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <util...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <util...
[["+", 0, 52, 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, 46]]
1
287
3
#include <algorithm> #include <iostream> #include <vector> using namespace std; int n, m, c; int main() { while (true) { scanf("%d", &n); scanf("%d", &m); if (n == 0 && m == 0) { break; } vector<pair<int, int>> r(m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) {...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int n, m, c; int main() { while (true) { scanf("%d", &n); scanf("%d", &m); if (n == 0 && m == 0) { break; } vector<pair<int, int>> r(m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) {...
[["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
216
7
#include <algorithm> #include <iostream> #include <vector> using namespace std; class HOTEL { public: int hotel; int vote; bool operator<(const HOTEL &h) { if (vote == h.vote) { return hotel > h.hotel; } else { return vote < h.vote; } } }; int main() { int i, j, n, m, tmp; while ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; class HOTEL { public: int hotel; int vote; bool operator<(const HOTEL &h) { if (vote == h.vote) { return hotel > h.hotel; } else { return vote < h.vote; } } }; int main() { int i, j, n, m, tmp; while ...
[["+", 0, 52, 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, 46]]
1
258
3
#include <bits/stdc++.h> #define N 105 using namespace std; typedef pair<int, int> P; int n, m, a; P ans[N]; int main() { while (1) { cin >> n >> m; if (!n && !m) break; for (int i = 1; i <= m; i++) ans[i].first = 0, ans[i].second = i; for (int i = 0; i < n; i++) for (int j = 1; j <...
#include <bits/stdc++.h> #define N 105 using namespace std; typedef pair<int, int> P; int n, m, a; P ans[N]; int main() { while (1) { cin >> n >> m; if (!n && !m) break; for (int i = 1; i <= m; i++) ans[i].first = 0, ans[i].second = i; for (int i = 0; i < n; i++) for (int j = 1; j <...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 7, 10, 43, 49, 50, 51, 22], ["+", 0, 7, 8, 7, 10, 43, 49, 50, 51, 13]]
1
237
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, m; while (cin >> n >> m, n) { vector<pair<int, int>> vp(m); for (int i = 0; i < m; i++) vp[i] = make_pair(0, i); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int t; ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, m; while (cin >> n >> m, n) { vector<pair<int, int>> vp(m); for (int i = 0; i < m; i++) vp[i] = make_pair(0, i + 1); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int t...
[["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
176
2
#include <algorithm> #include <cstdio> #include <vector> using namespace std; struct A { int n; int a; }; struct A V_A[100]; class sort_ { public: bool operator()(const A &a, const A &b) { if (b.n == a.n) { return a.a < b.a; } return b.n < a.n; } }; int main() { int n, m; while (true)...
#include <algorithm> #include <cstdio> #include <vector> using namespace std; struct A { int n; int a; }; struct A V_A[105]; class sort_ { public: bool operator()(const A &a, const A &b) { if (b.n == a.n) { return a.a < b.a; } return b.n < a.n; } }; int main() { int n, m; while (true)...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 2, 3, 4, 0, 16, 12, 105, 0, 150], ["-", 0, 16, 12, 105, 51, 16, 31, 23, 0, 24], ["-", 0, 16, 12, 105, 51, 16, 31, 23, 0, 22], ["-", 0, 16, 12, 105, 51, 16, 31, 23, 0, 25], ["-", 3, 4, 0, 16, 12, 105, 51, 16, 17, 48]]
1
286
7
#include <algorithm> #include <cstdio> #include <iostream> #include <map> using namespace std; typedef pair<int, int> P; P p[111]; int main(void) { while (1) { int n, m; cin >> n >> m; if (!n && !m) break; for (int i = 0; i < m; i++) { p[i] = P(0, i + 1); } for (int i = 0; i < n; i...
#include <algorithm> #include <cstdio> #include <iostream> #include <map> using namespace std; typedef pair<int, int> P; P p[111]; int main(void) { while (1) { int n, m; cin >> n >> m; if (!n && !m) break; for (int i = 0; i < m; i++) { p[i] = P(0, i + 1); } for (int i = 0; i < n; i...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
190
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <string> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb(in, tmp) in.push_back(tmp) #define all(in) in.begin(), n.end() #define PI acos(-1) using namespace s...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <string> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb(in, tmp) in.push_back(tmp) #define all(in) in.begin(), n.end() #define PI acos(-1) using namespace s...
[["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
243
8
while True: students,places = list(map(int,input().split())) if students == 0 and places == 0: break res = dict(list(zip(list(range(places)),[0]*places))) for i in range(students): points = list(map(int,input().split())) for j in range(places): res[j] += points[j] for k,v in sorted(list(res.items()),key=l...
while True: students,places = list(map(int,input().split())) if students == 0 and places == 0: break res = dict(list(zip(list(range(places)),[0]*places))) for i in range(students): points = list(map(int,input().split())) for j in range(places): res[j] += points[j] for k,v in sorted(list(res.items()),key=l...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["-", 0, 652, 3, 4, 0, 557, 0, 6, 0, 44], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655]]
5
147
3
/* AOJ 0507 Title:Square @kankichi573 */ #include <stdio.h> #define min(x, y) (((x) < (y)) ? (x) : (y)) int prefix[31]; void print_prefix(int len) { int i; for (i = 0; i < len; i++) printf("%d ", prefix[i]); } void print_square(int sum, int len, int max_) { int i; // printf(":%d %d %d\n",sum,len,m...
/* AOJ 0507 Title:Square @kankichi573 */ #include <stdio.h> #define min(x, y) (((x) < (y)) ? (x) : (y)) int prefix[31]; void print_prefix(int len) { int i; for (i = 0; i < len; i++) printf("%d ", prefix[i]); } void print_square(int sum, int len, int max_) { int i; // printf(":%d %d %d\n",sum,len,m...
[["-", 10, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["-", 10, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
0
257
2
#include <memory.h> #include <stdio.h> void f(int now, int rest, int list[], int p) { int i; list[p] = now; if (rest == 0) { for (i = 0; i <= p; i++) { if (i > 0) { printf(" "); } printf("%d", list[i]); } } for (i = rest; i > 0; i--) { if (i > now) { continue; }...
#include <memory.h> #include <stdio.h> void f(int now, int rest, int list[], int p) { int i; list[p] = now; if (rest == 0) { for (i = 0; i <= p; i++) { if (i > 0) { printf(" "); } printf("%d", list[i]); } puts(""); } for (i = rest; i > 0; i--) { if (i > now) { c...
[["+", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
0
209
6
#include <algorithm> #include <cstring> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define REP(i, k, n) for (int i = k; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1 << 30 #define pb push_back #define mp make_pair using namespace ...
#include <algorithm> #include <cstring> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define REP(i, k, n) for (int i = k; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1 << 30 #define pb push_back #define mp make_pair using namespace ...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
273
6
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; vector<vector<int>> ans; void getans(vector<int> now, int pre, int rest) { for (int i = min(rest, pre); i >= 1; -...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; vector<vector<int>> ans; void getans(vector<int> now, int pre, int rest) { for (int i = min(rest, pre); i >= 1; -...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
228
6
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <vector> #de...
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <vector> #de...
[["-", 51, 218, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 51, 218, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 51, 218, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 51, 218, 8, 9, 0, 7, 26, 27, 28, 22]]
1
488
4
#include <cstdio> int calc(int aa[31], int l) { int a[31], f = 1; for (int i = 0; i < 31; i++) a[i] = aa[i]; for (int i = 1; i < l + 1; i++) if (a[i - 1] < a[i]) f = 0; for (int i = 0; f && i < l; i++) printf("%d ", a[i]); if (f) printf("%d\n", a[l]); while (a[l] > 1) { if (a[l ...
#include <cstdio> int calc(int aa[31], int l) { int a[31], f = 1; for (int i = 0; i < 31; i++) a[i] = aa[i]; for (int i = 1; i < l + 1; i++) if (a[i - 1] < a[i]) f = 0; for (int i = 0; f && i < l; i++) printf("%d ", a[i]); if (f) printf("%d\n", a[l]); while (a[l] > 1) { if (a[l ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
326
2
#include <iostream> using namespace std; int a[31], n; void hyo(int sum = 0, int size = 0) { if (sum == n) { for (int i = 0; i < size; i++) { if (i) cout << " "; cout << a[i]; } cout << endl; } for (int i = n - sum; i > 0; i--) { a[size] = i; if (sum != 0) if (i > a[...
#include <iostream> using namespace std; int a[31], n; void hyo(int sum = 0, int size = 0) { if (sum == n) { for (int i = 0; i < size; i++) { if (i) cout << " "; cout << a[i]; } cout << endl; } for (int i = n - sum; i > 0; i--) { a[size] = i; if (sum != 0) if (i > a[...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25]]
1
146
6
#include <iostream> #include <sstream> using namespace std; int n; int r(int a, int b, string s) { a || cout << s; for (int i = a < b ? a : b; i > 0; i--) { stringstream t; t << i << (a - i ? " " : "\n"); r(a - i, i, s + t.str()); } } main() { cin >> n; r(n, n, ""); }
#include <iostream> #include <sstream> using namespace std; int n; int r(int a, int b, string s) { a || cout << s; for (int i = a < b ? a : b; i > 0; i--) { stringstream t; t << i << (a - i ? " " : "\n"); r(a - i, i, s + t.str()); } } main() { for (; cin >> n, n;) r(n, n, ""); }
[["+", 0, 30, 0, 14, 8, 9, 0, 7, 0, 88], ["+", 0, 30, 0, 14, 8, 9, 0, 7, 0, 24], ["+", 0, 30, 0, 14, 8, 9, 0, 7, 0, 35], ["+", 8, 9, 0, 7, 15, 34, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 34, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 7, 0, 25]]
1
110
6
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include...
[["-", 0, 52, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 80, 81, 13]]
1
332
2
INF = 2 << 32 def out stat, remain puts stat.join(' ') if remain.zero? ([stat.last || INF, remain].min.downto(1)).each {|n| out(stat << n, remain - n) } stat.pop end until (n = gets.to_i) == 0 out [], 5 end
INF = 2 << 32 def out stat, remain puts stat.join(' ') if remain.zero? ([stat.last || INF, remain].min.downto(1)).each {|n| out(stat << n, remain - n) } stat.pop end until (n = gets.to_i) == 0 out [], n end
[["-", 0, 750, 8, 170, 0, 652, 3, 4, 0, 612], ["+", 0, 750, 8, 170, 0, 652, 3, 4, 0, 22]]
4
78
2
l = [0 for i in range(20)] pos = goal = 0 def solve(cur,sum): global pos, goal if cur == goal: print(" ".join(map(str,l[:pos]))) return for i in range(sum,0,-1): if cur + i <= goal: l[pos] = i pos += 1 solve(cur+i,i) pos -= 1 while True...
l = [0 for i in range(31)] pos = goal = 0 def solve(cur,sum): global pos, goal if cur == goal: print(" ".join(map(str,l[:pos]))) return for i in range(sum,0,-1): if cur + i <= goal: l[pos] = i pos += 1 solve(cur+i,i) pos -= 1 while True...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612]]
5
118
21
#include <bitset> #include <iostream> #include <vector> using namespace std; class range { private: struct Iterator { int val; int operator*() { return val; } bool operator!=(Iterator &itr) { return val < itr.val; } void operator++() { ++val; } }; Iterator i, n; public: range(int n) : i({0}),...
#include <bitset> #include <iostream> #include <vector> using namespace std; class range { private: struct Iterator { int val; int operator*() { return val; } bool operator!=(Iterator &itr) { return val < itr.val; } void operator++() { ++val; } }; Iterator i, n; public: range(int n) : i({0}),...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 338, 12, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 338, 12, 2, 3, 4, 0, 13]]
1
611
6
#include <cstdio> #include <queue> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define pb push_back using namespace std; vector<int> e[100]; bool used[100]; int ans; void dfs(int x, int y) { if (used[x]) { if (y > ans) ans = y; return; } used[x] = true; rep(i, e[x].size()) { ...
#include <cstdio> #include <queue> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define pb push_back using namespace std; vector<int> e[100]; bool used[100]; int ans; void dfs(int x, int y) { if (used[x]) { if (y > ans) ans = y; return; } used[x] = true; rep(i, e[x].size()) { ...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
252
3
#include <bits/stdc++.h> using namespace std; #define PB push_back const int INF = 999; vector<int> v[100]; bool vis[100]; bool f[100]; int search(int now) { // vis[now] = true; int res = 1; for (int i = 0; i < v[now].size(); i++) { vis[now] = true; if (!vis[v[now][i]]) res = max(res, search(v[no...
#include <bits/stdc++.h> using namespace std; #define PB push_back const int INF = 999; vector<int> v[100]; bool vis[100]; bool f[100]; int search(int now) { // vis[now] = true; int res = 1; for (int i = 0; i < v[now].size(); i++) { vis[now] = true; if (!vis[v[now][i]]) res = max(res, search(v[no...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
331
2
#include <algorithm> #include <cstdio> #include <vector> using namespace std; vector<int> es[100]; int max_length; bool used[100]; void get_max_length(int at_pos, int sum_length) { used[at_pos] = true; for (int i = 0; i < es[at_pos].size(); i++) { int next_pos = es[at_pos][i]; if (used[next_pos]) cont...
#include <algorithm> #include <cstdio> #include <vector> using namespace std; vector<int> es[100]; int max_length; bool used[100]; void get_max_length(int at_pos, int sum_length) { used[at_pos] = true; for (int i = 0; i < es[at_pos].size(); i++) { int next_pos = es[at_pos][i]; if (used[next_pos]) cont...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
260
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool isVisited[101]; int dfs(const vector<vector<int>> &r, int pos) { if (isVisited[pos]) { return 0; } isVisited[pos] = true; int ret = 0; for (int i = 0; i < r[pos].size(); i++) { ret = max(ret, dfs(r, r[pos][i])); ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool isVisited[101]; int dfs(const vector<vector<int>> &r, int pos) { if (isVisited[pos]) { return 0; } isVisited[pos] = true; int ret = 0; for (int i = 0; i < r[pos].size(); i++) { ret = max(ret, dfs(r, r[pos][i])); ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
262
6
#include <algorithm> #include <stdio.h> using namespace std; int N, A, B, v[111], r[111], G[111][222]; int rec(int pos) { int ret = 0; v[pos] = 1; for (int i = 0; i < r[pos]; i++) { if (!v[G[pos][i]]) ret = max(ret, rec(G[pos][i])); } v[pos] = 0; return ret; } int main() { while (scanf("%d", &N)...
#include <algorithm> #include <stdio.h> using namespace std; int N, A, B, v[111], r[111], G[111][222]; int rec(int pos) { int ret = 0; v[pos] = 1; for (int i = 0; i < r[pos]; i++) { if (!v[G[pos][i]]) ret = max(ret, rec(G[pos][i])); } v[pos] = 0; return ret + 1; } int main() { while (scanf("%d",...
[["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
266
4
#include <iostream> #include <vector> using namespace std; int n; vector<int> r[100]; bool ud[100]; int func(int a) { int l = 1; ud[a] = true; for (int j = 0; j < r[a].size(); ++j) { if (!ud[r[a][j]]) { l = max(l, func(r[a][j]) + 1); } } ud[a] = false; return l; } int main() { int f, t, a; ...
#include <iostream> #include <vector> using namespace std; int n; vector<int> r[100]; bool ud[100]; int func(int a) { int l = 1; ud[a] = true; for (int j = 0; j < r[a].size(); ++j) { if (!ud[r[a][j]]) { l = max(l, func(r[a][j]) + 1); } } ud[a] = false; return l; } int main() { int f, t; w...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
259
26
#include <bits/stdc++.h> using namespace std; vector<int> G[101]; bool V[101] = {}; int N; int Ans = 0; void DFS(int n, int len) { Ans = max(Ans, len); bool Vis = false; int S = G[n].size(); for (int i = 0; i < S; i++) { if (!V[G[n][i]]) { Vis = true; V[G[n][i]] = true; DFS(G[n][i], len +...
#include <bits/stdc++.h> using namespace std; vector<int> G[101]; bool V[101] = {}; int N; int Ans = 0; void DFS(int n, int len) { Ans = max(Ans, len); bool Vis = false; int S = G[n].size(); for (int i = 0; i < S; i++) { if (!V[G[n][i]]) { Vis = true; V[G[n][i]] = true; DFS(G[n][i], len +...
[["-", 0, 82, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 82, 8, 9, 0, 7, 15, 16, 12, 13]]
1
317
2
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; vector<int> rinsetu[100]; bool S[100]; int MAX; void saiki(int a, int b) { MAX = max(MAX...
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; vector<int> rinsetu[105]; bool S[105]; int MAX; void saiki(int a, int b) { MAX = max(MAX...
[["-", 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, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
270
8
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define INF 1 << 30 #define LINF 1LL << 60 /* <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0508> ?????????============================================================ ?????????????...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define INF 1 << 30 #define LINF 1LL << 60 /* <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0508> ?????????============================================================ ?????????????...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
1
308
8
#include <cstring> #include <iostream> #include <set> #include <vector> using namespace std; // int node[101][101]; int visit[101]; int ans, last; int die[101]; int flag; void dfs(int now, int cnt, int *st, vector<vector<int>> &vv) { if (cnt > ans) { ans = cnt; last = now; flag = 1; } for (int next ...
#include <cstring> #include <iostream> #include <set> #include <vector> using namespace std; // int node[101][101]; int visit[101]; int ans, last; int die[101]; int flag; void dfs(int now, int cnt, int *st, vector<vector<int>> &vv) { if (cnt > ans) { ans = cnt; last = now; flag = 1; } for (int next ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
402
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; int result; vector<int> strands[100]; bool used[100]; void rec(int k, int d, int ub) { if (result < d) result = d; used[k] = 1; for (int i = 0; i < strands[k].size(); i++) if (!used[strands[k][i]]) ub--; ub++; if ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int result; vector<int> strands[100]; bool used[100]; void rec(int k, int d, int ub) { if (result < d) result = d; used[k] = 1; for (int i = 0; i < strands[k].size(); i++) if (!used[strands[k][i]]) ub--; ub++; if ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
316
4
#include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; int n; vector<int> G[101]; int ans = 0; int mn[101]; bool vis[101]; bool nuse[101]; int INF = 10000; vector<int> group; int dfs(int v) { vis[v] = true; int res = 0; for (int i = 0; i < G[v].size(); i++) { if (vis...
#include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; int n; vector<int> G[101]; int ans = 0; int mn[101]; bool vis[101]; bool nuse[101]; int INF = 10000; vector<int> group; int dfs(int v) { vis[v] = true; int res = 0; for (int i = 0; i < G[v].size(); i++) { if (vis...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
537
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <utility> #include <vector> using namespace std; int N; vector<vector<int>> g; int ans; void dfs(int cur, bool *visited, int len) { for (int n : g[cur]) { if (visited[n]) continue; visited[n] = true; dfs(n, visite...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <utility> #include <vector> using namespace std; int N; vector<vector<int>> g; int ans; void dfs(int cur, bool *visited, int len) { for (int n : g[cur]) { if (visited[n]) continue; visited[n] = true; dfs(n, visite...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
320
2
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (i...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (i...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
498
2
#include <bits/stdc++.h> using namespace std; bool mp[10005][4]; int main() { ios_base::sync_with_stdio(false); int h, n, x, y; for (int i = 0; i < 10005; i++) { for (int j = 0; j < 4; j++) { mp[i][j] = true; } } cin >> h >> n; for (int i = 0; i < n; i++) { cin >> x >> y; mp[y][x] = ...
#include <bits/stdc++.h> using namespace std; bool mp[10005][4]; int main() { ios_base::sync_with_stdio(false); int h, n, x, y; for (int i = 0; i < 10005; i++) { for (int j = 0; j < 4; j++) { mp[i][j] = true; } } cin >> h >> n; for (int i = 0; i < n; i++) { cin >> x >> y; mp[y][x] = ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 106]]
1
475
4
#include <stdio.h> int main(void) { int w, h, n, x[100000], y[100000], Xmax, cnt, flg[100000], kyori, ymax, i; scanf("%d%d%d", &w, &h, &n); Xmax = 0; for (i = 1; i <= n; i++) { scanf("%d%d", &x[i], &y[i]); if (Xmax < x[i]) Xmax = x[i]; } for (i = 1; i <= Xmax; i++) flg[i] = -1; flg[0] = ...
#include <stdio.h> int main(void) { int w, h, n, x[100000], y[100000], Xmax, cnt, flg[100000], kyori, ymax, i; scanf("%d%d%d", &w, &h, &n); Xmax = 0; for (i = 0; i < n; i++) { scanf("%d%d", &x[i], &y[i]); if (Xmax < x[i]) Xmax = x[i]; } for (i = 0; i <= Xmax; i++) flg[i] = -1; flg[0] = 0...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]]
1
260
12
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int w, n, m[100009], ans = 1e8, x, y; main() { cin >> w >> n >> n; r(i, n) { cin >> x >> y; m[x] = max(m[x], y); } r(i, n) m[n - i - 1] = max(m[n - i - 1], m[n - i]); r(i, w - 2) ans = min(ans, i + m[i + 1]); c...
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int w, n, m[100009], ans = 1e8, x, y; main() { cin >> w >> n >> n; r(i, n) { cin >> x >> y; m[x] = max(m[x], y); } r(i, w) m[w - i - 1] = max(m[w - i - 1], m[w - i]); r(i, w) ans = min(ans, i + m[i + 1]); cout ...
[["-", 0, 11, 31, 69, 28, 2, 3, 4, 0, 22], ["+", 0, 11, 31, 69, 28, 2, 3, 4, 0, 22], ["-", 31, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 31, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["-", 0, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 0, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 31, 22], ...
1
138
10
#include <algorithm> #include <cstdlib> #include <ctime> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vecto...
#include <algorithm> #include <cstdlib> #include <ctime> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vecto...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
209
2
#include <bits/stdc++.h> using namespace std; const int inf = 1001001001; int main() { int w, h, n; cin >> w >> h >> n; vector<int> a(h + 1, 0); for (int i = 0; i < n; ++i) { int x, y; cin >> x >> y; a[y] = max(a[y], x); } int ans = inf; for (int i = h; i >= 0; --i) { ans = min(ans, ...
#include <bits/stdc++.h> using namespace std; const int inf = 1001001001; int main() { int w, h, n; cin >> w >> h >> n; vector<int> a(h + 2, 0); for (int i = 0; i < n; ++i) { int x, y; cin >> x >> y; a[y] = max(a[y], x); } int ans = inf; for (int i = h; i >= 0; --i) { ans = min(ans, ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
151
6
#include <algorithm> #include <cmath> #include <iostream> #define rep(i, a, n) for (int i = a; i < n; i++) using namespace std; int w, h, n; int seg[131072 * 2 - 1]; int N; int p(int i) { return (int)((i - 1) / 2); } void update(int i) { if (i == 0) return; if (seg[p(i)] >= seg[i]) return; seg[p(i)] = ...
#include <algorithm> #include <cmath> #include <iostream> #define rep(i, a, n) for (int i = a; i < n; i++) using namespace std; int w, h, n; int seg[131072 * 2 - 1]; int N; int p(int i) { return (int)((i - 1) / 2); } void update(int i) { if (i == 0) return; if (seg[p(i)] >= seg[i]) return; seg[p(i)] = ...
[["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
406
2
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define ll long long #define FOR(i, a, b) for (int i = a; i < b; i++) #define ROF(i, a, b) for (int i = b - 1; i >= a; i--) using namespace std; // const int inf = 1e9 + 7; cons...
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define ll long long #define FOR(i, a, b) for (int i = a; i < b; i++) #define ROF(i, a, b) for (int i = b - 1; i >= a; i--) using namespace std; // const int inf = 1e9 + 7; cons...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19]]
1
1,095
2
#include <algorithm> #include <cfloat> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define MOD 1000000007 #define EPS 0...
#include <algorithm> #include <cfloat> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define MOD 1000000007 #define EPS 0...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 0, 57, 15, 339, 51, 16, 31, 118, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 28, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 118, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 28, 22], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 2...
1
1,121
10
#include <stdio.h> int main(void) { int n, i, j, count, tmp; char s[10000] = {0}, t[10000] = {0}; while (scanf("%d", &n), n) { count = 0; scanf("%s", s); while (n--) { count = 0; for (i = 0; s[i] != '\0'; i++) { for (j = 1; s[i] == s[i + j]; j++) ; tmp = j - 1; ...
#include <stdio.h> int main(void) { int n, i, j, count, tmp; char s[1000000] = {0}, t[1000000] = {0}; while (scanf("%d", &n), n) { count = 0; scanf("%s", s); while (n--) { count = 0; for (i = 0; s[i] != '\0'; i++) { for (j = 1; s[i] == s[i + j - 1]; j++) ; tmp =...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 0, 7, 15, 16, 12, 69, 71, 16, 17, 33], ["+", 0, 7, 15, 16, 12, 69, 71, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
0
326
8
#include <stdio.h> #include <string.h> int main(void) { char str1[10000001], str2[10000001], fig, tmp; int i, n, idx1, idx2, sum; while (1) { scanf("%d", &n); if (!n) break; scanf("%s", str1); for (i = 0; i < n; i++) { idx1 = idx2 = 0; while (1) { if (sscanf(str1 + i...
#include <stdio.h> #include <string.h> int main(void) { char str1[100000], str2[100000], fig, tmp; int i, n, idx1, idx2, sum; while (1) { scanf("%d", &n); if (!n) break; scanf("%s", str1); for (i = 0; i < n; i++) { idx1 = idx2 = 0; while (1) { if (sscanf(str1 + idx1,...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
195
4
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int n; char s[21][1000000]; int main() { int i, j, len; char bef, now; int cnt, cor; while (1) { cin >> n >> s[0]; if (!n) break; for (i = 0; i < n; i++) { len = strlen(s[i]); cnt = 1; cor = 0...
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int n; char s[21][1000000]; int main() { int i, j, len; char bef, now; int cnt, cor; while (1) { cin >> n >> s[0]; if (!n) break; for (i = 0; i < n; i++) { len = strlen(s[i]); cnt = 1; cor = 0...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
227
2
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <math.h> #include <queue> #include <sstream> #include <string> #include <vector> using namespace std; #define FOR(I, N) for (int I = 0; I < (int)(N); I++) #define FIN(V) cout << V << endl #define pb push_back #define INF (1 << 30) ty...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <math.h> #include <queue> #include <sstream> #include <string> #include <vector> using namespace std; #define FOR(I, N) for (int I = 0; I < (int)(N); I++) #define FIN(V) cout << V << endl #define pb push_back #define INF (1 << 30) ty...
[["-", 0, 7, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
248
5
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define rep(i, l, n) for (lint i = l; i < n; i++) #define rer(i, l, n) for (lint i = l; i <= n; i++) #define all(a) a.begin(), a.end() #define o(a) cout << a <...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define rep(i, l, n) for (lint i = l; i < n; i++) #define rer(i, l, n) for (lint i = l; i <= n; i++) #define all(a) a.begin(), a.end() #define o(a) cout << a <...
[["-", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 52, 8, 9, 0, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
336
7
#include <cstring> #include <iostream> #define REP(i, a, n) for (int i = a; i < n; i++) using namespace std; int n; char str[21][10000]; int main(void) { while (cin >> n, n != 0) { cin >> str[0]; REP(i, 0, n) { int j = 0; int k = 0; int len = strlen(str[i]); while (k < len) { ...
#include <cstring> #include <iostream> #define REP(i, a, n) for (int i = a; i < n; i++) using namespace std; int n; char str[21][100000]; int main(void) { while (cin >> n, n != 0) { cin >> str[0]; REP(i, 0, n) { int j = 0; int k = 0; int len = strlen(str[i]); while (k < len) { ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
248
4
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int N; string S; string::iterator CountSeqStr(string::iterator start, string *s, int *n) { *s = *start; *n = 0; string tmp; for (; tmp = *start, tmp == *s && start != S.end(); ++start) { (*n)++; } return --...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int N; string S; string::iterator CountSeqStr(string::iterator start, string *s, int *n) { *s = *start; *n = 0; string tmp; for (; tmp = *start, tmp == *s && start != S.end(); ++start) { (*n)++; } return --...
[["-", 0, 7, 8, 9, 0, 43, 49, 84, 0, 48], ["+", 0, 7, 8, 9, 0, 43, 49, 80, 0, 70], ["+", 0, 7, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 7, 8, 9, 0, 43, 49, 80, 0, 73]]
1
233
4
while True: n=eval(input()) if n==0: break ar=input()+' ' for i in range(n): print(i) cnt=1 tmp='' for i in range(len(ar)-1): if ar[i]==ar[i+1]: cnt+=1 else: tmp+="%d%s"%(cnt,ar[i]) cnt=1 ar=t...
while True: n=eval(input()) if n==0: break ar=input()+' ' for i in range(n): cnt=1 tmp='' for i in range(len(ar)-1): if ar[i]==ar[i+1]: cnt+=1 else: tmp+="%d%s"%(cnt,ar[i]) cnt=1 ar=tmp+' ' print(...
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
108
4
#include <iostream> #include <map> #include <vector> using namespace std; int main() { int n; vector<char> str; while (cin >> n, n) { map<char, char> m; char a, b; for (int i = 0; i < n; i++) { cin >> a >> b; m[a] = b; } cin >> n; for (int i = 0; i < n; i++) { cin >> a;...
#include <iostream> #include <map> #include <vector> using namespace std; int main() { int n; vector<char> str; while (cin >> n, n) { map<char, char> m; char a, b; for (int i = 0; i < n; i++) { cin >> a >> b; m[a] = b; } cin >> n; for (int i = 0; i < n; i++) { cin >> a;...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
171
6
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string s1, s2, tmp, ans; int n, m; while (1) { s1.clear(); s2.clear(); ans.clear(); cin >> n; if (n == 0) return 0; for (int i = 0; i ...
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string s1, s2, tmp, ans; int n, m; while (1) { s1.clear(); s2.clear(); ans.clear(); cin >> n; if (n == 0) return 0; for (int i = 0; i ...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
177
4
#include <iostream> #include <vector> using namespace std; int main(void) { while (1) { int n; cin >> n; if (!n) break; vector<char> v1, v2; for (int i = 0; i < n; i++) { char c; cin >> c; v1.push_back(c); cin >> c; v2.push_back(c); } int m; cin ...
#include <iostream> #include <vector> using namespace std; int main(void) { while (1) { int n; cin >> n; if (!n) break; vector<char> v1, v2; for (int i = 0; i < n; i++) { char c; cin >> c; v1.push_back(c); cin >> c; v2.push_back(c); } int m; cin ...
[["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
1
152
6
#include <iostream> #include <map> using namespace std; int main(void) { map<char, char> chgMap; int num; char in1, in2; int i; while (true) { cin >> num; if (num == 0) { break; } for (i = 0; i < num; i++) { cin >> in1 >> in2; chgMap[in1] = in2; } cin >> num; f...
#include <iostream> #include <map> using namespace std; int main(void) { map<char, char> chgMap; int num; char in1, in2; int i; while (true) { cin >> num; if (num == 0) { break; } chgMap.clear(); for (i = 0; i < num; i++) { cin >> in1 >> in2; chgMap[in1] = in2; } ...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
143
6
#include <algorithm> #include <cstdio> #include <list> using namespace std; int n, m; int main() { while (true) { list<char> map_1; list<char> map_2; list<char>::iterator map; list<char>::iterator map2; scanf("%d", &n); if (n == 0) break; for (int i = 0; i < n; i++) { char a...
#include <algorithm> #include <cstdio> #include <list> using namespace std; int n, m; int main() { while (true) { list<char> map_1; list<char> map_2; list<char>::iterator map; list<char>::iterator map2; scanf("%d", &n); if (n == 0) break; for (int i = 0; i < n; i++) { char a...
[["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
247
7
#include <stdio.h> int main() { int n, m; int i, j; char c[10000000][2]; char t[10000000]; int f; while (scanf("%d", &n), n) { for (i = 0; i < n; i++) { scanf("%s", &c[i][0]); scanf("%s", &c[i][1]); } scanf("%d", &m); for (i = 0; i < m; i++) { scanf(" %s", &t[i]); } ...
#include <stdio.h> int main() { int n, m; int i, j; char c[1000000][2]; char t[1000000]; int f; while (scanf("%d", &n), n) { for (i = 0; i < n; i++) { scanf("%s", &c[i][0]); scanf("%s", &c[i][1]); } scanf("%d", &m); for (i = 0; i < m; i++) { scanf(" %s", &t[i]); } ...
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
246
4
#include <iostream> #include <string> using namespace std; int main() { int n; int c; string d; int m; int e; int f; while (cin >> n) { if (n != 0) { string a[n]; string b[n]; c = 0; while (c < n) { cin >> a[c]; cin >> b[c]; c = c + 1; } ci...
#include <iostream> #include <string> using namespace std; int main() { int n; int c; string d; int m; int e; int f; while (cin >> n) { if (n != 0) { string a[n]; string b[n]; c = 0; while (c < n) { cin >> a[c]; cin >> b[c]; c = c + 1; } ci...
[["+", 0, 57, 64, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
174
4
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #includ...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #includ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
413
1
#include <iostream> #include <map> using namespace std; int main() { int n, m; char a, b; map<char, char> ma; while (cin >> n, n) { for (int i = 0; i < n; i++) { cin >> a >> b; ma[a] = b; } cin >> m; for (int i = 0; i < m; i++) { cin >> a; if (ma[a] != '\0') co...
#include <iostream> #include <map> using namespace std; int main() { int n, m; char a, b; map<char, char> ma; while (cin >> n, n) { ma.clear(); for (int i = 0; i < n; i++) { cin >> a >> b; ma[a] = b; } cin >> m; for (int i = 0; i < m; i++) { cin >> a; if (ma[a] != ...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
122
6