buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
import static java.lang.Integer.MAX_VALUE; import static java.lang.Integer.parseInt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Problem 05: Split Up! */ public class Main { public static void main(String[] args) throws IOEx...
import static java.lang.Integer.MAX_VALUE; import static java.lang.Integer.parseInt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Problem 05: Split Up! */ public class Main { public static void main(String[] args) throws IOEx...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499]]
3
283
2
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == 0) break; int[] a = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == 0) break; int[] a = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); ...
[["+", 0, 492, 3, 4, 0, 16, 31, 16, 17, 48], ["+", 0, 492, 3, 4, 0, 16, 31, 16, 12, 499]]
3
248
2
#include <iostream> #include <queue> #define abs(a) ((a) > 0 ? (a) : -(a)) using namespace std; long diffmin, n, p[20]; void dfs(int layer, long a, long b) { if (layer < n) { dfs(layer + 1, a + p[layer], b); dfs(layer + 1, a, b + p[layer]); } else { if (diffmin > abs(a - b)) { diffmin = abs(a - ...
#include <iostream> #include <queue> #define abs(a) ((a) > 0 ? (a) : -(a)) using namespace std; long diffmin, n, p[20]; void dfs(int layer, long a, long b) { if (layer < n) { dfs(layer + 1, a + p[layer], b); dfs(layer + 1, a, b + p[layer]); } else { if (diffmin > abs(a - b)) { diffmin = abs(a - ...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
202
2
#include <algorithm> #include <iostream> using namespace std; int RegNum; //登録者数 int RegATK[20]; //登録者戦闘力 int RegATKAll; //登録者戦闘力合計 int PartyATK[2]; //パーティー戦闘力 int GetMinATK(int n, int PAATK) { if (n == 0) return abs(RegATKAll - (2 * PAATK)); return min(GetMinATK(n - 1, PAATK + RegATK[n]), GetMinATK(...
#include <algorithm> #include <iostream> using namespace std; int RegNum; //登録者数 int RegATK[20]; //登録者戦闘力 int RegATKAll; //登録者戦闘力合計 int PartyATK[2]; //パーティー戦闘力 int GetMinATK(int n, int PAATK) { if (n == 0) return abs(RegATKAll - (2 * PAATK)); return min(GetMinATK(n - 1, PAATK + RegATK[n]), GetMinATK(...
[["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
1
176
2
#include <cstdio> #include <iostream> #include <vector> using namespace std; int n, u[21]; vector<int> a, b; int minsa = 100000; void kakunin() { cout << "ateam" << endl; for (int i = 0; i < a.size(); i++) cout << a[i] << " "; cout << endl << "bteam" << endl; for (int i = 0; i < b.size(); i++) cout << ...
#include <cstdio> #include <iostream> #include <vector> using namespace std; int n, u[21]; vector<int> a, b; int minsa = 100000; void kakunin() { cout << "ateam" << endl; for (int i = 0; i < a.size(); i++) cout << a[i] << " "; cout << endl << "bteam" << endl; for (int i = 0; i < b.size(); i++) cout << ...
[["+", 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
362
4
#include <bits/stdc++.h> using namespace std; typedef set<int> S; int main() { int n; while (cin >> n, n) { int a[20], sum = 0; for (int i = 0; i < n; i++) cin >> a[i], sum += a[i]; S mp[21]; S::iterator it; mp[0].insert(0); for (int i = 0; i < n; i++) for (it = mp[i].begin(); ...
#include <bits/stdc++.h> using namespace std; typedef set<int> S; int main() { int n; while (cin >> n, n) { int a[20], sum = 0; for (int i = 0; i < n; i++) cin >> a[i], sum += a[i]; S mp[21]; S::iterator it; mp[0].insert(0); for (int i = 0; i < n; i++) for (it = mp[i].begin(); ...
[["+", 0, 11, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 17, 48], ["+", 3, 4, 0, 16, 12, 16, 12, 23, 0, 25]]
1
220
5
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int main() { int n, sum; vector<int> a; while (true) { cin >> n; if (n == 0) { break; } a = vector<int>(n); for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } ...
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int main() { int n, sum; vector<int> a; while (true) { cin >> n; if (n == 0) { break; } a = vector<int>(n); sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[...
[["+", 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
183
4
#include <algorithm> #include <cmath> #include <iostream> using namespace std; const int INF = 1e+9; int n, ans; int a[21]; void dfs(int diff, int k); int main() { while (cin >> n) { for (int i = 0; i < n; i++) { cin >> a[i]; } ans = INF; dfs(0, 0); cout << ans << endl; } } void dfs...
#include <algorithm> #include <cmath> #include <iostream> using namespace std; const int INF = 1e+9; int n, ans; int a[21]; void dfs(int diff, int k); int main() { while (cin >> n && n != 0) { for (int i = 0; i < n; i++) { cin >> a[i]; } ans = INF; dfs(0, 0); cout << ans << endl; } }...
[["+", 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, 79], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
153
4
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int n, a[23]; vector<int> v; void f(int k, int sum) { if (k == n) v.push_back(sum); else { f(k + 1, sum); f(k + 1, sum + a[k]); } return; } int main() { while (cin >> n, n) { v.clear(); int sum...
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int n, a[23]; vector<int> v; void f(int k, int sum) { if (k == n) v.push_back(sum); else { f(k + 1, sum); f(k + 1, sum + a[k]); } return; } int main() { while (cin >> n, n) { v.clear(); int sum...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["-", 0, 52, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 52, 8, 9, 0, 7, 10, 43, 39, 40]]
1
204
4
#include <iostream> #define INF (1 << 21) using namespace std; int n, t[20], mi, a[20]; void rec(int p) { int a1, a2; if (p == n) { a1 = 0; a2 = 0; for (int i = 0; i < n; i++) { if (t[i] == 1) a1 += a[i]; else a2 += a[i]; } if (a1 - a2 > 0 && a1 - a2 < mi) mi ...
#include <iostream> #define INF (1 << 21) using namespace std; int n, t[20], mi, a[20]; void rec(int p) { int a1, a2; if (p == n) { a1 = 0; a2 = 0; for (int i = 0; i < n; i++) { if (t[i] == 1) a1 += a[i]; else a2 += a[i]; } if (a1 - a2 >= 0 && a1 - a2 < mi) mi...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20]]
1
242
2
#include <cstring> #include <iostream> using namespace std; bool table[1000001]; int main() { while (true) { int n, a, sum = 0; cin >> n; if (n == 0) { break; } memset(table, 0, sizeof(bool) * 1000001); table[0] = true; while (n--) { cin >> a; for (int i = sum; i >= 0;...
#include <cstring> #include <iostream> using namespace std; bool table[1000001]; int main() { while (true) { int n, a, sum = 0; cin >> n; if (n == 0) { break; } memset(table, 0, sizeof(bool) * 1000001); table[0] = true; while (n--) { cin >> a; for (int i = sum; i >= 0;...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
164
2
def solve(a,i,sa,sb): if 2*sa >= all: return 2*sa-all if 2*sb >= all: return 2*sb-all return min(solve(a,i+1,sa+a[i],sb),solve(a,i+1,sa,sb+a[i])) while True: n = eval(input()) if n == 0: break a = sorted(map(int,input().split())) all = sum(a) print(solve(a,0,a[0],0))
def solve(a,i,sa,sb): if 2*sa >= all: return 2*sa-all if 2*sb >= all: return 2*sb-all return min(solve(a,i+1,sa+a[i],sb),solve(a,i+1,sa,sb+a[i])) while True: n = eval(input()) if n == 0: break a = sorted(map(int,input().split())) all = sum(a) print(solve(a,1,a[0],0))
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612]]
5
133
8
def solve(a,i,sa,sb): if 2*sa >= all: return 2*sa-all if 2*sb >= all: return 2*sb-all return min(solve(a,i+1,sa+a[i],sb),solve(a,i+1,sa,sb+a[i])) while True: n = eval(input()) if n == 0: break a = sorted(map(int,input().split())) all = sum(a) print(solve(a,0,a[0],0))
def solve(a,i,sa,sb): if 2*sa >= all: return 2*sa-all if 2*sb >= all: return 2*sb-all return min(solve(a,i+1,sa+a[i],sb),solve(a,i+1,sa,sb+a[i])) while True: n = eval(input()) if n == 0: break a = sorted(map(int,input().split()))[::-1] all = sum(a) print(solve(a,1,a[0],0))
[["+", 8, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 102], ["+", 0, 662, 12, 206, 206, 663, 0, 664, 17, 33], ["+", 0, 662, 12, 206, 206, 663, 0, 664, 28, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 0, 73], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, ...
5
133
8
#define _USE_MATH_DEFINES #define INF 0x3f3f3f3f #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #incl...
#define _USE_MATH_DEFINES #define INF 0x3f3f3f3f #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #incl...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
1,004
2
#include <iostream> #include <queue> using namespace std; typedef pair<pair<int, int>, int> pa; #define ff first.first #define fs first.second int h, w, sx, sy, gx, gy; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1}; int co[21][21]; char ma[21][21]; bool visited[21][21]; string pat; int m = 99999; int main() { ...
#include <iostream> #include <queue> using namespace std; typedef pair<pair<int, int>, int> pa; #define ff first.first #define fs first.second int h, w, sx, sy, gx, gy; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1}; int co[21][21]; char ma[21][21]; bool visited[21][21]; string pat; int m = 999999; int main() {...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
584
2
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef pair<int, int> P; char s[20][21]; int d[20][20]; int dx[]{0, -1, 0, 0, 1}, dy[]{0, 0, 1, -1, 0}; int main() { int h, w; while (scanf("%d%d", &h, &w), h) { int ax, ay, bx, by; rep(i, h) { scanf("%s",...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef pair<int, int> P; char s[20][21]; int d[20][20]; int dx[]{0, -1, 0, 0, 1}, dy[]{0, 0, 1, -1, 0}; int main() { int h, w; while (scanf("%d%d", &h, &w), h) { int ax, ay, bx, by; rep(i, h) { scanf("%s",...
[["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 13], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
572
6
#include <iostream> #include <queue> #include <string> #include <vector> using namespace std; int dir[] = {0, 1, 0, -1}; int H, W, dist[25][25]; string s[25], t; int main() { while (cin >> H >> W, H) { int ax = -1, ay = -1, bx = -1, by = -1; for (int i = 0; i < H; i++) { cin >> s[i]; for (int j = ...
#include <iostream> #include <queue> #include <string> #include <vector> using namespace std; int dir[] = {0, 1, 0, -1}; int H, W, dist[25][25]; string s[25], t; int main() { while (cin >> H >> W, H) { int ax = -1, ay = -1, bx = -1, by = -1; for (int i = 0; i < H; i++) { cin >> s[i]; for (int j = ...
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
583
2
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define fr first #define sc second #define INFTY 1000000 typedef pair<int, int> Pt; typedef pair<pair<Pt...
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define fr first #define sc second #define INFTY 1000000 typedef pair<int, int> Pt; typedef pair<pair<Pt...
[["+", 0, 23, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 23, 0, 2, 3, 4, 0, 16, 12, 13]]
1
864
2
#include <algorithm> #include <iostream> #include <queue> #include <stdio.h> #define INF 99999999 using namespace std; queue<int> qy, qx, qcnt; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; int n, m, x, y, cnt, nx, ny, mini, ansx, ansy; int t[20][20], sx, sy, tx, ty, vd[20][20]; string in; int main() { while (c...
#include <algorithm> #include <iostream> #include <queue> #include <stdio.h> #define INF 99999999 using namespace std; queue<int> qy, qx, qcnt; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; int n, m, x, y, cnt, nx, ny, mini, ansx, ansy; int t[20][20], sx, sy, tx, ty, vd[20][20]; string in; int main() { while (c...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
697
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <vector> using namespace std; typedef complex<double> P; const double PI = acos(-1); const double EPS = 1e-9; struct circle /*{{{*/ { P o; double r; circle() {} circle(const P &p, double x) : o(p), r(x) {}...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <vector> using namespace std; typedef complex<double> P; const double PI = acos(-1); const double EPS = 1e-9; struct circle /*{{{*/ { P o; double r; circle() {} circle(const P &p, double x) : o(p), r(x) {}...
[["-", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22]]
1
687
1
#include <algorithm> #include <cmath> #include <stack> #include <stdio.h> using namespace std; int b_row, b_col, memo[16][3][3]; char b[2]; bool rangeCheck(int row, int col) { if (row >= 0 && row <= 2 && col >= 0 && col <= 2) return true; else { return false; } } int translate(char ch) { switch (ch...
#include <algorithm> #include <cmath> #include <stack> #include <stdio.h> using namespace std; int b_row, b_col, memo[16][3][3]; char b[2]; bool rangeCheck(int row, int col) { if (row >= 0 && row <= 2 && col >= 0 && col <= 2) return true; else { return false; } } int translate(char ch) { switch (ch...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107]]
1
621
2
#include <iostream> #include <stdio.h> using namespace std; int main() { while (1) { int n, s, t, b, sum = 0; int ai[16][3][3] = {0}; char a, d, c; scanf("%d", &n); if (n == 0) break; cin >> a >> d >> c; s = a - 'A'; t = d - 'A'; b = c - 'A'; ai[0][s / 3][s % 3] = 1; ...
#include <iostream> #include <stdio.h> using namespace std; int main() { while (1) { int n, s, t, b, sum = 0; int ai[16][3][3] = {0}; char a, d, c; scanf("%d", &n); if (n == 0) break; cin >> a >> d >> c; s = a - 'A'; t = d - 'A'; b = c - 'A'; ai[0][s / 3][s % 3] = 1; ...
[["-", 31, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 17, 72]]
1
524
2
#include "stdio.h" #include <cstring> #include <iostream> using namespace std; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; int main() { int n; double prob[2][3][3]; bool junk[3][3]; while (cin >> n, n) { char s, t, b; cin >> s >> t >> b; double ans = 0.0; for (int i = 0; i < 2; i++) ...
#include "stdio.h" #include <cstring> #include <iostream> using namespace std; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; int main() { int n; double prob[2][3][3]; bool junk[3][3]; while (cin >> n, n) { char s, t, b; cin >> s >> t >> b; double ans = 0.0; for (int i = 0; i < 2; i++) ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
468
2
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using nam...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using nam...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20]]
1
543
2
#include <iostream> #include <string.h> using namespace std; int n; char room[10] = "ABCDEFGHI"; char s, t, b; int off[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; int x, y; double table[3][3]; double solve() { memset(&table[0][0], 0, sizeof(double) * 9); table[x][y] = 1.0; for (int k = 0; k < n; k++) { d...
#include <iostream> #include <string.h> using namespace std; int n; char room[10] = "ABCDEFGHI"; char s, t, b; int off[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; int x, y; double table[3][3]; double solve() { memset(&table[0][0], 0, sizeof(double) * 9); table[y][x] = 1.0; for (int k = 0; k < n; k++) { d...
[["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
476
4
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <s...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <s...
[["+", 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
441
6
#include <cstring> #include <iomanip> #include <iostream> using namespace std; int main() { int n; while (cin >> n, n) { long double room[3][3][n + 1]; memset(room, 0, sizeof(room)); char s, t, b; cin >> s >> t >> b; int y = (s - 'A') / 3; int x = (s - 'A') % 3; int by = (b - 'A') / ...
#include <cstring> #include <iomanip> #include <iostream> using namespace std; int main() { int n; while (cin >> n, n) { long double room[3][3][n + 1]; memset(room, 0, sizeof(room)); char s, t, b; cin >> s >> t >> b; int y = (s - 'A') / 3; int x = (s - 'A') % 3; int by = (b - 'A') / ...
[["-", 51, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["-", 51, 16, 12, 23, 0, 16, 12, 16, 12, 22], ["+", 51, 16, 12, 23, 0, 16, 12, 16, 12, 22]]
1
388
4
#include <cstdio> #include <iostream> using namespace std; const int MAX = 16; const int NUM = 9; double f[MAX][NUM]; int main() { int n, s, t, b; char ts, tt, tb; while (cin >> n, n) { cin >> ts >> tt >> tb; s = ts - 'A'; t = tt - 'A'; b = tb - 'A'; fill((double *)f, (double *)f + MAX + NU...
#include <cstdio> #include <iostream> using namespace std; const int MAX = 16; const int NUM = 9; double f[MAX][NUM]; int main() { int n, s, t, b; char ts, tt, tb; while (cin >> n, n) { cin >> ts >> tt >> tb; s = ts - 'A'; t = tt - 'A'; b = tb - 'A'; fill((double *)f, (double *)(f + MAX), 0...
[["+", 0, 2, 3, 4, 0, 74, 51, 23, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 2, 3, 4, 0, 74, 51, 23, 0, 25]]
1
407
4
loop{ n = gets.to_i() if n == 0 then break end s,t,b = gets.split room_path = { "A"=>["B","D"], "B"=>["A","C","E"], "C"=>["B","F"], "D"=>["A","E","G"], "E"=>["D","B","F","H"], "F"=>["E","C","I"], "G"=>["H","D"], "H"=>["E","G","I"], "I"=>["F","H"]} room_path[b].each{|r| room_path[r].selec...
loop{ n = gets.to_i() if n == 0 then break end s,t,b = gets.split room_path = { "A"=>["B","D"], "B"=>["A","C","E"], "C"=>["B","F"], "D"=>["A","E","G"], "E"=>["D","B","F","H"], "F"=>["E","C","I"], "G"=>["H","D"], "H"=>["E","G","I"], "I"=>["F","H"]} room_path[b].each{|r| room_path[r].selec...
[["-", 31, 739, 0, 738, 31, 739, 0, 652, 486, 612], ["-", 31, 739, 0, 738, 31, 739, 0, 652, 17, 131], ["+", 31, 739, 0, 738, 31, 739, 0, 738, 31, 531]]
4
306
3
#include <stdio.h> #include <string.h> int line_max; char buffer[2000]; char bunsyou[200][2000]; int cx, cy; void a(void) { cx = 0; } void e(void) { cx = strlen(bunsyou[cy]); } void p(void) { if (cy > 0) cy--; cx = 0; } void n(void) { if (cy < line_max - 1) cy++; cx = 0; } void f(void) { if (cx ...
#include <stdio.h> #include <string.h> int line_max; char buffer[2000]; char bunsyou[200][2000]; int cx, cy; void a(void) { cx = 0; } void e(void) { cx = strlen(bunsyou[cy]); } void p(void) { if (cy > 0) cy--; cx = 0; } void n(void) { if (cy < line_max - 1) cy++; cx = 0; } void f(void) { if (cx ...
[["-", 0, 2, 3, 4, 0, 69, 71, 16, 17, 33], ["-", 0, 2, 3, 4, 0, 69, 71, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 69, 71, 16, 17, 33], ["+", 0, 2, 3, 4, 0, 69, 71, 16, 12, 13]]
0
883
4
#include <iostream> #include <list> #include <vector> #define POS_MAX 10000 #define GRID 40 #define GRID_NUM 250 // POS_MAX / GRID struct pos_t { pos_t() {} pos_t(int _x, int _y) : x(_x), y(_y) {} pos_t(std::istream *is) { (*is) >> x >> y; } int x, y; }; void process(const int AN, const int BN, const int R) {...
#include <iostream> #include <list> #include <vector> #define POS_MAX 10000 #define GRID 40 #define GRID_NUM 250 // POS_MAX / GRID struct pos_t { pos_t() {} pos_t(int _x, int _y) : x(_x), y(_y) {} pos_t(std::istream *is) { (*is) >> x >> y; } int x, y; }; void process(const int AN, const int BN, const int R) {...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
526
2
#include <bits/stdc++.h> using namespace std; int A, B, R; vector<int> P[11000]; bool check(int x, int y, int x1, int y1) { if ((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y) > 16 * R * R) return false; return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); while (cin >> A >> B >> R && (A ||...
#include <bits/stdc++.h> using namespace std; int A, B, R; vector<int> P[11000]; bool check(int x, int y, int x1, int y1) { if ((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y) > 16 * R * R) return false; return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); while (cin >> A >> B >> R && (A ||...
[["+", 0, 7, 10, 43, 49, 50, 51, 2, 63, 22], ["+", 10, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 10, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 10, 43, 49, 50, 51, 2, 3, 4, 0, 21], ["+", 10, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
1
378
5
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #incl...
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #incl...
[["+", 12, 83, 0, 83, 0, 42, 0, 11, 31, 22], ["-", 0, 83, 0, 27, 28, 11, 12, 16, 17, 18], ["+", 0, 83, 0, 27, 28, 11, 12, 16, 17, 19]]
1
424
3
#include <bits/stdc++.h> #define F 110000 using namespace std; vector<int> v[F]; int a, b, x, y, r, i; int D(int t) { int e = 0; while (e * e <= r * r - t * t) e++; return e - 1; } int main() { while (cin >> a >> b >> r && a + b) for (int i = 0; i < F; i++) v[i].clear(); r *= 4; for (i = 0; i ...
#include <bits/stdc++.h> #define F 110000 using namespace std; vector<int> v[F]; int a, b, x, y, r, i; int D(int t) { int e = 0; while (e * e <= r * r - t * t) e++; return e - 1; } int main() { while (cin >> a >> b >> r && a + b) { for (int i = 0; i < F; i++) v[i].clear(); r *= 4; for (i =...
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 52, 8, 9, 0, 7, 8, 9, 0, 45]]
1
302
4
#include <algorithm> #include <cassert> #include <climits> #include <cstdio> #include <cstdlib> #include <cstring> #include <map> #include <numeric> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i) #d...
#include <algorithm> #include <cassert> #include <climits> #include <cstdio> #include <cstdlib> #include <cstring> #include <map> #include <numeric> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i) #d...
[["-", 0, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["-", 51, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["+", 51, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["-", 51, 16, 12, 2, 3, 4, 0, 16, 31, 13], ["+", 51, 16, 12, 2, 3, 4, 0, 16, 31, 13]]
1
376
10
#include <algorithm> #include <cmath> #include <cstdio> #include <vector> using namespace std; int main() { int an, bn, r, x, y; while (scanf("%d%d%d", &an, &bn, &r), an != 0) { r *= 4; vector<vector<double>> pos(10000); for (int i = 0; i < an; ++i) { scanf("%d%d", &x, &y); pos[x].push_bac...
#include <algorithm> #include <cmath> #include <cstdio> #include <vector> using namespace std; int main() { int an, bn, r, x, y; while (scanf("%d%d%d", &an, &bn, &r), an != 0) { r *= 4; vector<vector<double>> pos(10000); for (int i = 0; i < an; ++i) { scanf("%d%d", &x, &y); pos[x].push_bac...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22]]
1
298
8
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <st...
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <st...
[["-", 0, 52, 8, 9, 0, 43, 0, 114, 0, 115], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 13], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 31, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 31, 13], ["-", 51, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["+", 51, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["-", 0, 7, 15, 16, 12, 16...
1
444
9
#include <cmath> #include <iostream> using namespace std; const double eps = 1.0e-9; int main() { while (true) { unsigned long long int n, r, ans = 0; cin >> n; if (n == 0) break; unsigned long long int tmp = n / 2LL; unsigned long long int rn = (long long int)(sqrt(n / 2) + eps) + 1; //...
#include <cmath> #include <iostream> using namespace std; const double eps = 1.0e-9; int main() { while (true) { unsigned long long int n, r, ans = 0; cin >> n; if (n == 0) break; unsigned long long int tmp = n / 2LL; unsigned long long int rn = (long long int)ceil(sqrt(n / 2) - eps); //...
[["+", 0, 43, 49, 50, 51, 74, 51, 2, 63, 22], ["-", 51, 16, 31, 74, 51, 23, 0, 16, 17, 72], ["+", 51, 74, 51, 2, 3, 4, 0, 16, 17, 33], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
180
5
while 1: n=int(input()) if n==0:break a=0;i=1;b=n//2 while i*i<b:a+=((b-1)/i+1)-i-1;i+=1 a=int((a+b-1)*2+i) print(8*(a+n))
while 1: n=int(input()) if n==0:break a=0;i=1;b=n//2 while i*i<b:a+=((b-1)//i+1)-i-1;i+=1 a=(a+b-1)*2+i print(8*(a+n))
[["-", 31, 657, 31, 23, 0, 657, 31, 657, 17, 85], ["+", 31, 657, 31, 23, 0, 657, 31, 657, 17, 676], ["-", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
84
5
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; Stri...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; Stri...
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 492, 500, 492, 3, 4, 0, 25], ["+", 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]]
3
188
5
#include <stdio.h> int main() { int k, c, i, total, kai, t; for (t = 0; t < 100; t++) { scanf("%d", &k); if (k == 0) break; total = 0; for (i = 0; i < (k * k - k) / 2; i++) { scanf("%d", &c); total += c; } kai = total / 2; printf("%d\n", kai); } return 0; }
#include <stdio.h> int main() { int k, c, i, total, kai, t; for (t = 0; t < 100; t++) { scanf("%d", &k); if (k == 0) break; total = 0; for (i = 0; i < (k * k - k) / 2; i++) { scanf("%d", &c); total += c; } kai = total / (k - 1); printf("%d\n", kai); } return 0...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
0
114
6
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) ...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) ...
[["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24]]
1
848
7
#include <algorithm> #include <climits> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; struct Tag { int pos, pat, cost; Tag() : pos(0), pat(0), cost(0) {} Tag(int p, int pat, int c) : pos(p), pat(pat), cost(c) {} bool operator<(const Tag &other) co...
#include <algorithm> #include <climits> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; struct Tag { int pos, pat, cost; Tag() : pos(0), pat(0), cost(0) {} Tag(int p, int pat, int c) : pos(p), pat(pat), cost(c) {} bool operator<(const Tag &other) co...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 146], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["-", 51, 4, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 51, 4, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 43, 0, 153, 0, 154]]
1
815
5
import java.util.*; public class Main { static Scanner kbd = new Scanner(System.in); public static void main(String[] args) { while (kbd.hasNext()) { int n = kbd.nextInt(); if (n != 0) { int[] p = new int[n]; int i; for (i = 0; i < n; i++) { p[i] = kbd.nextInt(); ...
import java.util.*; public class Main { static Scanner kbd = new Scanner(System.in); public static void main(String[] args) { while (kbd.hasNext()) { int n = kbd.nextInt(); if (n != 0) { int[] p = new int[n]; int i; for (i = 0; i < n; i++) { p[i] = kbd.nextInt(); ...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 22]]
3
217
2
n, p, i, a[51]; main() { for (; ~scanf("%d", &n), n;) { for (p = i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 1; i <= n; i++) { if (a[i - 1] + 1 != a[i] || n) { if (i - p - 1) printf(n - i ? "%d-%d " : "%d-%d\n", a[p], a[i - 1]); else printf(n - i ? "%d " : "...
n, p, i, a[51]; main() { for (; ~scanf("%d", &n), n;) { for (p = i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 1; i <= n; i++) { if (a[i - 1] + 1 != a[i] || n - i == 0) { if (i - p - 1) printf(n - i ? "%d-%d " : "%d-%d\n", a[p], a[i - 1]); else printf(n - i ? ...
[["+", 15, 23, 0, 16, 12, 16, 31, 16, 17, 33], ["+", 15, 23, 0, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
0
166
24
n, p, i, a[51]; main() { for (; ~scanf("%d", &n), n;) { for (a[n] = p = i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 0; i < n; i++) { if (a[i] + 1 != a[i + 1]) { if (i - p + 1) printf(n - i - 1 ? "%d-%d " : "%d-%d\n", a[p], a[i]); else printf(n - i - 1 ? "%d ...
n, p, i, a[51]; main() { for (; ~scanf("%d", &n), n;) { for (a[n] = p = i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 0; i < n; i++) { if (a[i] + 1 != a[i + 1]) { if (i - p) printf(n - i - 1 ? "%d-%d " : "%d-%d\n", a[p], a[i]); else printf(n - i - 1 ? "%d " : ...
[["-", 64, 9, 0, 57, 15, 23, 0, 16, 17, 72], ["-", 64, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
173
2
n, p, i, a[51]; main() { for (; ~scanf("%d", &n), n;) { for (a[n] = p = i = 0; i < n; i++) scanf("%d", a + i); for (i = 1; i <= n; i++) (a[i - 1] - a[i] + 1) && printf(i - p - 1 ? n - i ? "%d-%d " : "%d-%d\n" : n - i ? "%d " ...
n, p, i, a[51]; main() { for (; ~scanf("%d", &n), n;) { for (a[n] = p = i = 0; i < n; i++) scanf("%d", a + i); for (i = 1; i <= n; i++) if (a[i - 1] - a[i] + 1) printf(i - p - 1 ? n - i ? "%d-%d " : "%d-%d\n" : n - i ? "%d " : "%d\n", ...
[["+", 0, 7, 8, 9, 0, 7, 8, 57, 0, 121], ["-", 0, 7, 8, 1, 0, 34, 31, 16, 17, 98]]
0
152
2
#include <stdio.h> int n, p, a[50]; int main() { while (~scanf("%d", &n), n) { for (int i = 0; i < n; i++) scanf("%d", &a[i]); p = 0; for (int i = 1; i < n; i++) { if (a[i - 1] + 1 != a[i]) { if (p - i != 1) printf("%d-%d ", a[p], a[i - 1]); else printf("%d ...
#include <stdio.h> int n, p, a[50]; int main() { while (~scanf("%d", &n), n) { for (int i = 0; i < n; i++) scanf("%d", &a[i]); p = 0; for (int i = 1; i < n; i++) { if (a[i - 1] + 1 != a[i]) { if (i - p != 1) printf("%d-%d ", a[p], a[i - 1]); else printf("%d ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
189
4
#include "bits/stdc++.h" using namespace std; //#define int long long #define DEBUG 1 #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--) #define all(a) (a).begin(), (a).end() #define dump(o) \ if...
#include "bits/stdc++.h" using namespace std; //#define int long long #define DEBUG 1 #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--) #define all(a) (a).begin(), (a).end() #define dump(o) \ if...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
295
2
#include <cstdio> #include <iostream> using namespace std; int main() { int n; while (cin >> n, n) { int x[n]; int a = 0; for (int i = 0; i < n; i++) { cin >> x[i]; if (i > 0) { if (x[i] - 1 != x[i - 1]) { if (a != i - 1) { printf("%d-%d ", x[a], x[i - 1]); ...
#include <cstdio> #include <iostream> using namespace std; int main() { int n; while (cin >> n, n) { int x[n]; int a = 0; for (int i = 0; i < n; i++) { cin >> x[i]; if (i > 0) { if (x[i] - 1 != x[i - 1]) { if (a != i - 1) { printf("%d-%d ", x[a], x[i - 1]); ...
[["+", 75, 76, 0, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
177
4
/* * File: main.cpp * Author: 成诺 * * Created on 2011年8月27日, 下午12:34 */ #include <cstdio> #include <cstdlib> using namespace std; int main(int argc, char **argv) { int n; while (1 == scanf("%d", &n) && n) { int just; int t; bool need = false; for (int i = 0; i < n; ++i, just = ...
/* * File: main.cpp * Author: 成诺 * * Created on 2011年8月27日, 下午12:34 */ #include <cstdio> #include <cstdlib> using namespace std; int main(int argc, char **argv) { int n; while (1 == scanf("%d", &n) && n) { int just; int t; bool need = false; for (int i = 0; i < n; ++i, just = ...
[["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 147], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
1
164
4
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); while (true) { var n = Arr.shift() - 0; if (n == 0) break; var s = []; var sum = 0; for (var i = 0; i < n; i++) { var arr = (Arr.shift()).split(" ").map(Number); s.push(arr); sum += arr[0]; } ...
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); while (true) { var n = Arr.shift() - 0; if (n == 0) break; var s = []; var sum = 0; for (var i = 0; i < n; i++) { var arr = (Arr.shift()).split(" ").map(Number); s.push(arr); sum += arr[0]; } ...
[["-", 8, 556, 0, 198, 0, 200, 51, 557, 0, 491], ["+", 8, 556, 0, 198, 0, 200, 51, 557, 0, 491], ["-", 64, 556, 0, 1, 0, 11, 12, 557, 0, 491], ["+", 64, 556, 0, 1, 0, 11, 12, 557, 0, 491]]
2
226
4
import java.util.Map.Entry; import java.util.Scanner; import java.util.TreeMap; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); a: while (true) { int N = sc.nextInt(); if (N == 0) break; TreeMap<Integer, Integer> map = new TreeMap<...
import java.util.Map.Entry; import java.util.Scanner; import java.util.TreeMap; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); a: while (true) { int N = sc.nextInt(); if (N == 0) break; TreeMap<Integer, Integer> map = new TreeMap<...
[["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
3
229
5
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; class Main { private static void solve() { final Scanner scanner = new Scanner(System.in); while (true) { final int n = scanner.nextInt(); if (n == 0) { break; } int[][] islands = new int[n][2]; ...
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; class Main { private static void solve() { final Scanner scanner = new Scanner(System.in); while (true) { final int n = scanner.nextInt(); if (n == 0) { break; } int[][] islands = new int[n][2]; ...
[["-", 0, 492, 3, 4, 0, 510, 64, 5, 0, 491], ["+", 0, 492, 3, 4, 0, 510, 64, 5, 0, 491], ["-", 0, 492, 3, 4, 0, 510, 75, 5, 0, 491], ["+", 0, 492, 3, 4, 0, 510, 75, 5, 0, 491]]
3
315
4
import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner in = new Scanner(System.in); while (in.hasNext()) { int n = in.nextInt(); if (n == 0) return; int a[] = new int[n]; int b[] = new int[n]; for (int i = 0; i < n; i++) { a...
import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner in = new Scanner(System.in); while (in.hasNext()) { int n = in.nextInt(); if (n == 0) return; int a[] = new int[n]; int b[] = new int[n]; for (int i = 0; i < n; i++) { a...
[["-", 0, 57, 15, 15, 0, 16, 31, 504, 516, 22], ["+", 0, 57, 15, 15, 0, 16, 31, 504, 516, 22], ["-", 0, 57, 15, 15, 0, 16, 12, 504, 516, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 504, 516, 22]]
3
306
4
#include <stdio.h> #include <stdlib.h> int N, I[30][2], i, h; int c(const void *a, const void *b) { int *x = (int *)a; int *y = (int *)b; return x[1] == y[1] ? x[0] - y[0] : x[1] - y[1]; } int main() { for (; scanf("%d", &N), N;) { for (i = 0; i < N; i++) scanf("%d%d", &I[i][0], &I[i][1]); qsort(I...
#include <stdio.h> #include <stdlib.h> int N, I[30][2], i, h; int c(const void *a, const void *b) { int *x = (int *)a; int *y = (int *)b; return x[1] == y[1] ? x[0] - y[0] : x[1] - y[1]; } int main() { for (; scanf("%d", &N), N;) { for (i = 0; i < N; i++) scanf("%d%d", &I[i][0], &I[i][1]); qsort(I...
[["-", 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]]
0
224
4
#include <algorithm> #include <cstring> #include <ctype.h> #include <iostream> #include <math.h> #include <queue> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR...
#include <algorithm> #include <cstring> #include <ctype.h> #include <iostream> #include <math.h> #include <queue> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
208
4
#include <algorithm> #include <stdio.h> #include <utility> int main(void) { int n, sum; bool NGflag; // first... テ」ツ?敕」ツ?ョテ・ツウツカテ」ツ?ョテ・ツョツ敕」ツ?ョテゥツ?? // second... // テ」ツ?敕」ツ?ョテ・ツウツカテ」ツ?ョテヲツゥツ凝」ツ?ョティツ?静、ツケツ?・ツ環? std::pair<int, int> bridge[30]; while (true) { scanf("%d", &n); if (n == 0) { br...
#include <algorithm> #include <stdio.h> #include <utility> int main(void) { int n, sum; bool NGflag; // first... // テ」ツ?敕」ツ?ョテ・ツウツカテ」ツ?ョテヲツゥツ凝」ツ?ョティツ?静、ツケツ?・ツ環? // second... テ」ツ?敕」ツ?ョテ・ツウツカテ」ツ?ョテ・ツョツ敕」ツ?ョテゥツ?? std::pair<int, int> bridge[30]; while (true) { scanf("%d", &n); if (n == 0) { br...
[["-", 0, 2, 3, 4, 0, 66, 28, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 66, 28, 118, 119, 120], ["-", 8, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["-", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120]]
1
202
8
#include <algorithm> #include <iostream> using namespace std; int n; pair<int, int> d[25]; int main() { while (cin >> n, n) { for (int i = 0; i < n; i++) cin >> d[i].first >> d[i].second; sort(d, d + n); int s = 0, f = 0; for (int i = 0; i < n; i++) { s += d[i].second; if (d[i].first...
#include <algorithm> #include <iostream> using namespace std; int n; pair<int, int> d[25]; int main() { while (cin >> n, n) { for (int i = 0; i < n; i++) cin >> d[i].second >> d[i].first; sort(d, d + n); int s = 0, f = 0; for (int i = 0; i < n; i++) { s += d[i].second; if (d[i].first...
[["-", 8, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["+", 8, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["-", 0, 7, 8, 1, 0, 16, 12, 118, 119, 120], ["+", 0, 7, 8, 1, 0, 16, 12, 118, 119, 120]]
1
149
4
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep2(i, a, b) for (int i = (b)-1; i >= (a); i--) #define al...
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep2(i, a, b) for (int i = (b)-1; i >= (a); i--) #define al...
[["-", 63, 118, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 63, 118, 28, 69, 341, 342, 0, 16, 12, 22]]
1
237
2
#include <bits/stdc++.h> #define LL long long #define ULL unsigned long long #define REP(i, n) for (int i = 0; i < (n); i++) #define REP2(i, x, n) for (int i = x; i < (n); i++) using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); while (true) { int N; cin >> N; if (N == 0) { ...
#include <bits/stdc++.h> #define LL long long #define ULL unsigned long long #define REP(i, n) for (int i = 0; i < (n); i++) #define REP2(i, x, n) for (int i = x; i < (n); i++) using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); while (true) { int N; cin >> N; if (N == 0) { ...
[["-", 0, 52, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 52, 8, 9, 0, 43, 39, 344, 141, 78]]
1
173
2
#include <algorithm> #include <iostream> using namespace std; int n, z[25], h[25], wa, f; int main() { while (1) { wa = 0; f = 0; cin >> n; if (n == 0) break; for (int i = 0; i < n; i++) { cin >> z[i] >> h[i]; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - ...
#include <algorithm> #include <iostream> using namespace std; int n, z[25], h[25], wa, f; int main() { while (1) { wa = 0; f = 0; cin >> n; if (n == 0) break; for (int i = 0; i < n; i++) { cin >> z[i] >> h[i]; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - ...
[["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22]]
1
232
4
// 8-11.cpp : 螳壻ケ画而蛻カ蜿ー蠎皮畑遞句コ冗噪蜈・蜿」轤ケ縲?// #include <algorithm> #include <iomanip> #include <iostream> #include <string> using namespace std; struct island { int v, t; }; struct island a[1000]; bool cmp(struct island a, struct island b) { return a.t < b.t; } int main() { int n; while (cin >> n && n != 0) { f...
// 8-11.cpp : 螳壻ケ画而蛻カ蜿ー蠎皮畑遞句コ冗噪蜈・蜿」轤ケ縲?// #include <algorithm> #include <iomanip> #include <iostream> #include <string> using namespace std; struct island { int v, t; }; struct island a[1000]; bool cmp(struct island a, struct island b) { return a.t < b.t; } int main() { int n; while (cin >> n && n != 0) { f...
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
195
4
#include <algorithm> #include <iostream> using namespace std; struct island { int bridge; int treasure; }; bool operator<(island i1, island i2) { return i1.treasure < i2.treasure; } int main() { int input, value; bool flag; while (1) { cin >> input; if (input == 0) { break; } is...
#include <algorithm> #include <iostream> using namespace std; struct island { int bridge; int treasure; }; bool operator<(island i1, island i2) { // if(i1.treasure == i2.treasure){ return i1.bridge < i2.bridge; // } // return i1.treasure < i2.treasure; } int main() { int input, value; bool flag;...
[["-", 8, 9, 0, 37, 0, 16, 31, 118, 119, 120], ["+", 8, 9, 0, 37, 0, 16, 31, 118, 119, 120], ["-", 8, 9, 0, 37, 0, 16, 12, 118, 119, 120], ["+", 8, 9, 0, 37, 0, 16, 12, 118, 119, 120], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
201
6
#include <algorithm> #include <iostream> #include <vector> using namespace std; vector<string> ans; int main() { while (1) { int n; cin >> n; if (n == 0) break; int it[25]; int bl[25]; int sindex[25]; for (int i = 0; i < n; i++) { cin >> it[i] >> bl[i]; sindex[i] = i...
#include <algorithm> #include <iostream> #include <vector> using namespace std; vector<string> ans; int main() { while (1) { int n; cin >> n; if (n == 0) break; int it[25]; int bl[25]; int sindex[25]; for (int i = 0; i < n; i++) { cin >> it[i] >> bl[i]; sindex[i] = i...
[["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22]]
1
284
4
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; bool myComparison(const pair<int, int> &a, const pair<int, int> &b) { return a.second < b.second; } int main() { int n = 0; vector<int> re; while (cin >> n, n != 0) { vector<pair<int, int>> v; for (int i ...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; bool myComparison(const pair<int, int> &a, const pair<int, int> &b) { return a.second < b.second; } int main() { int n = 0; vector<int> re; while (cin >> n, n != 0) { vector<pair<int, int>> v; for (int i ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
276
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct islands { int t; int w; bool operator>(const islands &left) const { return w >= left.w; } }; int main() { int n, i; vector<islands> island; while (1) { cin >> n; if (n == 0) break; for (i = 0; i < n...
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct islands { int t; int w; bool operator>(const islands &left) const { return w > left.w; } }; int main() { int n, i; vector<islands> island; while (1) { cin >> n; if (n == 0) break; for (i = 0; i < n;...
[["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 20], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 47], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
218
6
#include <algorithm> #include <functional> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <vector> #define PI 3.14159265 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define all(x) (x).begin(), (x).end() typedef long long ll; #define SZ(x) ((in...
#include <algorithm> #include <functional> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <vector> #define PI 3.14159265 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define all(x) (x).begin(), (x).end() typedef long long ll; #define SZ(x) ((in...
[["+", 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
251
4
#include <cstdlib> #include <iostream> using namespace std; struct island { int tre; int bri; }; int compare(const island *a, const island *b) { if ((*a).bri == (*b).bri) return (*a).tre - (*b).tre; else return (*a).bri - (*b).bri; } island isls[25]; int main() { for (;;) { int isl; cin ...
#include <cstdlib> #include <iostream> using namespace std; struct island { int tre; int bri; }; int compare(const island *a, const island *b) { if ((*a).bri == (*b).bri) return (*a).tre - (*b).tre; else return (*a).bri - (*b).bri; } island isls[25]; int main() { for (;;) { int isl; cin ...
[["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 44], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 44]]
1
247
2
#include <algorithm> #include <functional> #include <iostream> #include <vector> using namespace std; #define pii pair<int, int> int main() { int n; while (cin >> n, n) { vector<pii> v; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; v.push_back(pii(b, a)); } sort(v.begin(...
#include <algorithm> #include <functional> #include <iostream> #include <vector> using namespace std; #define pii pair<int, int> int main() { int n; while (cin >> n, n) { vector<pii> v; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; v.push_back(pii(b, a)); } sort(v.begin(...
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
162
4
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; typedef struct { int weight, bridge; } sima; bool lessw(const sima &Left, const sima &Right) { return Left.weight < Right.weight; } bool lessb(const sima &Left, const sima &Right) { return Left.bridge < Right.brid...
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; typedef struct { int weight, bridge; } sima; bool lessw(const sima &Left, const sima &Right) { return Left.weight < Right.weight; } bool lessb(const sima &Left, const sima &Right) { return Left.bridge < Right.brid...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
267
4
#include <algorithm> #include <stdio.h> using namespace std; pair<int, int> t[25]; int main() { int a; while (scanf("%d", &a), a) { for (int i = 0; i < a; i++) { scanf("%d%d", &t[i].first, &t[i].second); } std::sort(t, t + a); int now = 0; bool ok = true; for (int i = 0; i < a; i++) { ...
#include <algorithm> #include <stdio.h> using namespace std; pair<int, int> t[25]; int main() { int a; while (scanf("%d", &a), a) { for (int i = 0; i < a; i++) { scanf("%d%d", &t[i].second, &t[i].first); } std::sort(t, t + a); int now = 0; bool ok = true; for (int i = 0; i < a; i++) { ...
[["-", 0, 2, 3, 4, 0, 66, 28, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 66, 28, 118, 119, 120], ["-", 8, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["-", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120]]
1
159
8
#include <cassert> #include <climits> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <sstream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <algorithm> #include <cctype> #include <cmath> #include <list> ...
#include <cassert> #include <climits> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <sstream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <algorithm> #include <cctype> #include <cmath> #include <list> ...
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
252
4
#include <algorithm> #include <map> #include <stdio.h> int main() { int n, i, s; std::pair<int, int> b[25]; while (scanf("%d", &n), n) { for (i = 0; i < n; ++i) scanf("%d%d", &b[i].second, &b[i].first); std::sort(b, b + n); for (i = s = 0; i < n; ++i) { s += b[i].second; if (s > b[i]...
#include <algorithm> #include <map> #include <stdio.h> int main() { int n, i, s; std::pair<int, int> b[25]; while (scanf("%d", &n), n) { for (i = 0; i < n; ++i) scanf("%d%d", &b[i].second, &b[i].first); std::sort(b, b + n); for (i = s = 0; i < n; ++i) { s += b[i].second; if (s > b[i]...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
157
4
while True: n=eval(input()) if n==0:break p=[0]*n l=[[0]*31 for i in range(n)] a=sorted([input().split() for i in range(n)]) for j in range(n): for t in a[j][2:]: l[j][int(t)]=1 for t in range(1,30): c=0 for j in range(n): if l[j][t]:c+=1 for j in range(n): if l[j][t]: p[j]+=n-c+1 print(min...
while True: n=eval(input()) if n==0:break p=[0]*n l=[[0]*31 for i in range(n)] a=sorted([input().split() for i in range(n)]) for j in range(n): for t in a[j][2:]: l[j][int(t)]=1 for t in range(30): c=0 for j in range(n): if l[j][t]: c+=1 for j in range(n): if l[j][t]: p[j]+=n-c+1 print(...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21]]
5
176
2
#include <bits/stdc++.h> using namespace std; #define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X)) typedef long long ll; typedef pair<int, int> pii; #define all(X) (X).begin(), (X).end() #define pb push_back #define eb emplace_back #define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X)) #define X first #define Y sec...
#include <bits/stdc++.h> using namespace std; #define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X)) typedef long long ll; typedef pair<int, int> pii; #define all(X) (X).begin(), (X).end() #define pb push_back #define eb emplace_back #define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X)) #define X first #define Y sec...
[["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13]]
1
243
2
#include <bits/stdc++.h> using namespace std; typedef long long ll; int A, B, C; int main() { int a, b, c, d, e, f; while (cin >> a >> b >> c >> d >> e >> f && (a || b || c || d || e || f)) { A = a + d; B = b + e; C = c + f; // cout<< A << " "<< B << " " << C << endl; int n = min(A, min(B, ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int A, B, C; int main() { int a, b, c, d, e, f; while (cin >> a >> b >> c >> d >> e >> f && (a || b || c || d || e || f)) { A = a + d; B = b + e; C = c + f; // cout<< A << " "<< B << " " << C << endl; int n = min(A, min(B, ...
[["-", 8, 9, 0, 7, 15, 16, 12, 2, 63, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 2, 63, 22]]
1
189
2
#include <iostream> #include <vector> using namespace std; vector<string> split(const string &str, const string &delim) { vector<string> res; size_t current = 0, found, delimlen = delim.size(); while ((found = str.find(delim, current)) != string::npos) { res.push_back(string(str, current, found - current)); ...
#include <iostream> #include <vector> using namespace std; vector<string> split(const string &str, const string &delim) { vector<string> res; size_t current = 0, found, delimlen = delim.size(); while ((found = str.find(delim, current)) != string::npos) { res.push_back(string(str, current, found - current)); ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 146], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 147], ["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 28, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 147], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 146]]
1
421
7
while gets.chomp!='#' puts $_.split('|').all?{|e|a=e[1..e.size-2].split('&');a.select{|e|e[0,1]!='~'&&a.index('~'+e)}!=[]}?'no':'yes'end
while(l=gets.chomp)!='#' puts l.split('|').all?{|e|a=e[1..e.size-2].split('&');a.select{|e|e[0,1]!='~'&&a.index('~'+e)}!=[]}?'no':'yes'end
[["+", 0, 493, 0, 89, 15, 738, 31, 739, 0, 24], ["+", 0, 89, 15, 738, 31, 739, 0, 662, 31, 22], ["+", 0, 89, 15, 738, 31, 739, 0, 662, 0, 32], ["+", 0, 493, 0, 89, 15, 738, 31, 739, 0, 25], ["-", 3, 4, 0, 754, 15, 652, 486, 652, 486, 744], ["+", 3, 4, 0, 754, 15, 652, 486, 652, 486, 22]]
4
85
17
#include <algorithm> #include <stdio.h> using namespace std; int d[51000]; int e[51000]; int f[51000]; int row[51000]; int col[51000]; int main() { int a, b, c; while (scanf("%d%d%d", &a, &b, &c), a) { for (int i = 0; i < a; i++) row[i] = 1; for (int j = 0; j < b; j++) col[j] = 1; for (int i...
#include <algorithm> #include <stdio.h> using namespace std; int d[51000]; int e[51000]; int f[51000]; int row[51000]; int col[51000]; int main() { int a, b, c; while (scanf("%d%d%d", &a, &b, &c), a) { for (int i = 0; i < a; i++) row[i] = 1; for (int j = 0; j < b; j++) col[j] = 1; for (int i...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["-", 64, 9, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 64, 9, 0, 57, 64, 1, 0, 11, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 27, 28, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 9, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 9, 0, 57, 64, ...
1
278
8
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int order[100000][3]; bool check_r[100000]; bool check_c[100000]; int main() { int r, c, q; while (true) { cin >> r >> c >> q; if (r == 0 && c == 0 ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int order[100000][3]; bool check_r[100000]; bool check_c[100000]; int main() { int r, c, q; while (true) { cin >> r >> c >> q; if (r == 0 && c == 0 ...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22]]
1
321
4
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <sstream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define fr(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); i...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <sstream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define fr(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); i...
[["-", 0, 57, 64, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 31, 22]]
1
309
4
#include <cstdio> #include <cstring> using namespace std; typedef long long int64; const int MAX_W = 50000; const int MAX_Q = 50000; int H, W, Q; int ts[MAX_Q], as[MAX_Q], cmd[MAX_Q]; bool visited[2][MAX_W]; bool init() { scanf("%d%d%d", &H, &W, &Q); for (int i = 0; i < Q; i++) { scanf("%d%d%d", ts + i, as ...
#include <cstdio> #include <cstring> using namespace std; typedef long long int64; const int MAX_W = 50000; const int MAX_Q = 50000; int H, W, Q; int ts[MAX_Q], as[MAX_Q], cmd[MAX_Q]; bool visited[2][MAX_W]; bool init() { scanf("%d%d%d", &H, &W, &Q); for (int i = 0; i < Q; i++) { scanf("%d%d%d", ts + i, as ...
[["-", 0, 11, 12, 16, 31, 23, 0, 41, 64, 22], ["-", 0, 11, 12, 16, 31, 23, 0, 41, 0, 102], ["+", 0, 11, 12, 16, 31, 23, 0, 41, 0, 102], ["+", 0, 11, 12, 16, 31, 23, 0, 41, 75, 22]]
1
285
4
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; struct P { int point; string name; P() {} P(int point, string name) : point{point}, name{name} {} bool operator<(const P &p) const { if (point != p.point) { return point > p.point; } return nam...
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; struct P { int point; string name; P() {} P(int point, string name) : point{point}, name{name} {} bool operator<(const P &p) const { if (point != p.point) { return point > p.point; } return nam...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
542
2
#include <algorithm> #include <iostream> #include <numeric> #include <utility> #include <vector> using namespace std; typedef pair<int, int> P; int main() { for (int N; cin >> N, N;) { vector<P> v; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; v.push_back(make_pair(b, a)); } ...
#include <algorithm> #include <iostream> #include <numeric> #include <utility> #include <vector> using namespace std; typedef pair<int, int> P; int main() { for (int N; cin >> N, N;) { vector<P> v; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; v.push_back(make_pair(b, a)); } ...
[["-", 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
223
4
#include <iostream> #include <set> using namespace std; int main(void) { int n; int temp1, temp2; int i1; int ok; while (1) { cin >> n; if (n == 0) break; set<pair<int, int>> w; int sum; for (i1 = 0; i1 < n; i1++) { cin >> temp1 >> temp2; w.insert(make_pair(temp2, te...
#include <iostream> #include <set> using namespace std; int main(void) { int n; int temp1, temp2; int i1; int ok; while (1) { cin >> n; if (n == 0) break; multiset<pair<int, int>> w; int sum; for (i1 = 0; i1 < n; i1++) { cin >> temp1 >> temp2; w.insert(make_pair(temp...
[["-", 0, 52, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 52, 8, 9, 0, 43, 39, 344, 141, 78]]
1
182
2
#include <algorithm> #include <cstdlib> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define INF 100000000 typedef long long int lli; typedef pair<int, int> P; int ...
#include <algorithm> #include <cstdlib> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define INF 100000000 typedef long long int lli; typedef pair<int, int> P; int ...
[["-", 15, 339, 51, 16, 31, 16, 12, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 16, 12, 118, 119, 120]]
1
321
2
class Q1052 def doIt n = gets.to_i island = Struct.new("Island", :treasure, :bridge) while n > 0 ary = Array.new for i in 0..n-1 t = gets.split(" ").map{|x| x.to_i} is = island.new(t[0], t[1]) ary.push is end ary.sort!{|a, b| a.treasure <=> b.treasure} ...
class Q1052 def doIt n = gets.to_i island = Struct.new("Island", :treasure, :bridge) while n > 0 ary = Array.new for i in 0..n-1 t = gets.split(" ").map{|x| x.to_i} is = island.new(t[0], t[1]) ary.push is end ary.sort!{|a, b| a.bridge <=> b.bridge} sum...
[["-", 196, 196, 8, 734, 0, 738, 31, 652, 735, 22], ["+", 196, 196, 8, 734, 0, 738, 31, 652, 735, 22], ["-", 196, 196, 8, 734, 0, 738, 12, 652, 735, 22], ["+", 196, 196, 8, 734, 0, 738, 12, 652, 735, 22]]
4
163
4
while True: n = eval(input()) if n == 0: break info = [] for i in range(n): lu, w = list(map(int, input().split())) info.append((w, lu)) info.sort() lu_sum = 0 flag = True for w, lu in info: lu_sum += lu if lu_sum > w: flag = False print(("...
while True: n = eval(input()) if n == 0: break info = [] for i in range(n): lu, w = list(map(int, input().split())) info.append((w, lu)) info.sort() lu_sum = 0 flag = True for w, lu in info: lu_sum += lu if lu_sum > w: flag = False print(("...
[["-", 3, 4, 0, 23, 0, 41, 0, 557, 0, 6], ["+", 3, 4, 0, 23, 0, 41, 0, 557, 0, 6]]
5
101
4
while(1): n=int(input()) if n==0: break A=[[0,0] for i in range(n)] for i in range(n): [a,b]=list(map(int,input().split())) A[i]=[a,b] A.sort(key= lambda x: x[0]) s=0 for i in range(n): if s+A[i][0]>A[i][1]: print('No') break else: ...
while(1): n=int(input()) if n==0: break A=[[0,0] for i in range(n)] for i in range(n): [a,b]=list(map(int,input().split())) A[i]=[a,b] A.sort(key= lambda x: x[1]) s=0 for i in range(n): if s+A[i][0]>A[i][1]: print('No') break else: ...
[["-", 3, 4, 0, 653, 51, 670, 8, 206, 206, 612], ["+", 3, 4, 0, 653, 51, 670, 8, 206, 206, 612]]
5
144
2
while True: n = int(input()) if n == 0: break z = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1]) cnt = total = 0 for a, b in z: total += a if total > b: cnt = 1 break print("Yes" if cnt else "No")
while True: n = int(input()) if n == 0: break z = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1]) cnt = total = 0 for a, b in z: total += a if total > b: cnt = 1 break print("No" if cnt else "Yes")
[["-", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6]]
5
92
17
def solve(l): have = 0 for m, w in l: have += w if m < have: return "NO" return "YES" while True: n = eval(input()) if n == 0: break l = sorted([tuple(reversed(list(map(int, input().split())))) for i in range(n)]) print(solve(l))
def solve(l): have = 0 for m, w in l: have += w if m < have: return "No" return "Yes" while True: n = eval(input()) if n == 0: break l = sorted([tuple(reversed(list(map(int, input().split())))) for i in range(n)]) print(solve(l))
[["-", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6], ["+", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6], ["-", 0, 14, 8, 196, 0, 37, 0, 557, 0, 6], ["+", 0, 14, 8, 196, 0, 37, 0, 557, 0, 6]]
5
91
4
#include <algorithm> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #define Epsilon 0.000001 using namespace std; double cal1(double x, double y) { return sqrt(x * x + y * y); } double cal2(double a, double b, double c, double d) { return a * b + c * d; } ...
#include <algorithm> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #define Epsilon 0.000001 using namespace std; double cal1(double x, double y) { return sqrt(x * x + y * y); } double cal2(double a, double b, double c, double d) { return a * b + c * d; } ...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]]
1
295
2
#include <algorithm> #include <complex> #include <vector> using namespace std; const double EPS = 1e-7; typedef complex<double> P; /* “_ */ typedef vector<P> G; /* ‘½ŠpŒ` */ struct L { P p, q; L(P p, P q) : p(p), q(q) {} }; /* ü•ª */ // “àÏEŠOÏEŠp“x double dot(P a, P b) { return real(conj(a) * b); } do...
#include <algorithm> #include <complex> #include <vector> using namespace std; const double EPS = 1e-7; typedef complex<double> P; /* “_ */ typedef vector<P> G; /* ‘½ŠpŒ` */ struct L { P p, q; L(P p, P q) : p(p), q(q) {} }; /* ü•ª */ // “àÏEŠOÏEŠp“x double dot(P a, P b) { return real(conj(a) * b); } do...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
1,651
4
// AOJ1053 Accelerated Railgun #include <complex> #include <iostream> using namespace std; typedef complex<double> P; double dot(P a, P b) { return real(conj(a) * b); } double cross(P a, P b) { return imag(conj(a) * b); } int main() { double d; while (cin >> d) { if (d == 0.0) break; double px, p...
// AOJ1053 Accelerated Railgun #include <complex> #include <iostream> using namespace std; typedef complex<double> P; double dot(P a, P b) { return real(conj(a) * b); } double cross(P a, P b) { return imag(conj(a) * b); } int main() { double d; while (cin >> d) { if (d == 0.0) break; double px, p...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
198
3
#include <cmath> #include <iomanip> #include <iostream> #define PI (3.1415926535897932384626433832795) #define SQ(x) ((x) * (x)) #define LEN(x, y) (sqrt(SQ(x) + SQ(y))) using namespace std; bool eq(double a, double b) { return fabs(a - b) < 1e-8; } double prod(double x1, double y1, double x2, double y2) { return ...
#include <cmath> #include <iomanip> #include <iostream> #define PI (3.1415926535897932384626433832795) #define SQ(x) ((x) * (x)) #define LEN(x, y) (sqrt(SQ(x) + SQ(y))) using namespace std; bool eq(double a, double b) { return fabs(a - b) < 1e-8; } double prod(double x1, double y1, double x2, double y2) { return ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
228
2
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vecto...
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vecto...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
429
3
#include <bits/stdc++.h> using namespace std; #define EPS 1e-6 #define INF 1e8 typedef complex<double> P; double dot(P a, P b) { return real(conj(a) * b); } double cross(P a, P b) { return imag(conj(a) * b); } struct Point { double x, y; }; int main() { double D; while (true) { Point v, p; scanf("...
#include <bits/stdc++.h> using namespace std; #define EPS 1e-6 #define INF 1e8 typedef complex<double> P; double dot(P a, P b) { return real(conj(a) * b); } double cross(P a, P b) { return imag(conj(a) * b); } struct Point { double x, y; }; int main() { double D; while (true) { Point v, p; scanf("...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
250
25
#include <bits/stdc++.h> using namespace std; using Int = long long; struct UnionFind { Int n; vector<Int> r, p; UnionFind(Int n) : n(n), r(n, 1), p(n) { iota(p.begin(), p.end(), 0); } Int find(Int x) { if (x == p[x]) return x; return p[x] = find(p[x]); } void unite(Int x, Int y) { x = ...
#include <bits/stdc++.h> using namespace std; using Int = long long; struct UnionFind { Int n; vector<Int> r, p; UnionFind(Int n) : n(n), r(n, 1), p(n) { iota(p.begin(), p.end(), 0); } Int find(Int x) { if (x == p[x]) return x; return p[x] = find(p[x]); } void unite(Int x, Int y) { x = fi...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
472
4
#include <iostream> #include <map> #include <stack> #include <vector> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef pair<int, int> PII; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c)...
#include <iostream> #include <map> #include <stack> #include <vector> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef pair<int, int> PII; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c)...
[["+", 28, 69, 28, 69, 341, 342, 0, 69, 28, 22], ["+", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 12, 118, 28, 69, 28, 69, 341, 342, 0, 70]]
1
807
6