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
#include <stdio.h> void func(int); int main(void) { int n; scanf("%d", &n); while (n != 0) { func(n); scanf("%d", &n); } return 0; } void func(int n) { int xg, yg, x, y; int map[21][21]; int i, j, m, l; char d; int cnt; for (i = 0; i <= 20; i++) { for (j = 0; j <= 20; j++) { m...
#include <stdio.h> void func(int); int main(void) { int n; scanf("%d", &n); while (n != 0) { func(n); scanf("%d", &n); } return 0; } void func(int n) { int xg, yg, x, y; int map[21][21]; int i, j, m, l; char d; int cnt; for (i = 0; i <= 20; i++) { for (j = 0; j <= 20; j++) { ma...
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
0
470
10
#include <stdio.h> #include <string.h> main() { int n, m, x, y, pos[20][20]; int i, j, a, b, c, cnt; int l; char d[2]; while (1) { scanf("%d", &n); if (n == 0) break; memset(pos, 0, sizeof(pos)); cnt = 0; for (i = 0; i < n; i++) { scanf("%d %d", &a, &b); pos[a][b] = 1; ...
#include <stdio.h> #include <string.h> int main() { int n, m, x, y, pos[22][22]; int i, j, a, b, c, cnt; int l; char d[2]; while (1) { scanf("%d", &n); if (n == 0) break; memset(pos, 0, sizeof(pos)); cnt = 0; for (i = 0; i < n; i++) { scanf("%d %d", &a, &b); pos[a][b] = 1...
[["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 30, 0, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
311
6
#include <iostream> using namespace std; int main() { while (true) { bool map[21][21] = {}; int gem, n, get = 0, cx = 10, cy = 10; cin >> gem; if (gem == 0) break; for (int i = 0; i < gem; i++) { int x, y; cin >> x >> y; map[x][y] = true; } cin >> n; for (int i...
#include <iostream> using namespace std; int main() { while (true) { bool map[21][21] = {}; int gem, n, get = 0, cx = 10, cy = 10; cin >> gem; if (gem == 0) break; for (int i = 0; i < gem; i++) { int x, y; cin >> x >> y; map[x][y] = true; } cin >> n; for (int i...
[["-", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
1
236
4
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define REP...
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define REP...
[["-", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["-", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6]]
1
503
4
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; int main() { int k; char d; int a, b; int counter; int robx; int roby; int kari; while (cin >> k) { if (k == 0) { break; } counter = 0; int hyou[20][20] = {0}; int koudou[30][2] = {0}; for (int i...
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; int main() { int k; char d; int a, b; int counter; int robx; int roby; int kari; while (cin >> k) { if (k == 0) { break; } counter = 0; int hyou[30][30] = {0}; int koudou[30][2] = {0}; for (int i...
[["-", 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
435
4
#include <iostream> #include <map> using namespace std; #define N 20 int main(int argc, char const *argv[]) { int f[N][N]; int n, xj, yj; int m, d; char c; int xr, yr; int cnt; map<char, pair<int, int>> mp; mp['N'] = make_pair(0, 1); mp['E'] = make_pair(1, 0); mp['S'] = make_pair(0, -1); mp['...
#include <iostream> #include <map> using namespace std; #define N 21 int main(int argc, char const *argv[]) { int f[N][N]; int n, xj, yj; int m, d; char c; int xr, yr; int cnt; map<char, pair<int, int>> mp; mp['N'] = make_pair(0, 1); mp['E'] = make_pair(1, 0); mp['S'] = make_pair(0, -1); mp['...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
375
2
#include <iostream> using namespace std; class Point { public: int x; int y; }; class Treasure : public Point { public: bool get; Treasure(); }; Treasure::Treasure() { get = false; } int main() { int N; //# of treasure int M; //# of command char direction; int move; // l移動距離 int num; //見つけた宝の数 ...
#include <iostream> using namespace std; class Point { public: int x; int y; }; class Treasure : public Point { public: bool get; Treasure(); }; Treasure::Treasure() { get = false; } int main() { int N; //# of treasure int M; //# of command char direction; int move; //移動距離 int num; //見つけた宝の数 d...
[["-", 0, 82, 8, 9, 0, 7, 15, 16, 17, 98], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 18], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22]]
1
598
4
answers = [] def get_answer(n, m, gems_coordinate, operation_set, answers) visited_coordinate = [] now = [10,10] operation_set.each do |ope| if ope[0] == "N" ope[1].times do now[1] += 1 visited_coordinate << Marshal.load(Marshal.dump(now)) end end if ope[0] == "E" op...
answers = [] def get_answer(n, m, gems_coordinate, operation_set, answers) visited_coordinate = [] now = [10,10] operation_set.each do |ope| if ope[0] == "N" ope[1].times do now[1] += 1 visited_coordinate << Marshal.load(Marshal.dump(now)) end end if ope[0] == "E" op...
[["-", 8, 38, 0, 4, 0, 738, 12, 557, 0, 6], ["+", 8, 38, 0, 4, 0, 738, 12, 557, 0, 6], ["-", 0, 38, 0, 4, 0, 738, 12, 557, 0, 6], ["+", 0, 38, 0, 4, 0, 738, 12, 557, 0, 6]]
4
381
4
n = gets.to_i while n != 0 tmp = [] n.times do tmp.push(gets.split.map(&:to_i)) end m = gets.to_i ans = [] xy_first = [10,10] m.times do dir,val = gets.split(" ") val = val.to_i val.times do flag = 0 if dir == "N" xy_first[1] += 1 elsif dir == "E" xy_first[0] += 1 elsif dir == "S" ...
n = gets.to_i while n != 0 tmp = [] n.times do tmp.push(gets.split.map(&:to_i)) end m = gets.to_i ans = [] xy_first = [10,10] m.times do dir,val = gets.split(" ") val = val.to_i val.times do flag = 0 if dir == "N" xy_first[1] += 1 elsif dir == "E" xy_first[0] += 1 elsif dir == "S" ...
[["+", 8, 736, 0, 121, 64, 749, 0, 652, 486, 22], ["+", 8, 736, 0, 121, 64, 749, 0, 652, 17, 131], ["+", 8, 736, 0, 121, 64, 749, 0, 652, 735, 22]]
4
180
3
while(1): N=int(input()) if N==0: break else: gems=[] okflag=0 loc=[10,10] for i in range(N): [gemx,gemy]=[int(x) for x in input().split()] gems.append([gemx,gemy]) M=int(input()) for i in range(M): com=input().split...
while(1): N=int(input()) if N==0: break else: gems=[] okflag=0 loc=[10,10] for i in range(N): [gemx,gemy]=[int(x) for x in input().split()] gems.append([gemx,gemy]) M=int(input()) for i in range(M): com=input().split...
[["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
309
1
# coding: utf-8 # Here your code ! while True: n = int(input()) if n == 0: break else: posi = [] now = [10,10] for i in range(n): l = list(map(int,input().split())) posi.append(l) n = int(input()) for i in range(n): l = inpu...
# coding: utf-8 # Here your code ! while True: n = int(input()) if n == 0: break else: posi = [] now = [10,10] for i in range(n): l = list(map(int,input().split())) posi.append(l) n = int(input()) for i in range(n): l = inpu...
[["-", 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
321
4
while 1: n=int(input()) if n==0:break x=y=10 b=[list(map(int,input().split())) for _ in range(n)] for i,j in [input().split() for _ in range(int(input()))]: for _ in range(int(j)): if 'N'<=i<='S': y+=1 if i=='N' else -1 else: x+=1 if i=='E' else -1 if [x,y...
while 1: n=int(input()) if n==0:break x=y=10 b=[list(map(int,input().split())) for _ in range(n)] for i,j in [input().split() for _ in range(int(input()))]: for _ in range(int(j)): if 'N'<=i<='S': y+=1 if i=='N' else -1 else: x+=1 if i=='E' else -1 if [x,y...
[["-", 0, 652, 3, 4, 0, 206, 206, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 206, 206, 652, 63, 22]]
5
164
2
while True: n = int(input()) if n == 0: break p = [10, 10] l = [list(map(int,input().split())) for _ in range(n)] for d,s in [input.split() for _ in range(int(input()))]: for _ in range(s): if d == 'N': p[1] += 1 elif d == 'E': ...
while True: n = int(input()) if n == 0: break p = [10, 10] l = [list(map(int,input().split())) for _ in range(n)] for d,s in [input().split() for _ in range(int(input()))]: for _ in range(int(s)): if d == 'N': p[1] += 1 elif d == 'E': ...
[["+", 8, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 8, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 7, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
168
5
import java.io.*; import java.util.*; public class Main { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); class State implements Comparable<State> { int h, p, q; State(int h, int p, int q) { this.h = h; this.p = p; this.q = q; } pu...
import java.io.*; import java.util.*; public class Main { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); class State implements Comparable<State> { int h, p, q; State(int h, int p, int q) { this.h = h; this.p = p; this.q = q; } pu...
[["-", 0, 7, 8, 196, 0, 503, 49, 200, 141, 22], ["+", 0, 7, 8, 196, 0, 503, 49, 200, 141, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95]]
3
985
5
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a; while (cin >> n >> m >> a) { if (n == 0 && m == 0 && a == 0) { break; } int v[1010][110]; for (int i = 0; i < m; i++) { int h, p, q; cin >> h >> p >> q; v[h][p] = q, v[h][q] = p; } for (int i = 10...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a; while (cin >> n >> m >> a) { if (n == 0 && m == 0 && a == 0) { break; } int v[1010][110] = {0}; for (int i = 0; i < m; i++) { int h, p, q; cin >> h >> p >> q; v[h][p] = q, v[h][q] = p; } for (int ...
[["+", 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, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
1
151
4
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { while (1) { int n, m, a; cin >> n >> m >> a; if (!n) break; vector<tuple<int, int, int>> v; REP(i, m) { ...
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { while (1) { int n, m, a; cin >> n >> m >> a; if (!n) break; vector<tuple<int, int, int>> v; REP(i, m) { ...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
193
2
#include <algorithm> #include <iostream> #include <stdio.h> #include <tuple> #include <vector> using namespace std; int main() { int n, m, a; while (scanf("%d%d%d", &n, &m, &a) != EOF && n) { vector<tuple<int, int, int>> ami; for (int i = 0; i < n; i++) { int h, p, q; scanf("%d%d%d", &h, &p, &...
#include <algorithm> #include <iostream> #include <stdio.h> #include <tuple> #include <vector> using namespace std; int main() { int n, m, a; while (scanf("%d%d%d", &n, &m, &a) != EOF && n) { vector<tuple<int, int, int>> ami; for (int i = 0; i < m; i++) { int h, p, q; scanf("%d%d%d", &h, &p, &...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
244
2
#include <algorithm> #include <bitset> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #in...
#include <algorithm> #include <bitset> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #in...
[["-", 0, 9, 0, 42, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
464
5
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a; while (cin >> n >> m >> a && (n || m || a)) { vector<pair<int, pair<int, int>>> v; int h, p, q; for (int i = 0; i < m; i++) { cin >> h >> p >> q; v.push_back(make_pair(h, make_pair(p, q))); } sort(v.rbegin()...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a; while (cin >> n >> m >> a && (n || m || a)) { vector<pair<int, pair<int, int>>> v; int h, p, q; for (int i = 0; i < m; i++) { cin >> h >> p >> q; v.push_back(make_pair(h, make_pair(p, q))); } sort(v.rbegin()...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
194
2
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i, a, b) fo...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i, a, b) fo...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
270
2
#include <algorithm> #include <iostream> #include <utility> //#include <functional> //#include <boost/foreach.hpp> using namespace std; int main() { pair<int, pair<int, int>> pai[1001]; int n, m, a, t, y1, y2; while (1) { cin >> n >> m >> a; if (n == 0) break; for (int i = 0; i < m; i++) { //横棒...
#include <algorithm> #include <iostream> #include <utility> //#include <functional> //#include <boost/foreach.hpp> using namespace std; int main() { pair<int, pair<int, int>> pai[1001]; int n, m, a, t, y1, y2; while (1) { cin >> n >> m >> a; if (n == 0) break; for (int i = 0; i < m; i++) { //?¨...
[["-", 12, 118, 28, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 118, 28, 118, 28, 69, 341, 342, 0, 22]]
1
217
4
#include <cstdio> #include <iostream> using namespace std; int main() { int n, m, a; int yoko[3][100]; int i, j; while (1) { cin >> n >> m >> a; if (n == 0 && m == 0 && a == 0) break; for (i = 0; i < m; i++) { cin >> yoko[0][i] >> yoko[1][i] >> yoko[2][i]; } for (i = m; i > 0;...
#include <cstdio> #include <iostream> using namespace std; int main() { int n, m, a; int yoko[3][1000]; int i, j; while (1) { cin >> n >> m >> a; if (n == 0 && m == 0 && a == 0) break; for (i = 0; i < m; i++) { cin >> yoko[0][i] >> yoko[1][i] >> yoko[2][i]; } for (i = 1000; i ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13]]
1
203
4
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) struct boad { int high, a, b; bool operator<(const boad &a) const { return this->high > a.high; } }; int main() { int n, m, a;...
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) struct boad { int high, a, b; bool operator<(const boad &a) const { return this->high > a.high; } }; int main() { int n, m, a;...
[["+", 0, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 0, 9, 0, 57, 64, 9, 0, 116, 0, 35], ["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]]
1
203
4
#include <iostream> #include <vector> using namespace std; vector<int> ans; int main() { while (1) { int n, m, a; cin >> n >> m >> a; if (n + m + a == 0) break; int root[1001][101]; for (int i = 0; i < 1001; i++) { for (int j = 0; j < 101; j++) { root[i][j] = 0; } ...
#include <iostream> #include <vector> using namespace std; vector<int> ans; int main() { while (1) { int n, m, a; cin >> n >> m >> a; if (n + m + a == 0) break; int root[1001][101]; for (int i = 0; i < 1001; i++) { for (int j = 0; j < 101; j++) { root[i][j] = 0; } ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
235
2
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include ...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
215
2
#include <stdio.h> int main() { int n, m, a, h, p, q; while (scanf("%d%d%d", &n, &m, &a), n) { int l[1001][101] = {0}; while (m--) { scanf("%d%d%d", &h, &p, &q); l[h][p] = q; l[h][q] = p; } for (h = n; h > 0; --h) if (l[h][a]) a = l[h][a]; printf("%d\n", a); } ...
#include <stdio.h> int main() { int n, m, a, h, p, q; while (scanf("%d%d%d", &n, &m, &a), n) { int l[1001][101] = {0}; while (m--) { scanf("%d%d%d", &h, &p, &q); l[h][p] = q; l[h][q] = p; } for (h = 1000; h > 0; --h) if (l[h][a]) a = l[h][a]; printf("%d\n", a); ...
[["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13]]
1
145
2
#include <algorithm> #include <iostream> using namespace std; struct Line { int h, p, q; }; bool CmpLine(const Line &l, const Line &r) { return (l.h > r.h); } int main(void) { while (1) { int n, m, a; cin >> n >> m >> a; if (n == 0 && m == 0 && a == 0) break; Line *l = new Line[m]; for...
#include <algorithm> #include <iostream> using namespace std; struct Line { int h, p, q; }; bool CmpLine(const Line &l, const Line &r) { return (l.h > r.h); } int main(void) { while (1) { int n, m, a; cin >> n >> m >> a; if (n == 0 && m == 0 && a == 0) break; Line *l = new Line[m]; fo...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
266
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; struct SideLine { int h; int l; int r; }; bool myless(const SideLine &l, const SideLine &r) { ret...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; struct SideLine { int h; int l; int r; }; bool myless(const SideLine &l, const SideLine &r) { ret...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22]]
1
272
2
#include <bits/stdc++.h> using namespace std; struct bar { int h, p, q; bool operator>(const bar &b) const { return h > b.h; } }; int main() { int n, m, a; while (cin >> n >> m >> a) { vector<bar> v; for (int i = 0; i < m; i++) { bar b; cin >> b.h >> b.p >> b.q; v.push_back(b); }...
#include <bits/stdc++.h> using namespace std; struct bar { int h, p, q; bool operator>(const bar &b) const { return h > b.h; } }; int main() { int n, m, a; while (cin >> n >> m >> a, n + m + a) { vector<bar> v; for (int i = 0; i < m; i++) { bar b; cin >> b.h >> b.p >> b.q; v.push_bac...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 31, 22], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 17, 72], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 12, 22], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 72], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 12, 22]]
1
197
6
loop do n, m, a = gets.split.map(&:to_i) break if n == 0 && m == 0 && a == 0 d = m.times.map{gets.split.map(&:to_i)} d.sort! { |a, b| b[0] <=> a[0]} pos = 1 d.each do |dd| if dd[1] == pos pos = dd[2] elsif dd[2] == pos pos = dd[1] end end p...
loop do n, m, a = gets.split.map(&:to_i) break if n == 0 && m == 0 && a == 0 d = m.times.map{gets.split.map(&:to_i)} d.sort! { |a, b| b[0] <=> a[0]} pos = a d.each do |dd| if dd[1] == pos pos = dd[2] elsif dd[2] == pos pos = dd[1] end end p...
[["-", 0, 652, 196, 737, 8, 736, 0, 662, 12, 612], ["+", 0, 652, 196, 737, 8, 736, 0, 662, 12, 22]]
4
108
2
### constant MAX_H = 1000 ### main loop do n, m, a = gets.split.map(&:to_i) break if n == 0 hls = Array.new(n + 1){Array.new(MAX_H + 1){0}} maxh = 0 n.times do h, pi, qi = gets.split.map(&:to_i) hls[pi][h] = qi hls[qi][h] = pi maxh = h if maxh < h end x = a y = maxh while y >=...
### constant MAX_H = 1000 ### main loop do n, m, a = gets.split.map(&:to_i) #p [n, m, a] break if n == 0 hls = Array.new(n + 1){Array.new(MAX_H + 1){0}} maxh = 0 m.times do h, pi, qi = gets.split.map(&:to_i) #p [h, pi, qi] hls[pi][h] = qi hls[qi][h] = pi maxh = h if maxh < h en...
[["-", 0, 652, 196, 737, 8, 736, 0, 652, 486, 22], ["+", 0, 652, 196, 737, 8, 736, 0, 652, 486, 22]]
4
134
2
import itertools while True: n, m, a = map(int, input().split()) if (n,m,a) == (0,0,0): break hpq = [list(map(int, input().split())) for i in range(m)] hpq = sorted(hpq, reverse=True) for k, g in itertools.groupby(hpq, key=lambda x:x[0]): for gg in g: if a == gg[1]: a = gg[2] break elif a == gg[...
import itertools while True: n, m, a = map(int, input().split()) if (n,m,a) == (0,0,0): break hpq = [list(map(int, input().split())) for i in range(m)] hpq = sorted(hpq, reverse=True) for k, g in itertools.groupby(hpq, key=lambda x:x[0]): for gg in g: if a == gg[1]: a = gg[2] break elif a == gg[...
[["-", 75, 665, 64, 196, 0, 1, 0, 666, 667, 60], ["+", 75, 665, 64, 196, 0, 1, 0, 662, 0, 32]]
5
138
2
#include <bits/stdc++.h> using namespace std; using T = int; const T id = INT_MAX; T op(T l, T r) { return min(l, r); } using COL = bool; const COL RED = false, BLACK = true; struct node { COL color; int size; int level; T val, all; node *p, *ch[2]; node() : color(BLACK), size(0), level(0), val(id)...
#include <bits/stdc++.h> using namespace std; using T = int; const T id = INT_MAX; T op(T l, T r) { return min(l, r); } using COL = bool; const COL RED = false, BLACK = true; struct node { COL color; int size; int level; T val, all; node *p, *ch[2]; node() : color(BLACK), size(0), level(0), val(id)...
[["-", 3, 4, 0, 2, 3, 4, 0, 118, 119, 120], ["+", 3, 4, 0, 2, 3, 4, 0, 118, 119, 120], ["-", 0, 11, 12, 2, 3, 4, 0, 118, 119, 120], ["+", 0, 11, 12, 2, 3, 4, 0, 118, 119, 120], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21]]
1
1,863
7
#include <bits/stdc++.h> using namespace std; using Int = long long; // BEGIN CUT HERE template <typename T, typename E> struct RBST { int xor128() { static int x = 123456789; static int y = 362436069; static int z = 521288629; static int w = 88675123; int t; t = x ^ (x << 11); x = y; ...
#include <bits/stdc++.h> using namespace std; using Int = long long; // BEGIN CUT HERE template <typename T, typename E> struct RBST { int xor128() { static int x = 123456789; static int y = 362436069; static int z = 521288629; static int w = 88675123; int t; t = x ^ (x << 11); x = y; ...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22]]
1
3,086
2
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; inline int xor32() { static int y = 2463534242; y = y ^ (y << 13); y = y ^ (y >> 17); return (y = y ^ (y << 5)); } struct Node { int Value; int SubTreeSize; Node *Lch, *Rch; int RMQ; Node(int V) : Value(V), SubTreeSize(1), RMQ(...
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; inline int xor32() { static int y = 2463534242; y = y ^ (y << 13); y = y ^ (y >> 17); return (y = y ^ (y << 5)); } struct Node { int Value; int SubTreeSize; Node *Lch, *Rch; int RMQ; Node(int V) : Value(V), SubTreeSize(1), RMQ(...
[["-", 0, 14, 0, 357, 0, 358, 0, 4, 0, 22], ["+", 0, 14, 0, 357, 0, 358, 0, 4, 0, 22], ["-", 15, 339, 51, 16, 31, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 16, 31, 2, 63, 22]]
1
1,049
4
#include <stdio.h> const int INF = 1e9 + 10; long long int now = 1234819384719LL; bool rand(int a, int b) { now ^= 1932847192384LL; now += 1293419328471LL; now %= (a + b); return now >= b; } int min(int a, int b) { return a < b ? a : b; } struct node { node *l; node *r; int val; int top; int size; n...
#include <stdio.h> const int INF = 1e9 + 10; long long int now = 1234819384719LL; bool rand(int a, int b) { now ^= 1932847192384LL; now += 1293419328471LL; now %= (a + b); return now >= b; } int min(int a, int b) { return a < b ? a : b; } struct node { node *l; node *r; int val; int top; int size; n...
[["-", 3, 4, 0, 2, 3, 4, 0, 118, 119, 120], ["+", 3, 4, 0, 2, 3, 4, 0, 118, 119, 120]]
1
1,083
2
#include <algorithm> #include <cassert> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; struct STree { typedef ll D; const static D INF = 1LL << 55; struct Node; typede...
#include <algorithm> #include <cassert> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; struct STree { typedef ll D; const static D INF = 1LL << 55; struct Node; typede...
[["-", 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, 7, 8, 9, 0, 1, 0, 35]]
1
1,243
6
#include <algorithm> #include <climits> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <string> #include <vector> #define INF 10000000001 using namespace std; typedef long long ll; template <class T> struct Treap { public: struct node_t { T val, mini, sum, lazy; node_t ...
#include <algorithm> #include <climits> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <string> #include <vector> #define INF 10000000001 using namespace std; typedef long long ll; template <class T> struct Treap { public: struct node_t { T val, mini, sum, lazy; node_t ...
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
1,775
4
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; #define int long long #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0, a1, a2, a3, x, ...) x #define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal) #define REP2(i, s, n) REP1(i, s, < signed(n), ++) #define REP3(i, n) REP2(i,...
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; #define int long long #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0, a1, a2, a3, x, ...) x #define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal) #define REP2(i, s, n) REP1(i, s, < signed(n), ++) #define REP3(i, n) REP2(i,...
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13]]
1
1,264
2
#include <algorithm> #include <cstdlib> #include <fstream> #include <iostream> using namespace std; const int INF = 1 << 30; class Treap { public: struct node_t { int val; // 値 node_t *lch, *rch; // l,r int pri; // 優先度 int cnt; // 部分木のサイズ int sum; // 部分木の値の...
#include <algorithm> #include <cstdlib> #include <fstream> #include <iostream> using namespace std; const int INF = 1 << 30; class Treap { public: struct node_t { int val; // 値 node_t *lch, *rch; // l,r int pri; // 優先度 int cnt; // 部分木のサイズ int sum; // 部分木の値の...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]]
1
1,044
2
main(r, T, a, b, c, d, e, A, B, C) { for (; scanf("%d%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &A, &B, &C) > 7; printf("%d\n", r)) { r = a * A + b * B + c * C; if (C >= d) { if (r > a * A + b * B + e * C) r = a * A + b * B + e * C; } else { if (r > a * A + b * B + e * d) r = ...
main(r, T, a, b, c, d, e, A, B, C) { for (; scanf("%d%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &A, &B, &C) > 7; printf("%d\n", r)) { r = a * A + b * B + c * C; if (C >= d) { if (r > a * A + b * B + e * C) r = a * A + b * B + e * C; } else { if (r > a * A + b * B + e * d) r = ...
[["-", 64, 1, 0, 11, 12, 16, 12, 16, 12, 22], ["+", 64, 1, 0, 11, 12, 16, 12, 16, 12, 22]]
0
285
2
#define R(x) \ if (r > x) \ r = x; main(r, T, a, b, c, d, e, A, B, C) { for (; scanf("%d%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &A, &B, &C) > 7; printf("%d\n", r)) { r = a ...
#define R(x) \ if (r > x) \ r = x; main(r, T, a, b, c, d, e, A, B, C) { for (; scanf("%d%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &A, &B, &C) > 7; printf("%d\n", r)) { r = a ...
[["+", 75, 76, 0, 9, 0, 57, 75, 76, 0, 95]]
0
211
1
#define R(x) \ if (r > x) \ r = x; main(r, D, t, a, b, c, d, e, A, B, C) { for (; scanf("%d%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &A, &B, &C) > 7; printf("%d\n", r)) { if ...
#define R(x) \ if (r > x) \ r = x; main(r, D, t, a, b, c, d, e, A, B, C) { for (; scanf("%d%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &A, &B, &C) > 7; printf("%d\n", r)) { if ...
[["-", 12, 34, 31, 11, 12, 41, 15, 16, 31, 22], ["+", 12, 34, 31, 11, 12, 41, 15, 16, 31, 22], ["-", 12, 34, 12, 34, 31, 11, 12, 41, 64, 22], ["+", 12, 34, 12, 34, 31, 11, 12, 41, 64, 22], ["-", 12, 34, 12, 34, 12, 34, 31, 11, 31, 22], ["+", 12, 34, 12, 34, 12, 34, 31, 11, 31, 22]]
0
183
12
#include <algorithm> #include <iostream> #include <string> using namespace std; typedef basic_string<int> IS; int main() { for (int a, b, c, d, e, na, nb, nc; cin >> a >> b >> c >> d >> e >> na >> nb >> nc, a;) { IS is = IS(nc, c) + IS(nb, b) + IS(na, a); int m, cs = a * na + b * nb + c * nc; m ...
#include <algorithm> #include <iostream> #include <string> using namespace std; typedef basic_string<int> IS; int main() { for (int a, b, c, d, e, na, nb, nc; cin >> a >> b >> c >> d >> e >> na >> nb >> nc, a;) { IS is = IS(nc, c) + IS(nb, b) + IS(na, a); int m, cs = a * na + b * nb + c * nc; m ...
[["+", 12, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 12, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
1
161
2
#include <algorithm> #include <iostream> #include <vector> using namespace std; int a, b, c, d, e; int na, nb, nc; int main() { while (cin >> a >> b >> c >> d >> e && (a | b | c | d | e)) { cin >> na >> nb >> nc; if (nc >= d) { cout << e * d + na * a + nb * b << endl; } else { int cost = ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int a, b, c, d, e; int na, nb, nc; int main() { while (cin >> a >> b >> c >> d >> e && (a | b | c | d | e)) { cin >> na >> nb >> nc; if (nc >= d) { cout << e * nc + na * a + nb * b << endl; } else { int cost =...
[["-", 31, 16, 12, 16, 31, 16, 31, 16, 12, 22], ["+", 31, 16, 12, 16, 31, 16, 31, 16, 12, 22]]
1
217
2
#include <algorithm> #include <cstdint> #include <cstdio> #define fprintf(...) (void)0 int testcase_ends() { intmax_t a, b, c, d, e; scanf("%jd%jd%jd%jd%jd", &a, &b, &c, &d, &e); if (a == 0) return 1; intmax_t na, nb, nc; scanf("%jd%jd%jd", &na, &nb, &nc); intmax_t res = na * a + nb * b + nc * c; ...
#include <algorithm> #include <cstdint> #include <cstdio> #define fprintf(...) (void)0 int testcase_ends() { intmax_t a, b, c, d, e; scanf("%jd%jd%jd%jd%jd", &a, &b, &c, &d, &e); if (a == 0) return 1; intmax_t na, nb, nc; scanf("%jd%jd%jd", &na, &nb, &nc); intmax_t res = na * a + nb * b + nc * c; ...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
1
490
1
#include <algorithm> #include <stdio.h> using namespace std; int b[6][6]; int c[6]; int n; int t[6][6]; int v[6][6]; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int f[6][6]; int calc() { int ret = 0; int s = 1; for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) v[i][j] = t[i][j]; bool chg...
#include <algorithm> #include <stdio.h> using namespace std; int b[6][6]; int c[6]; int n; int t[6][6]; int v[6][6]; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int f[6][6]; int calc() { int ret = 0; int s = 1; for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) v[i][j] = t[i][j]; bool chg...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
1
1,057
4
#include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int n; int a[5][5]; int s[5]; int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1}; int check(void) { int res = 0; for (int d = 1;; d++) { bool dis[5][5], f = false; rep(i, 5) rep(j, 5) dis[i][j] = false; rep(i, 5) rep(j...
#include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int n; int a[5][5]; int s[5]; int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1}; int check(void) { int res = 0; for (int d = 1;; d++) { bool dis[5][5], f = false; rep(i, 5) rep(j, 5) dis[i][j] = false; rep(i, 5) rep(j...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
1
775
2
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); ++i) using namespace std; typedef long long LL; typedef pair<LL, int> P; inline LL eval(P p, const vector<LL> &sum, LL C) { return p.first + sum[p.second] - C; } inline int lower_bound(LL l, const deque<P> &s, const vector<LL> &sum, LL C) { i...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); ++i) using namespace std; typedef long long LL; typedef pair<LL, int> P; inline LL eval(P p, const vector<LL> &sum, LL C) { return p.first + sum[p.second] - C; } inline int lower_bound(LL l, const deque<P> &s, const vector<LL> &sum, LL C) { i...
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
637
4
#include "bits/stdc++.h" using namespace std; typedef int Value1; typedef pair<bool, int> Value2; const Value1 Zero1(0); const Value2 Zero2(make_pair(false, 0)); struct Node { Value1 sum; //??´??°????????????. //?????????????????§??????????????????????????¨????????????????????????????????????. Va...
#include "bits/stdc++.h" using namespace std; typedef int Value1; typedef pair<bool, int> Value2; const Value1 Zero1(0); const Value2 Zero2(make_pair(false, 0)); struct Node { Value1 sum; //??´??°????????????. //?????????????????§??????????????????????????¨????????????????????????????????????. Va...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13]]
1
1,746
2
import java.util.*; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); boolean fi = true; while (true) { int a = stdIn.nextInt(); if (a == 0) break; if (!fi) { System.out.println(); } else { fi = false; ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); boolean fi = true; while (true) { int a = stdIn.nextInt(); if (a == 0) break; if (!fi) { System.out.println(); } else { fi = false; ...
[["-", 0, 52, 8, 196, 0, 503, 49, 200, 51, 499], ["+", 0, 52, 8, 196, 0, 503, 49, 200, 51, 499]]
3
549
2
import java.io.*; import java.util.*; public class Main { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int[] VAL = {10, 50, 100, 500}; int calc(int x) { if (x < 0) return Integer.MAX_VALUE; int res = 0; for (int i = 3; i >= 0; i--) { whi...
import java.io.*; import java.util.*; public class Main { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int[] VAL = {10, 50, 100, 500}; int calc(int x) { if (x < 0) return Integer.MAX_VALUE; int res = 0; for (int i = 3; i >= 0; i--) { whi...
[["-", 0, 57, 15, 15, 0, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 17, 20]]
3
1,122
2
import java.util.*; public class Main { int[] table = {10, 50, 100, 500}; private void doit() { Scanner sc = new Scanner(System.in); boolean isfirst = true; while (true) { int value = sc.nextInt(); if (value == 0) break; if (isfirst) { isfirst = false; } else {...
import java.util.*; public class Main { int[] table = {10, 50, 100, 500}; private void doit() { Scanner sc = new Scanner(System.in); boolean isfirst = true; while (true) { int value = sc.nextInt(); if (value == 0) break; if (isfirst) { isfirst = false; } else {...
[["+", 49, 200, 51, 16, 31, 16, 12, 23, 0, 24], ["+", 49, 200, 51, 16, 31, 16, 12, 23, 0, 25]]
3
493
2
#include <algorithm> #include <iostream> #include <stdexcept> #include <tuple> #include <utility> #include <vector> using namespace std; int main() { int m; vector<tuple<int, int, int, int>> answer; while (cin >> m && m != 0) { tuple<int, int, int, int> coin; // = {0, 0, 0, 0}; get<0>(coin) = 0; get<...
#include <algorithm> #include <iostream> #include <stdexcept> #include <tuple> #include <utility> #include <vector> using namespace std; int main() { int m; vector<tuple<int, int, int, int>> answer; while (cin >> m && m != 0) { tuple<int, int, int, int> coin; // = {0, 0, 0, 0}; get<0>(coin) = 0; get<...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
562
2
#include <iostream> using namespace std; int main() { int siharai; bool flag = false; while (cin >> siharai, siharai) { if (flag) { cout << endl; } else { flag = true; } int money[4]; cin >> money[0] >> money[1] >> money[2] >> money[3]; int all; all = money[0] * 10 + mone...
#include <iostream> using namespace std; int main() { int siharai; bool flag = false; while (cin >> siharai, siharai) { if (flag) { cout << endl; } else { flag = true; } int money[4]; cin >> money[0] >> money[1] >> money[2] >> money[3]; int all; all = money[0] * 10 + mone...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
358
2
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { bool old = false; while (1) { int n; cin >> n; if (!n) break; int a, b, c, d; cin >> a >> b >> c >> d; i...
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { bool old = false; while (1) { int n; cin >> n; if (!n) break; int a, b, c, d; cin >> a >> b >> c >> d; i...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
394
2
#include <iostream> #include <map> using namespace std; const int INF = 1 << 25; int c[] = {10, 50, 100, 500}; int main() { int n, a = 0; while (cin >> n && n) { if (a != 0) cout << endl; int s[4], csum = 0; for (int i = 0; i < 4; ++i) { cin >> s[i]; csum += s[i]; } int an...
#include <iostream> #include <map> using namespace std; const int INF = 1 << 25; int c[] = {10, 50, 100, 500}; int main() { int n, a = 0; while (cin >> n && n) { if (a != 0) cout << endl; int s[4], csum = 0; for (int i = 0; i < 4; ++i) { cin >> s[i]; csum += s[i]; } int an...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
477
2
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; bool f = false; vector<int> money = {10, 50, 100, 500}; while (std::cin >> n, n) { if (f) std::cout << std::endl; f = true; vector<int> a(4); for (int i = 0; i < 4; i++) std::cin >> ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; bool f = false; vector<int> money = {10, 50, 100, 500}; while (std::cin >> n, n) { if (f) std::cout << std::endl; f = true; vector<int> a(4); for (int i = 0; i < 4; i++) std::cin >> ...
[["-", 31, 16, 31, 16, 31, 16, 12, 69, 28, 22], ["+", 31, 16, 31, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]]
1
230
4
#include <algorithm> #include <iostream> using namespace std; int s[4] = {10, 50, 100, 500}; int n, t[4], u[4], maxm, ans[4]; int calc(int x) { int res = 0; for (int i = 3; i >= 0; i--) { res += x / s[i]; x %= s[i]; } return res; } void solve(int pos, int cnt, int sum) { if (pos == 4) { if (sum...
#include <algorithm> #include <iostream> using namespace std; int s[4] = {10, 50, 100, 500}; int n, t[4], u[4], maxm, ans[4]; int calc(int x) { int res = 0; for (int i = 3; i >= 0; i--) { res += x / s[i]; x %= s[i]; } return res; } void solve(int pos, int cnt, int sum) { if (pos == 4) { if (sum...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 91, 17, 33], ["+", 0, 1, 0, 11, 12, 91, 28, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 91, 28, 23, 0, 13], ["+", 0, 1, 0, 11, 12, 91, 28, 23, 0, 25]]
1
329
5
#include <iostream> #include <vector> #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef vector<int> sequence; sequence shop(int value) { sequence seq(4); seq[0] = value / 500; value -= 500 * seq[0]; seq[1] = value / 100; value -= 100 * seq[1]; seq[2] = value / 50; value -...
#include <iostream> #include <vector> #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef vector<int> sequence; sequence shop(int value) { sequence seq(4); seq[0] = value / 500; value -= 500 * seq[0]; seq[1] = value / 100; value -= 100 * seq[1]; seq[2] = value / 50; value -...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
278
2
#include <bits/stdc++.h> using namespace std; int main() { int coins[4] = {10, 50, 100, 500}; int price; bool flag = true; while (true) { scanf("%d", &price); if (price == 0) { break; } int have_coins[4]; int sum = 0; for (int i = 0; i < 4; i++) { scanf("%d", &have_coin...
#include <bits/stdc++.h> using namespace std; int main() { int coins[4] = {10, 50, 100, 500}; int price; bool flag = true; while (true) { scanf("%d", &price); if (price == 0) { break; } int have_coins[4]; int sum = 0; for (int i = 0; i < 4; i++) { scanf("%d", &have_coin...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
225
2
#include <bits/stdc++.h> using namespace std; const int coin[] = {10, 50, 100, 500}; int main(void) { int pay; int flg = false; while (cin >> pay, pay) { if (flg) cout << endl; flg = true; int noc[4]; int noc_org[4]; for (int i = 0; i < 4; i++) { int t; cin >> t; noc[i...
#include <bits/stdc++.h> using namespace std; const int coin[] = {10, 50, 100, 500}; int main(void) { int pay; int flg = false; while (cin >> pay, pay) { if (flg) cout << endl; flg = true; int noc[4]; int noc_org[4]; for (int i = 0; i < 4; i++) { int t; cin >> t; noc[i...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
280
2
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <stack> #include <stdlib.h> #include <string> using namespace std; int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1}; int dy[8] = {0, 0, 1, -1, -1, 1, -1, 1}; int main() { int n; cin >> n; while (1) { int a[4] = {0}; int b[4] = {...
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <stack> #include <stdlib.h> #include <string> using namespace std; int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1}; int dy[8] = {0, 0, 1, -1, -1, 1, -1, 1}; int main() { int n; cin >> n; while (1) { int a[4] = {0}; int b[4] = {...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85]]
1
371
4
#include <algorithm> #include <iostream> using namespace std; const int INF = (1 << 21); int coin_num[4], tmp_coin_num[4], ans_coin_num[4], pay_coin_num[4]; int coins[4] = {10, 50, 100, 500}; void calc_change(int res) { for (int i = 3; i >= 0; i--) { while (res >= coins[i]) { res -= coins[i]; tmp_co...
#include <algorithm> #include <iostream> using namespace std; const int INF = (1 << 21); int coin_num[4], tmp_coin_num[4], ans_coin_num[4], pay_coin_num[4]; int coins[4] = {10, 50, 100, 500}; void calc_change(int res) { for (int i = 3; i >= 0; i--) { while (res >= coins[i]) { res -= coins[i]; tmp_co...
[["-", 8, 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, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13]]
1
496
5
#include <bits/stdc++.h> using namespace std; // define #define ALL(a) a.begin(), a.end() #define REP(i, n) for (int i = 0; i < n; i++) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define debug(x) \ if (0) ...
#include <bits/stdc++.h> using namespace std; // define #define ALL(a) a.begin(), a.end() #define REP(i, n) for (int i = 0; i < n; i++) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define debug(x) \ if (0) ...
[["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 33], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 72], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40]]
1
484
3
#include <bits/stdc++.h> using namespace std; int cn[4] = {10, 50, 100, 500}; int cc[4]; int ca[4]; int getcc(int aa) { int res = 0; for (int i = 3; i >= 0; i--) { cc[i] = aa / cn[i]; aa %= cn[i]; res += cc[i]; } return res; } int main() { int c[4]; int ans; int n; cin >> n; while (1) {...
#include <bits/stdc++.h> using namespace std; int cn[4] = {10, 50, 100, 500}; int cc[4]; int ca[4]; int getcc(int aa) { int res = 0; for (int i = 3; i >= 0; i--) { cc[i] = aa / cn[i]; aa %= cn[i]; res += cc[i]; } return res; } int main() { int c[4]; int ans; int n; cin >> n; while (1) {...
[["-", 51, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 51, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
1
445
2
#include <bits/stdc++.h> using namespace std; int main() { int coun = 0; while (1) { int n; int ma = 10000000; cin >> n; if (n == 0) break; if (coun) cout << endl; coun++; int a[4]; int co = 0; for (int i = 0; i < 4; i++) { cin >> a[i]; co += a[i]; } ...
#include <bits/stdc++.h> using namespace std; int main() { int coun = 0; while (1) { int n; int ma = 10000000; cin >> n; if (n == 0) break; if (coun) cout << endl; coun++; int a[4]; int co = 0; for (int i = 0; i < 4; i++) { cin >> a[i]; co += a[i]; } ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85]]
1
415
2
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a; i...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a; i...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
464
2
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; int main() { int a; int b = 0; while (cin >> a, a) { if (b) cout << endl; int b, c, d, e; scanf("%d%d%d%d", &b...
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; int main() { int a; int p = 0; while (cin >> a, a) { if (p) cout << endl; int b, c, d, e; scanf("%d%d%d%d", &b...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 52, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 51, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22]]
1
505
6
#include <algorithm> #include <assert.h> #include <iostream> #include <math.h> #include <queue> #include <stdio.h> #include <string.h> #include <vector> using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; static const double EPS = 1e-9; static const double PI = acos(-1...
#include <algorithm> #include <assert.h> #include <iostream> #include <math.h> #include <queue> #include <stdio.h> #include <string.h> #include <vector> using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; static const double EPS = 1e-9; static const double PI = acos(-1...
[["+", 64, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
1,217
5
#include <stdio.h> int MIN(int a, int b) { return a < b ? a : b; } int main() { int n, m, s, t, u, i, j, k, d[1010][1010]; while (scanf("%d %d %d %d %d", &n, &m, &s, &t, &u), n) { for (i = 0; i < 1010 * 1010; i++) d[i / 1010][i % 1010] = 1e9; for (i = 0; i < 1010; i++) d[i][i] = 0; while (m-...
#include <stdio.h> int MIN(int a, int b) { return a < b ? a : b; } int main() { int n, m, s, t, u, i, j, k, d[1010][1010]; while (scanf("%d %d %d %d %d", &n, &m, &s, &t, &u), n) { for (i = 0; i < 1010 * 1010; i++) d[i / 1010][i % 1010] = 1e8; for (i = 0; i < 1010; i++) d[i][i] = 0; while (m-...
[["-", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13]]
0
305
2
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
410
2
#include <iostream> #define INF 1e+9 using namespace std; int main() { int n, m, s, g1, g2; while (1) { cin >> n >> m >> s >> g1 >> g2; s--; g1--; g2--; if (!n) break; int cost[100][100]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cost[i][j] = INF; ...
#include <iostream> #define INF 1e+8 using namespace std; int main() { int n, m, s, g1, g2; while (1) { cin >> n >> m >> s >> g1 >> g2; s--; g1--; g2--; if (!n) break; int cost[100][100]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cost[i][j] = INF; ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
308
2
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) #define INF 1e7 using namespace std; int main() { int n, m, x, y, z, q, w, e; while (cin >> n >> m >> x >> y >> z, n++) { int dp[n][n] = {}; r(i, n) r(j, n) if (i != j) dp[i][j] = INF; r(i, m) { cin >> q >> w >> e; dp[q][w]...
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) #define INF 1e8 using namespace std; int main() { int n, m, x, y, z, q, w, e; while (cin >> n >> m >> x >> y >> z, n++) { int dp[n][n] = {}; r(i, n) r(j, n) if (i != j) dp[i][j] = INF; r(i, m) { cin >> q >> w >> e; dp[q][w]...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 31, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 31, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 31, 69, 341, 342, 0, 22]]
1
230
6
#include <cstring> #include <iostream> using namespace std; #define INF 1000000000 int n, m, s, g1, g2; int t[101][101]; int main(void) { while (cin >> n >> m >> s >> g1 >> g2, n) { for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) t[i][j] = INF; for (int i = 1; i <= n; i++) t[i...
#include <cstring> #include <iostream> using namespace std; #define INF 100000000 int n, m, s, g1, g2; int t[101][101]; int main(void) { while (cin >> n >> m >> s >> g1 >> g2, n) { for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) t[i][j] = INF; for (int i = 1; i <= n; i++) t[i]...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
303
2
#include <limits.h> #include <stdio.h> int main() { int n, m, s, g1, g2, b1, b2, c, i, j, k, d[101][101], V = INT_MAX / 2; while (scanf("%d%d%d%d%d", &n, &m, &s, &g1, &g2), n) { for (i = 1; i <= n; d[i][i] = 0, ++i) for (j = 1; j <= n; ++j) d[i][j] = V; while (m--) scanf("%d%d%d", &b1, &...
#include <limits.h> #include <stdio.h> int main() { int n, m, s, g1, g2, b1, b2, c, i, j, k, d[101][101], V = INT_MAX / 5; while (scanf("%d%d%d%d%d", &n, &m, &s, &g1, &g2), n) { for (i = 1; i <= n; d[i][i] = 0, ++i) for (j = 1; j <= n; ++j) d[i][j] = V; while (m--) scanf("%d%d%d", &b1, &...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
307
2
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define INF 1e8 #define rep(i, n) for (int i = ...
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define INF 1e8 #define rep(i, n) for (int i = ...
[["+", 0, 11, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 31, 2, 3, 4, 0, 16, 12, 13]]
1
273
2
// 35 #include <algorithm> #include <iostream> using namespace std; int main() { int d[101][101]; for (int n, m, s, g1, g2; cin >> n >> m >> s >> g1 >> g2, n | m | s | g1 | g2;) { for (int y = 1; y <= n; y++) { for (int x = 1; x <= n; x++) { d[y][x] = (y == x) ? 0 : 1 << 28; } }...
// 35 #include <algorithm> #include <iostream> using namespace std; int main() { int d[101][101]; for (int n, m, s, g1, g2; cin >> n >> m >> s >> g1 >> g2, n | m | s | g1 | g2;) { for (int y = 1; y <= n; y++) { for (int x = 1; x <= n; x++) { d[y][x] = (y == x) ? 0 : 1 << 28; } }...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
301
2
#include <algorithm> #include <iostream> using namespace std; int const INF = (int)1e9; int main() { int N, M, S, g1, g2; while (cin >> N >> M >> S >> g1 >> g2 && N) { int cost[100][100]; fill(cost[0], cost[0] + 10000, INF); for (int i = 0; i < N; i++) cost[i][i] = 0; S--, g1--, g2--; ...
#include <algorithm> #include <iostream> using namespace std; int const INF = 1 << 29; int main() { int N, M, S, g1, g2; while (cin >> N >> M >> S >> g1 >> g2 && N) { int cost[100][100]; fill(cost[0], cost[0] + 10000, INF); for (int i = 0; i < N; i++) cost[i][i] = 0; S--, g1--, g2--; f...
[["-", 0, 30, 0, 43, 49, 50, 51, 74, 0, 24], ["-", 0, 43, 49, 50, 51, 74, 39, 77, 39, 40], ["-", 0, 30, 0, 43, 49, 50, 51, 74, 0, 25], ["-", 0, 30, 0, 43, 49, 50, 51, 74, 51, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 17, 151], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 12, 13]]
1
296
7
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <vector> #define REP(i, a, b) for (int i = (a); i < (int)(b); i++) #define rep(i, a) REP(i, 0, a) using namespace std; char field[51][51]; map<char, vector<int>> corner; vector<char> chars; set<char> schars; int H, W; b...
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <vector> #define REP(i, a, b) for (int i = (a); i < (int)(b); i++) #define rep(i, a) REP(i, 0, a) using namespace std; char field[51][51]; map<char, vector<int>> corner; vector<char> chars; set<char> schars; int H, W; b...
[["-", 0, 14, 8, 9, 0, 37, 0, 5, 0, 6], ["+", 0, 14, 8, 9, 0, 37, 0, 5, 0, 6]]
1
577
2
#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>>; int main() { int N; cin >> N; while (N--) { int Y, X; cin >> Y >> X; vector<vector<int>> field(Y,...
#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>>; int main() { int N; cin >> N; while (N--) { int Y, X; cin >> Y >> X; vector<vector<int>> field(Y,...
[["+", 49, 50, 51, 69, 341, 342, 0, 69, 28, 22], ["+", 51, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 51, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
545
3
#include <bits/stdc++.h> #define REP(i, n, N) for (int i = n; i < N; i++) #define p(S) cout << (S) << endl #define F first #define S second using namespace std; int main() { int N; cin >> N; REP(n, 0, N) { int H, W; cin >> H >> W; bool safe = true; map<char, int> xmin, xmax, ymin, ymax; char ...
#include <bits/stdc++.h> #define REP(i, n, N) for (int i = n; i < N; i++) #define p(S) cout << (S) << endl #define F first #define S second using namespace std; int main() { int N; cin >> N; REP(n, 0, N) { int H, W; cin >> H >> W; bool safe = true; map<char, int> xmin, xmax, ymin, ymax; char ...
[["-", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6]]
1
513
2
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory.h> #include <memory> #include <numeric> #include <queue> #include <sstream> #include <stack> #include ...
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory.h> #include <memory> #include <numeric> #include <queue> #include <sstream> #include <stack> #include ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 64, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
640
6
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; typedef pair<int, int> P; int h, w; bool ans; void debug(vector<string> s) { cout << "[debug]" << endl; for (int y = 0; y < h; y++) { cout << s[y] << endl; } cout << endl; } // ツ債カツ湘」ツづ?右ツ可コツづ個催?標ツづーツ陛板つキ pair<...
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; typedef pair<int, int> P; int h, w; bool ans; void debug(vector<string> s) { cout << "[debug]" << endl; for (int y = 0; y < h; y++) { cout << s[y] << endl; } cout << endl; } // ツ債カツ湘」ツづ?右ツ可コツづ個催?標ツづーツ陛板つキ pair<...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22]]
1
885
4
using namespace std; /*{{{*/ #include <iostream> #include <map> #include <vector> typedef vector<char> VC; typedef vector<VC> VVC; #define FOR(i, b, e) for (typeof(e) i = (b); i != (e); i < (e) ? ++i : --i) #define REP(i, n) FOR(i, 0, n) #define EACH(c, it) ...
using namespace std; /*{{{*/ #include <iostream> #include <map> #include <vector> typedef vector<char> VC; typedef vector<VC> VVC; #define FOR(i, b, e) for (typeof(e) i = (b); i != (e); i < (e) ? ++i : --i) #define REP(i, n) FOR(i, 0, n) #define EACH(c, it) ...
[["+", 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, 14, 8, 9, 0, 1, 0, 35]]
1
527
6
#include <cstdio> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; int N, n; int H, W; char m[50][50]; bool used[26]; int U[26], D[26], L[26], R[26]; bool check(char ch) { int z = ch - 'A'; ...
#include <cstdio> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; int N, n; int H, W; char m[50][50]; bool used[26]; int U[26], D[26], L[26], R[26]; bool check(char ch) { int z = ch - 'A'; ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
510
4
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory.h> #include <memory> #include <numeric> #include <queue> #include <sstream> #include <stack> #include ...
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory.h> #include <memory> #include <numeric> #include <queue> #include <sstream> #include <stack> #include ...
[["-", 51, 2, 3, 4, 0, 16, 12, 118, 28, 22], ["+", 51, 2, 3, 4, 0, 16, 12, 118, 28, 22], ["+", 0, 52, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46]]
1
694
4
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; type...
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; type...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 36, 36, 36, 36, 0, 30, 0, 134, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 134, 39, 40]]
1
760
4
require 'set' class Graph def initialize @nodes = Set.new @edges = Set.new end def add_node(label = nil) Node.new(label) end def add_edge(u, v) e = Edge.new(u, v) u.outgoings << e v.incomings << e e end def del_edge(e) u, v = e.from, e.to u.outgoings.delete(e) v.incomings.delete(e) e ...
require 'set' class Graph def initialize @nodes = Set.new @edges = Set.new end def add_node(label = nil) Node.new(label) end def add_edge(u, v) e = Edge.new(u, v) u.outgoings << e v.incomings << e e end def del_edge(e) u, v = e.from, e.to u.outgoings.delete(e) v.incomings.delete(e) e ...
[["+", 196, 196, 8, 734, 0, 652, 486, 742, 0, 70], ["+", 8, 734, 0, 652, 486, 742, 0, 475, 756, 612], ["+", 8, 734, 0, 652, 486, 742, 0, 475, 17, 757], ["+", 0, 652, 486, 742, 0, 475, 444, 748, 17, 33], ["+", 0, 652, 486, 742, 0, 475, 444, 748, 439, 612], ["+", 196, 196, 8, 734, 0, 652, 486, 742, 0, 73]]
4
673
6
loop { n = gets.to_i break if n == 0 schedule = Array.new(30,0) (0..n-1).each{|i| gets.split(/\s+/).map(&:to_i)[1..-1].each{|day| schedule[day-1] |= (1 << i) } } x_day = -1 (0..29).each{|d1| gathered = schedule[d1] (d1-1).downto(0){|d2| members = schedule[d2] gathered |= members if gathered & ...
loop { n = gets.to_i break if n == 0 schedule = Array.new(30,0) (0..n-1).each{|i| gets.split(/\s+/).map(&:to_i)[1..-1].each{|day| schedule[day-1] |= (1 << i) } } x_day = -1 (0..29).each{|d1| gathered = schedule[d1] (d1-1).downto(0){|d2| members = schedule[d2] gathered |= members if gathered & ...
[["+", 196, 196, 8, 734, 0, 751, 15, 738, 17, 47], ["+", 196, 196, 8, 734, 0, 751, 15, 738, 12, 612]]
4
146
2
while(1): n=int(input()) if n==0: break else: win=2**n-1 know=[2**x for x in range(n)] date=[[] for x in range(31)] for i in range(n): indata=[int(x) for x in input().split()] for j in indata[1:]: date[j].append(i) #prin...
while(1): n=int(input()) if n==0: break else: win=2**n-1 know=[2**x for x in range(n)] date=[[] for x in range(31)] for i in range(n): indata=[int(x) for x in input().split()] for j in indata[1:]: date[j].append(i) #prin...
[["-", 75, 76, 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, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
166
6
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); while (true) { var e = Arr.shift() - 0; if (e == 0) break; var min = Infinity; for (var z = 0; z <= 100; z++) { for (var y = 0; y <= 1000; y++) { var x = e - Math.pow(z, 3) + Math.pow(y, 2); i...
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); while (true) { var e = Arr.shift() - 0; if (e == 0) break; var min = Infinity; for (var z = 0; z <= 100; z++) { for (var y = 0; y <= 1000; y++) { var x = e - (Math.pow(z, 3) + Math.pow(y, 2)); ...
[["+", 0, 198, 0, 200, 51, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 12, 2, 3, 3, 0, 25]]
2
153
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int e = sc.nextInt(); if (e == 0) break; int m = 1 << 30; for (int z = 1;; z++) { int xy = e - z * z * z; if (xy < 0) ...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int e = sc.nextInt(); if (e == 0) break; int m = 1 << 30; for (int z = 0;; z++) { int xy = e - z * z * z; if (xy < 0) ...
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
148
2
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { int x = 0; int y = 0; int z = 0; int[] m = new int[10000]; int temp_m; int count; BufferedReader br = new Buffere...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { int x = 0; int y = 0; int z = 0; int[] m = new int[10000]; int temp_m; int count; BufferedReader br = new Buffere...
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 20]]
3
278
2
#include <stdio.h> int main() { int x, y, z, z2, y2, x2; int m; int e, min; int i, j; while (1) { scanf("%d", &e); if (e == 0) break; x = 10000; min = 1000000; for (j = 0; j <= 100; j++) { for (i = 0; i <= 1000; i++) { y2 = i * i; z2 = j * j * j; x...
#include <stdio.h> int main() { int x, y, z, z2, y2, x2; int m; int e, min; int i, j; while (1) { scanf("%d", &e); if (e == 0) break; x = 10000; min = 1000000; for (j = 0; j <= 100; j++) { for (i = 0; i <= 1000; i++) { y2 = i * i; z2 = j * j * j; x...
[["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 20]]
0
176
2
#include <stdio.h> int main() { int e, i, j, k, x, y, z, m, min; for (;;) { scanf("%d", &e); if (e == 0) { break; } min = e; for (j = 0; j <= e; j++) { for (k = 0; k <= e; k++) { if (e - (j * j + k * k * k) > 0) { x = e - (j * j + k * k * k); y = j; ...
#include <stdio.h> int main() { int e, i, j, k, x, y, z, m, min; for (;;) { scanf("%d", &e); if (e == 0) { break; } min = e; for (j = 0; j <= 1000; j++) { for (k = 0; k <= 100; k++) { if (e - (j * j + k * k * k) >= 0) { x = e - (j * j + k * k * k); y ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
0
166
8
n, i, j; main() { while (scanf("%d", &n), n) { int mi = 999; for (i = 1; i < 110; i++) for (j = 1; j < 1010; j++) mi = fmin( mi, (n < i * i * i + j * j ? 999 : i + j + n - i * i * i - j * j)); printf("%d\n", mi); } return 0; }
n, i, j; main() { while (scanf("%d", &n), n) { int mi = 999; for (i = 0; i < 110; i++) for (j = 0; j < 1010; j++) mi = fmin( mi, (n < i * i * i + j * j ? 999 : i + j + n - i * i * i - j * j)); printf("%d\n", mi); } return 0; }
[["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 8, 9, 0, 7, 8, 7, 10, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 7, 10, 11, 12, 13]]
0
111
4
y, m, z, e; main(k) { for (; m = 1e7, scanf("%d", &e) * e; z = !printf("%d\n", m)) for (; (k = e - z * z * z) <= 0; m = fmin(m, y + k - y * y + z++)) y = sqrt(k); }
y, m, z, e; main(k) { for (; m = 1e7, scanf("%d", &e) * e; z = !printf("%d\n", m)) for (; (k = e - z * z * z) >= 0; m = fmin(m, y + k - y * y + z++)) y = sqrt(k); }
[["-", 8, 9, 0, 7, 8, 7, 15, 16, 17, 19], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 17, 20]]
0
88
10
y, m, z, e; main(k) { for (; m = -1u, scanf("%d", &e) * e; z = !printf("%d\n", m)) for (; (k = e - z * z * z) >= 0; m = fmin(m, y + k - y * y + z++)) y = sqrt(k); }
y, m, z, e; main(k) { for (; m = scanf("%d", &e) * e; z = !printf("%d\n", m)) for (; (k = e - z * z * z) >= 0; m = fmin(m, y + k - y * y + z++)) y = sqrt(k); }
[["-", 8, 9, 0, 7, 15, 34, 31, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 34, 0, 21]]
0
88
13
y, m, z, e; main(k) { for (; m = scanf("%d", &e) * e; z = !printf("%d\n", m)) for (; (k = e - z * z * z) > 0; m = fmin(m, y + k - y * y + z++)) y = sqrt(k); }
y, m, z, e; main(k) { for (; m = scanf("%d", &e) * e; z = !printf("%d\n", m)) for (; (k = e - z * z * z) > -1; m = fmin(m, k - y * ~-y + z++)) y = sqrt(k); }
[["-", 8, 9, 0, 7, 8, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 12, 13], ["-", 3, 4, 0, 16, 31, 16, 31, 16, 31, 22], ["-", 3, 4, 0, 16, 31, 16, 31, 16, 17, 72], ["+", 0, 16, 31, 16, 12, 16, 12, 91, 17, 92], ["+", 31, 16, 12, 16, 12, 91, 28, 91, 17, 33]]
0
86
13