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 <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define all(v) (v).begin(), (v).end() #d...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define all(v) (v).begin(), (v).end() #d...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
388
2
import java.util.Scanner; public class Main { public static void main(String[] args) { int millennium = getNumberOfDates(1000, 1, 1); Scanner s = new Scanner(System.in); int line = s.nextInt(); for (int i = 1; i < line; i++) { int year = s.nextInt(); int month = s.nextInt(); int da...
import java.util.Scanner; public class Main { public static void main(String[] args) { int millennium = getNumberOfDates(1000, 1, 1); Scanner s = new Scanner(System.in); int line = s.nextInt(); for (int i = 0; i < line; i++) { int year = s.nextInt(); int month = s.nextInt(); int da...
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
245
4
#include <stdio.h> int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int y, m, d; scanf("%d%d%d", &y, &m, &d); int answer = 1; for (int j = y; j < 1000; j++) { if (j % 3) { answer += 195; } else { answer += 200; } } if (y % 3) { for...
#include <stdio.h> int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int y, m, d; scanf("%d%d%d", &y, &m, &d); int answer = 1; for (int j = y; j < 1000; j++) { if (j % 3) { answer += 195; } else { answer += 200; } } if (y % 3) { for...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22]]
0
180
2
Y, M, D; main(n) { for (scanf("%d", &n); Y = n--; scanf("%d%d%d", &Y, &M, &D)) Y--, M--, printf("%d\n", 196471 - Y * 195 - Y / 3 * 5 - M * 20 + ((Y + 1) % 3 ? M / 2 : 0) - D); }
Y, M, D; main(n) { for (scanf("%d", &n); Y = n--; scanf("%d%d%d", &Y, &M, &D), Y--, M--, printf("%d\n", 196471 - Y * 195 - Y / 3 * 5 - M * 20 + (++Y % 3 ? M / 2 : 0) - D)) ; }
[["-", 0, 30, 0, 14, 8, 9, 0, 7, 0, 25], ["+", 0, 14, 8, 9, 0, 7, 26, 34, 0, 21], ["-", 3, 4, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 41, 15, 16, 31, 27, 17, 29], ["-", 0, 41, 15, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 41, 15, 16, 31, 23, 0, 16, 12, 13], ["-", 12, 23, 0, 41, 15, 16, 31, 23, 0, 25], ["+", 12, 34, ...
0
93
8
#include <stdio.h> int main() { int s, n, y, m, d, t, i; s = 39 * 5 * 999 + 333 * 5 + 1; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d%d%d", &y, &m, &d); if (m % 2 == 0) t = (y - 1) * 39 * 5 + ((m - 1) / 2) * 20 + ((m - 1) / 2) * 19 + d + 5 * ((y - 1) / 3); else t = (y ...
#include <stdio.h> int main() { int s, n, y, m, d, t, i; s = 39 * 5 * 999 + 333 * 5 + 1; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d%d%d", &y, &m, &d); if (m % 2 == 0) t = (y - 1) * 39 * 5 + (m / 2) * 20 + ((m - 1) / 2) * 19 + d + 5 * ((y - 1) / 3); else t = (y - 1) *...
[["-", 12, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 12, 13], ["-", 12, 16, 31, 23, 0, 16, 31, 23, 0, 25]]
0
237
4
#include <stdio.h> int main() { int n, i, j, All = 196471, Y, M, D, sum; scanf("%d", &n); for (j = 0, sum = 0; j < n; j++, sum = 0) { scanf("%d %d %d", &Y, &M, &D); for (i = 1; i < Y; i++) { if (j % 3 == 0) { sum += 200; } else { sum += 195; } } for (i = 1; i < ...
#include <stdio.h> int main() { int n, i, j, All = 196471, Y, M, D, sum; scanf("%d", &n); for (j = 0, sum = 0; j < n; j++, sum = 0) { scanf("%d %d %d", &Y, &M, &D); for (i = 1; i < Y; i++) { if (i % 3 == 0) { sum += 200; } else { sum += 195; } } for (i = 1; i < ...
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 31, 22]]
0
173
2
#include <stdio.h> int main() { int n, y, m, d; int year_sum[1024] = {0}; int month_sum[16] = {0}; int sum = 0; int i; for (i = 1; i < 1024; i++) { if (i % 3 == 0) year_sum[i] = 20 * 10 + year_sum[i - 1]; else year_sum[i] = 20 * 5 + 19 * 5 + year_sum[i - 1]; } for (i = 1; i < 16;...
#include <stdio.h> int main() { int n, y, m, d; int year_sum[1024] = {0}; int month_sum[16] = {0}; int sum = 0; int i; for (i = 1; i < 1024; i++) { if (i % 3 == 0) year_sum[i] = 20 * 10 + year_sum[i - 1]; else year_sum[i] = 20 * 5 + 19 * 5 + year_sum[i - 1]; } for (i = 1; i < 16;...
[["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
262
2
#include <stdio.h> int main(void) { int i, n; scanf("%d", &n); for (i = 0; i < n; i++) { int y, m, d, total = 0; scanf("%d %d %d", &y, &m, &d); if (y % 3 == 0) { total += (999 - y) / 3 * 590; total += (10 - m) * 20; total += 21 - d; } else if (y % 3 == 1) { total += (997 -...
#include <stdio.h> int main(void) { int i, n; scanf("%d", &n); for (i = 0; i < n; i++) { int y, m, d, total = 0; scanf("%d %d %d", &y, &m, &d); if (y % 3 == 0) { total += (999 - y) / 3 * 590; total += (10 - m) * 20; total += 21 - d; } else if (y % 3 == 1) { total += (997 -...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
0
285
2
#include <cstdio> using namespace std; int n; int y, m, d; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d%d", &y, &m, &d); int cnt = 0; while (!(y == 1000 && m == 1 && d == 1)) { int days = 19; if (y % 3 == 0 || m % 2 == 0) days = 20; cnt += days - d...
#include <cstdio> using namespace std; int n; int y, m, d; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d%d", &y, &m, &d); int cnt = 0; while (!(y == 1000 && m == 1 && d == 1)) { int days = 19; if (y % 3 == 0 || m % 2 == 1) days = 20; cnt += days - d...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
151
2
#include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int Y, M, D; cin >> Y >> M >> D; int offset = (10 - M + 1) * 20 - (D - 1); if (Y % 3 != 0) { offset -= (10 - M + 1) / 2; //小の月の分を引く。 int/intだが問題ない } Y++; int uruutime = (1002 -...
#include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int Y, M, D; cin >> Y >> M >> D; int offset = (10 - M + 1) * 20 - (D - 1); if (Y % 3 != 0) { offset -= (12 - M) / 2; //小の月の分を引く。 int/intだが問題ない } Y++; int uruutime = (1002 - Y) ...
[["-", 12, 16, 31, 23, 0, 16, 31, 16, 31, 13], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 13], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13]]
1
132
13
#include <bits/stdc++.h> #define _ \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; const int mill = 196471; const int nYear = ...
#include <bits/stdc++.h> #define _ \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; const int mill = 196471; const int nYear = ...
[["+", 0, 16, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 16, 12, 16, 31, 16, 31, 23, 0, 25]]
1
138
4
#include <iostream> using namespace std; int main() { int n, y, m, d; int y3, yd, m2, md, dd, y2; cin >> n; for (int i = 0; i < n; i++) { cin >> y >> m >> d; if (y % 3 != 0) y2 = y + (3 - y % 3); else y2 = y; y3 = 334 - y2 / 3; yd = y3 * 200 + (1000 - y - y3) * 195; m2 =...
#include <iostream> using namespace std; int main() { int n, y, m, d; int y3, yd, m2, md, dd, y2; cin >> n; for (int i = 0; i < n; i++) { cin >> y >> m >> d; if (y % 3 != 0) y2 = y + (3 - y % 3); else y2 = y; y3 = 334 - y2 / 3; yd = y3 * 200 + (1000 - y - y3) * 195; m2 =...
[["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
196
2
#include <iostream> using namespace std; int main() { int y, m, d, i, times, D1, D2, D3; cin >> times; i = 0; while (1) { i++; if (i > times) { break; } cin >> y >> m >> d; D1 = (y - 1) / 3 * 200 + ((y - 1) - (y - 1) / 3) * 195; if (y % 3 == 0) { D2 = (m - 1) * 20 + d; } ...
#include <iostream> using namespace std; int main() { int y, m, d, i, times, D1, D2, D3; cin >> times; i = 0; while (1) { i++; if (i > times) { break; } cin >> y >> m >> d; D1 = (y - 1) / 3 * 200 + ((y - 1) - (y - 1) / 3) * 195; if (y % 3 == 0) { D2 = (m - 1) * 20 + d; } ...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]]
1
156
2
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0, num[3], ans; i < n; i++) { for (int j = 0; j < 3; j++) cin >> num[j]; num[0]--; num[1]--; if ((num[0] + 1) % 3 == 0) ans = num[1] * 20; else ans = num[1] / 2 * 39 + num[1] % 2 * 20; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0, num[3], ans; i < n; i++) { for (int j = 0; j < 3; j++) cin >> num[j]; num[0]--; num[1]--; if ((num[0] + 1) % 3 == 0) ans = num[1] * 20; else ans = num[1] / 2 * 39 + num[1] % 2 * 20; ...
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 72], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 17, 33], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33]]
1
151
20
#include <iostream> using namespace std; int main() { int n, i, c, y, m, d; cin >> n; while (n--) { c = y = m = d = 0; cin >> y >> m >> d; if (y % 3 != 0 && m % 2 == 0) c += 20 - d; else c += 21 - d; for (i = m + 1; m <= 10; m++) { if (y % 3 != 0 && m % 2 == 0) c += 1...
#include <iostream> using namespace std; int main() { int n, i, c, y, m, d; cin >> n; while (n--) { c = y = m = d = 0; cin >> y >> m >> d; if (y % 3 != 0 && m % 2 == 0) c += 20 - d; else c += 21 - d; for (i = m + 1; i <= 10; i++) { if (y % 3 != 0 && i % 2 == 0) c += 1...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 15, 339, 51, 16, 12, 16, 31, 16, 31, 22], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0,...
1
161
12
#include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 0 #define dump(o) \ if (DBG) { \ cerr << #o << " " << o << endl; ...
#include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 0 #define dump(o) \ if (DBG) { \ cerr << #o << " " << o << endl; ...
[["-", 64, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["-", 31, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 31, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["-", 64, 16, 31, 16, 31, 16, 31, 23, 0, 25], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 13]]
1
270
6
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { int n, Y[110], M[110], D[110], sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> Y[i] >> M[i] >> D[i]; sum = 0; if (Y[i] % 3 == 0) { for (int j = 1; j < Y[i]; j++) { if (j % ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { int n, Y[110], M[110], D[110], sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> Y[i] >> M[i] >> D[i]; sum = 0; if (Y[i] % 3 == 0) { for (int j = 1; j < Y[i]; j++) { if (j % ...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["-", 0, 57, 75, 76, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 12, 13]]
1
243
4
#include "bits/stdc++.h" using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int d1[10] = {20, 19, 20, 19, 20, 19, 20, 19, 20, 19}; int d2[10] = {20, 20, 20, 20, 20, 20, 20, 20, 20, 20}; int Sd1 = 20 * 10 - 5; int Sd2 = 20 * 10; int SD = 196471; int n; cin >> n; int Y, M, D; ...
#include "bits/stdc++.h" using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int d1[10] = {20, 19, 20, 19, 20, 19, 20, 19, 20, 19}; int d2[10] = {20, 20, 20, 20, 20, 20, 20, 20, 20, 20}; int Sd1 = 20 * 10 - 5; int Sd2 = 20 * 10; int SD = 196471; int n; cin >> n; int Y, M, D; ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
257
4
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int mill = 1 + 999 * (20 * 10 - 5) + 333 * 5; for (int i = 0; i < n; ++i) { int y, m, d; cin >> y >> m >> d; int byear = (y - 1) / 3; int ans = d; if (y % 3 == 0) { ans += (m - 1) * 20; } else { ans...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int mill = 1 + 999 * (20 * 10 - 5) + 333 * 5; for (int i = 0; i < n; ++i) { int y, m, d; cin >> y >> m >> d; int byear = (y - 1) / 3; int ans = d; if (y % 3 == 0) { ans += (m - 1) * 20; } else { ans...
[["-", 0, 11, 12, 16, 12, 16, 31, 23, 0, 24], ["-", 12, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["-", 12, 16, 12, 16, 31, 23, 0, 16, 12, 13], ["-", 0, 11, 12, 16, 12, 16, 31, 23, 0, 25]]
1
161
4
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <set> #include <stack> #include <vector> using namespace std; int hoge[1000][10][20]; void Ini() { int cnt = 196470; f...
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <set> #include <stack> #include <vector> using namespace std; int hoge[1000][10][20]; void Ini() { int cnt = 196470; f...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
247
4
#include <iostream> #include <stdlib.h> using namespace std; int n; int y; int m; int d; int main() { cin >> n; for (int i = 0; i < n; i++) { int days = 0; cin >> y >> m >> d; if (d != 1) { if (m % 2 == 1 || y % 3 == 0) { days += 20 - d; } else { days += 19 - d; } ...
#include <iostream> #include <stdlib.h> using namespace std; int n; int y; int m; int d; int main() { cin >> n; for (int i = 0; i < n; i++) { int days = 0; cin >> y >> m >> d; if (d != 1) { if (m % 2 == 1 || y % 3 == 0) { days += 21 - d; } else { days += 20 - d; } ...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 31, 13]]
1
191
4
import sys if sys.version_info[0]>=3: raw_input=input n=int(raw_input()) for i in range(0,n): a=[int(e) for e in raw_input().split()] a[0]-=1;a[1]-=1 print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])
import sys if sys.version_info[0]>=3: raw_input=input n=int(raw_input()) for i in range(0,n): a=[int(e) for e in raw_input().split()] a[0]-=1;a[1]-=1 print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2])
[["-", 31, 657, 31, 657, 12, 657, 31, 657, 17, 85], ["+", 31, 657, 31, 657, 12, 657, 31, 657, 17, 676], ["-", 31, 657, 12, 23, 0, 41, 0, 657, 17, 85], ["+", 31, 657, 12, 23, 0, 41, 0, 657, 17, 676]]
5
116
4
def day(y, m, d): days = 0 days += (y-1)*195 days += (y-1)//3*5 days += (m-1)*19 if y%3 == 0: days += (m-1) else: days += (m-1)//2 days += (d-1) return days def main(): n = int(input()) for _ in range(n): (y, m, d) = [int(x) for x in input().split()] ...
def day(y, m, d): days = 0 days += (y-1)*195 days += (y-1)//3*5 days += (m-1)*19 if y%3 == 0: days += (m-1) else: days += m//2 days += (d-1) return days def main(): n = int(input()) for _ in range(n): (y, m, d) = [int(x) for x in input().split()] ...
[["-", 0, 1, 0, 677, 12, 657, 31, 23, 0, 24], ["-", 0, 677, 12, 657, 31, 23, 0, 657, 17, 33], ["-", 0, 677, 12, 657, 31, 23, 0, 657, 12, 612], ["-", 0, 1, 0, 677, 12, 657, 31, 23, 0, 25]]
5
151
4
M = [20, 19] Y = sum(M) * 5 for i in range(int(input())): res = 0 y,m,d = list(map(int,input().split())) for y_2 in range(1000-1, y, -1): res += Y if y_2 % 3 != 0 else 200 for m_2 in range(10, m, -1): res += M[m_2 % 2] if y % 3 != 0 else 20 res += (M[m%2] if y % 3 != 0 else 20) - ...
M = [19, 20] Y = sum(M) * 5 for i in range(int(input())): res = 0 y,m,d = list(map(int,input().split())) for y_2 in range(1000-1, y, -1): res += Y if y_2 % 3 != 0 else 200 for m_2 in range(10, m, -1): res += M[m_2 % 2] if y % 3 != 0 else 20 res += (M[m%2] if y % 3 != 0 else 20) - ...
[["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612], ["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 21], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 21], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612]]
5
133
4
#include <bits/stdc++.h> using namespace std; vector<int> mini, maxi, arr; int a, l; void num(vector<int> &ll, vector<int> &ss) { int t = 1; int llcp = ll[l - 1], sscp = ss[l - 1]; for (int i = l - 2; i >= 0; i--) { t *= 10; llcp += ll[i] * t; sscp += ss[i] * t; // cout << ll[i] << " " << ss[i...
#include <bits/stdc++.h> using namespace std; vector<int> mini, maxi, arr; int a, l; void num(vector<int> &ll, vector<int> &ss) { int t = 1; int llcp = ll[l - 1], sscp = ss[l - 1]; for (int i = l - 2; i >= 0; i--) { t *= 10; llcp += ll[i] * t; sscp += ss[i] * t; // cout << ll[i] << " " << ss[i...
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 12, 22]]
1
468
2
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int a, l; int i, j, k; int king, kingpoint, flag; int rank[10], past[30]; char max[10], min[10]; while (1) { scanf("%d %d", &a, &l); if (a + l == 0) { break; } past[0] = a; for (i = 0;; ++i) { // テ、...
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int a, l; int i, j, k; int king, kingpoint, flag; int rank[10], past[30]; char max[10], min[10]; while (1) { scanf("%d %d", &a, &l); if (a + l == 0) { break; } past[0] = a; for (i = 1;; ++i) { // テ、...
[["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
1
325
4
#include <iostream> using namespace std; int search(int *a, int N, int *s) { for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (a[i] == a[j]) { *s = j - i; return j; } } } return -1; } int main(void) { while (true) { int L, N = 21; int *a = new in...
#include <iostream> using namespace std; int search(int *a, int N, int *s) { for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (a[i] == a[j]) { *s = j - i; return i; } } } return -1; } int main(void) { while (true) { int L, N = 21; int *a = new in...
[["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 22]]
1
445
2
#include <algorithm> #include <iostream> #include <stdlib.h> #include <string> using namespace std; string Hen(int N) { string S; char s; while (N != 0) { s = '0' - N % 10; S.insert(S.begin(), s); N /= 10; } return S; } int main() { string S, T[40]; int L, N, M, j, len, flag; while (1) { ...
#include <algorithm> #include <iostream> #include <stdlib.h> #include <string> using namespace std; string Hen(int N) { string S; char s; while (N != 0) { s = '0' - N % 10; S.insert(S.begin(), s); N /= 10; } return S; } int main() { string S, T[40]; int L, N, M, j, len, flag; while (1) { ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
414
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < (n); i++) #define ALL(s) (s).begin(), (s).end() #...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < (n); i++) #define ALL(s) (s).begin(), (s).end() #...
[["-", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 52, 8, 9, 0, 9, 0, 1, 0, 35]]
1
394
5
#include <algorithm> #include <iostream> #include <map> #include <stdio.h> #include <stdlib.h> #include <vector> using namespace std; int main() { vector<int> S; map<int, int> temp; int a, L, min, max; while (1) { bool FLAG = false; cin >> a >> L; if (!a && !L) break; if (a == 0) { ...
#include <algorithm> #include <iostream> #include <map> #include <stdio.h> #include <stdlib.h> #include <vector> using namespace std; int main() { vector<int> S; map<int, int> temp; int a, L, min, max; while (1) { bool FLAG = false; cin >> a >> L; if (!a && !L) break; if (a == 0) { ...
[["+", 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
332
6
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using std::cin; using std::cout; using std::endl; using std::vector; int digit(int n, int d) { int m = (int)(n / pow(10, d)) * pow(10, d); return (n - m) / pow(10, d - 1); } int max_deci(int n, int l) { int ret = 0; vector<int> d(l);...
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using std::cin; using std::cout; using std::endl; using std::vector; int digit(int n, int d) { int m = (int)(n / pow(10, d)) * pow(10, d); return (n - m) / pow(10, d - 1); } int max_deci(int n, int l) { int ret = 0; vector<int> d(l);...
[["-", 0, 7, 15, 16, 12, 16, 12, 16, 12, 13], ["+", 0, 7, 15, 16, 12, 16, 12, 16, 12, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
546
4
#include <bits/stdc++.h> using namespace std; const long long INF = 1e7 + 1; const long long MOD = 1000000007; const long double PI = 3.1415926; #define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++) #define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e7 + 1; const long long MOD = 1000000007; const long double PI = 3.1415926; #define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++) #define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(...
[["+", 64, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
551
6
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char *argv[]) { for (;;) { int a, l; cin >> a >> l; if (a == 0 && l == 0) break; vector<int> ss(6); vector<int> done(2000000, -1); for (int k = 0;; k++) { if (done[a...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char *argv[]) { for (;;) { int a, l; cin >> a >> l; if (a == 0 && l == 0) break; vector<int> ss(l); vector<int> done(2000000, -1); for (int k = 0;; k++) { if (done[a...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
239
2
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; vector<int> a; int L; string intString(int n) { stringstream ss; int keta = 1, tmp; tmp = n; while (tmp != 0) { tmp /= 10; keta++; } for (int i = 0; i <= (L - keta); i++) ss << 0...
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; vector<int> a; int L; string intString(int n) { stringstream ss; int keta = 1, tmp; tmp = n; while (tmp != 0) { tmp /= 10; keta++; } for (int i = 0; i <= (L - keta); i++) ss << 0...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 73], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 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], ["+", 0, 2, 3, 4, 0...
1
311
8
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> //-- #include <bitset> #include <cstdio> #include <cstring> #include <deque> #include <list> #include <map> #include <set> #include <...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> //-- #include <bitset> #include <cstdio> #include <cstring> #include <deque> #include <list> #include <map> #include <set> #include <...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
314
4
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i < b; i++) #define all(v) (v).begin(), (v).end() #define MP make_pair u...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i < b; i++) #define all(v) (v).begin(), (v).end() #define MP make_pair u...
[["+", 0, 2, 3, 4, 0, 16, 31, 2, 63, 22], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
523
3
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (i...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (i...
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
860
2
#include <cstring> #include <iostream> #include <queue> using namespace std; typedef struct a { int x; int y; } coordin; int h, w, c; int res = 0; int maze[8][8]; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; void changeColor(int tmp[8][8], int color) { int originColor = tmp[0][0]; queue<coordin> q;...
#include <cstring> #include <iostream> #include <queue> using namespace std; typedef struct a { int x; int y; } coordin; int h, w, c; int res = 0; int maze[8][8]; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; void changeColor(int tmp[8][8], int color) { int originColor = tmp[0][0]; queue<coordin> q;...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
624
4
#include <iostream> #include <stack> #include <utility> #include <vector> using namespace std; vector<vector<bool>> getunion(const vector<vector<int>> &base) { vector<vector<bool>> ret; stack<pair<int, int>> nxt; int xmax = base[0].size(); int ymax = base.size(); int tar = base[0][0]; int curx, cury; ret...
#include <iostream> #include <stack> #include <utility> #include <vector> using namespace std; vector<vector<bool>> getunion(const vector<vector<int>> &base) { vector<vector<bool>> ret; stack<pair<int, int>> nxt; int xmax = base[0].size(); int ymax = base.size(); int tar = base[0][0]; int curx, cury; ret...
[["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
794
7
$dx = [0,1,0,-1] $dy = [1,0,-1,0] def bfs(f, sy, sx, h, w, col) q = [[sy,sx]] visited = [[sy,sx]] while q.size > 0 sy, sx = q.shift for i in 0..3 cy = sy + $dy[i] cx = sx + $dx[i] if cy.between?(0,h-1) && cx.between?(0,w-1) && f[cy][cx]== f[sy][sx] && !vis...
$dx = [0,1,0,-1] $dy = [1,0,-1,0] def bfs(f, sy, sx, h, w, col) q = [[sy,sx]] visited = [[sy,sx]] while q.size > 0 sy, sx = q.shift for i in 0..3 cy = sy + $dy[i] cx = sx + $dx[i] if cy.between?(0,h-1) && cx.between?(0,w-1) && f[cy][cx]== f[sy][sx] && !vis...
[["-", 0, 652, 196, 737, 8, 736, 0, 652, 735, 22], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 486, 22], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 17, 131], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 735, 22]]
4
584
4
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #...
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
622
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>>; const ld eps = 1e-9; // < "D:\D_Download\Visual Studio // 2015\Projects\programing_contest_c++\Debug\a.txt" /* ???...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; // < "D:\D_Download\Visual Studio // 2015\Projects\programing_contest_c++\Debug\a.txt" /* ???...
[["-", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22]]
1
5,618
2
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <str...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <str...
[["+", 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
502
6
#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, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22]]
1
532
4
#include "bits/stdc++.h" using namespace std; #define mod 1000000007 #define all(c) begin(c), end(c) template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); } using ll = long long; using vi = vector<int>; using vs = vector<strin...
#include "bits/stdc++.h" using namespace std; #define mod 1000000007 #define all(c) begin(c), end(c) template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); } using ll = long long; using vi = vector<int>; using vs = vector<strin...
[["+", 3, 4, 0, 16, 31, 69, 341, 342, 0, 73], ["-", 12, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
1
607
2
loop { a,l = gets.split.map{|s|s.to_i} if [a,l] == [0,0] then exit! end a = [a] loop { v = a.last.to_s.rjust(l,'0').chars.sort.join min = v.to_i max = v.reverse.to_i r = max - min i = a.index(r) puts i if i != nil puts [i, r, a.length-i].join(' ') break end a << r...
loop { a,l = gets.split.map{|s|s.to_i} if [a,l] == [0,0] then break end a = [a] loop { v = a.last.to_s.rjust(l,'0').chars.sort.join min = v.to_i max = v.reverse.to_i r = max - min i = a.index(r) if i != nil puts [i, r, a.length-i].join(' ') break end a << r } }
[["-", 8, 734, 0, 121, 64, 749, 0, 652, 735, 22], ["+", 8, 734, 0, 121, 64, 749, 0, 94, 0, 94], ["-", 0, 652, 196, 196, 8, 734, 0, 652, 735, 22], ["-", 196, 196, 8, 734, 0, 652, 3, 4, 0, 22]]
4
120
4
def sort_MxMn(SeriesA): global max_a, min_a listA = list(str(SeriesA)) while len(listA) < b: listA.append("0") listA = [int(x) for x in listA] max_a = sorted(listA, reverse=True) min_a = sorted(listA) def translate(listEx): num = 0 for i in range(b): num += listEx[i]*(10...
def sort_MxMn(SeriesA): global max_a, min_a listA = list(str(SeriesA)) while len(listA) < b: listA.append("0") listA = [int(x) for x in listA] max_a = sorted(listA, reverse=True) min_a = sorted(listA) def translate(listEx): num = 0 for i in range(b): num += listEx[i]*(10...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
204
4
import sys readline = sys.stdin.readline while True: A, L = (int(x) for x in readline().split()) if A == 0 and L == 0: break cnt = 0 past = {A: 0} while True: A = sorted(str(A).rjust(int(L), '0')) minA = int("".join(A)) maxA = int("".join(reversed(A))) A = maxA - min...
import sys readline = sys.stdin.readline while True: A, L = (int(x) for x in readline().split()) if A == 0 and L == 0: break cnt = 0 past = {A: 0} while True: A = sorted(str(A).rjust(int(L), '0')) minA = int("".join(A)) maxA = int("".join(reversed(A))) A = maxA - min...
[["-", 0, 652, 3, 4, 0, 657, 12, 660, 0, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 660, 0, 22]]
5
146
2
#include <stdio.h> int main() { int n; int i, j, k; int t, f; // int l, r, b; int field[100][100][100]; int left[6][6] = {{0, 4, 2, 5, 3, 0}, {3, 0, 6, 1, 0, 4}, {5, 1, 0, 0, 6, 2}, {2, 6, 0, 0, 1, 5}, {4, 0, 1, 6, 0, 3}, {0, 3, 5, 2, 4, 0}}; // int dice[6][2] = {{5, 4}, {6, 4}, {6, 5...
#include <stdio.h> int main() { int n; int i, j, k; int t, f; // int l, r, b; int field[100][100][100]; int left[6][6] = {{0, 4, 2, 5, 3, 0}, {3, 0, 6, 1, 0, 4}, {5, 1, 0, 0, 6, 2}, {2, 6, 0, 0, 1, 5}, {4, 0, 1, 6, 0, 3}, {0, 3, 5, 2, 4, 0}}; // int dice[6][2] = {{5, 4}, {6, 4}, {6, 5...
[["-", 49, 50, 51, 83, 0, 83, 0, 83, 0, 13], ["+", 49, 50, 51, 83, 0, 83, 0, 83, 0, 13]]
0
994
2
//転がす方向を決める処理と実際に転がす処理を分けると楽ちん。 // vec == 3は下面じゃないからね!!! #include <iostream> using namespace std; int n; int t, f; int dy[4] = {1, 0, -1, 0}; int dx[4] = {0, 1, 0, -1}; int tfrbl[7][4] = {{0}, {3, 5, 4, 2}, {3, 1, 4, 6}, {6, 5, 1, 2}, {1, 5, 6, 2}, {3, 6, 4, 1}, {3, 2, 4, 5}}; //側面右回り // ...
//転がす方向を決める処理と実際に転がす処理を分けると楽ちん。 // vec == 3は下面じゃないからね!!! #include <iostream> using namespace std; int n; int t, f; int dy[4] = {1, 0, -1, 0}; int dx[4] = {0, 1, 0, -1}; int tfrbl[7][4] = {{0}, {3, 5, 4, 2}, {3, 1, 4, 6}, {6, 5, 1, 2}, {1, 5, 6, 2}, {3, 6, 4, 1}, {3, 2, 4, 5}}; //側面右回り // ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
595
4
#include <iostream> #include <string.h> using namespace std; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; int tb[7][5] = { {}, {3, 5, 4, 2, 6}, {3, 1, 4, 6, 5}, {6, 5, 1, 2, 4}, {1, 5, 6, 2, 3}, {3, 6, 4, 1, 2}, {4, 5, 3, 2, 1}, }; int main() { int n; while (cin >> n && n) { ...
#include <iostream> #include <string.h> using namespace std; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; int tb[7][5] = { {}, {3, 5, 4, 2, 6}, {3, 1, 4, 6, 5}, {6, 5, 1, 2, 4}, {1, 5, 6, 2, 3}, {3, 6, 4, 1, 2}, {4, 5, 3, 2, 1}, }; int main() { int n; while (cin >> n && n) { ...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
654
2
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> //#include<cctype> #include <climits> #include <iostream> #include <map> #include <string> #include <vector> //#include<list> #include <algorithm> #include <deque> #include <queue> //#include<numeric> #include <complex> #include <utility> //#inclu...
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> //#include<cctype> #include <climits> #include <iostream> #include <map> #include <string> #include <vector> //#include<list> #include <algorithm> #include <deque> #include <queue> //#include<numeric> #include <complex> #include <utility> //#inclu...
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 21], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 21]]
1
1,108
8
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #...
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 21], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 21], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
1
710
4
#include <bits/stdc++.h> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int, int> P; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; struct dice { int top; int bottom; int front; int back; int left; int right; }; void rotate_front(dice *d) { int tmp = d->top; ...
#include <bits/stdc++.h> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int, int> P; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; struct dice { int top; int bottom; int front; int back; int left; int right; }; void rotate_front(dice *d) { int tmp = d->top; ...
[["-", 64, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["-", 64, 9, 0, 57, 15, 339, 51, 11, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
1,305
4
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(n) rep(i, n) #define all(n) n.begin(), n.end() const int TO = 4, BO = 5, F = 0, B = 1, R = 2, L = 3; int dx[] ...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(n) rep(i, n) #define all(n) n.begin(), n.end() const int TO = 4, BO = 5, F = 0, B = 1, R = 2, L = 3; int dx[] ...
[["-", 0, 57, 64, 9, 0, 57, 64, 37, 0, 13], ["+", 0, 57, 64, 9, 0, 57, 64, 37, 0, 13]]
1
1,251
2
#include <iostream> using namespace std; #define VAR 210 struct S { int U, D, R, L, F, B, h, x, y; }; int main() { int field[VAR][VAR][VAR]; int n; int t, f; int tmp; int cnt[7]; S dice; while (1) { cin >> n; if (n == 0) break; for (int i = 0; i < VAR; i++) { for (int j =...
#include <iostream> using namespace std; #define VAR 100 struct S { int U, D, R, L, F, B, h, x, y; }; int main() { int field[VAR][VAR][VAR]; int n; int t, f; int tmp; int cnt[7]; S dice; while (1) { cin >> n; if (n == 0) break; for (int i = 0; i < VAR; i++) { for (int j =...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
1,416
2
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { List<Rec> list = new ArrayList<Rec>(); for (int h = 1; h <= 150; h++) { for (int w ...
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { List<Rec> list = new ArrayList<Rec>(); for (int h = 1; h <= 150; h++) { for (int w ...
[["-", 49, 200, 51, 492, 3, 4, 0, 27, 0, 29], ["+", 49, 200, 51, 492, 3, 4, 0, 16, 17, 72], ["+", 49, 200, 51, 492, 3, 4, 0, 16, 12, 499], ["-", 0, 57, 75, 57, 15, 15, 0, 16, 17, 18], ["+", 0, 57, 75, 57, 15, 15, 0, 16, 17, 47]]
3
377
5
m, M, X, Y, x, y, i, j; main() { while (scanf("%d%d", &x, &y), x || y) { m = x * x + y * y, M = 90000; for (i = 150; i; i--) for (j = i + 1; j <= 150; j++, y = i * i + j * j) if (m == y && x < i) M = y, X = i, Y = j; else if (m < y && M >= y) M = y, X = i, Y = j; ...
m, M, X, Y, x, y, i, j; main() { while (scanf("%d%d", &x, &y), x || y) { m = x * x + y * y, M = 90000; for (i = 150; i; i--) for (j = i + 1; j <= 150; j++) { y = i * i + j * j; if (m == y && x < i) M = y, X = i, Y = j; else if (m < y && M >= y) M = y, X = i, Y...
[["-", 8, 9, 0, 7, 8, 7, 26, 34, 0, 21], ["+", 0, 52, 8, 9, 0, 7, 8, 7, 0, 25], ["+", 8, 9, 0, 7, 8, 7, 8, 9, 0, 45], ["-", 0, 52, 8, 9, 0, 7, 8, 7, 0, 25], ["+", 0, 7, 8, 7, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 7, 8, 7, 8, 9, 0, 46]]
0
153
6
#include <stdio.h> int tai(int x, int y) { x = x * x + y * y; return x; } int main() { int h, w, h1, w1; while (1) { int ha = 151, wa = 151; scanf("%d %D", &h1, &w1); if ((h1 == 0) && (w1 == 0)) { return 0; } for (h = 1; h < 150; h++) { for (w = h + 1; w <= 150; w++) { ...
#include <stdio.h> int tai(int x, int y) { x = x * x + y * y; return x; } int main() { int h, w, h1, w1; while (1) { int ha = 151, wa = 151; scanf("%d %d", &h1, &w1); if ((h1 == 0) && (w1 == 0)) { return 0; } for (h = 1; h < 150; h++) { for (w = h + 1; w <= 150; w++) { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
307
2
#include <math.h> #include <stdio.h> int search(int, int); int main(void) { int h, w, dSq, d, ans; for (; scanf("%d %d", &h, &w), h; printf("%d %d\n", ans / 101, ans % 101)) { dSq = h * h + w * w; if (ans = search(h + 1, dSq)) continue; for (d = dSq + 1; !(ans = search(1, d++));) ; } ...
#include <math.h> #include <stdio.h> int search(int, int); int main(void) { int h, w, dSq, d, ans; for (; scanf("%d %d", &h, &w), h; printf("%d %d\n", ans / 151, ans % 151)) { dSq = h * h + w * w; if (ans = search(h + 1, dSq)) continue; for (d = dSq + 1; !(ans = search(1, d++));) ; } ...
[["-", 0, 7, 26, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 7, 26, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 57, 64, 37, 0, 16, 31, 16, 12, 13], ["+", 0, 57, 64, 37, 0, 16, 31, 16, 12, 13]]
0
185
6
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <numeric> #include <vector> #define ALL(v) (v).begin(), (v).end() #define REP(i, p, n) for (int i = p; i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) #define dump(a) (cerr << #a <...
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <numeric> #include <vector> #define ALL(v) (v).begin(), (v).end() #define REP(i, p, n) for (int i = p; i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) #define dump(a) (cerr << #a <...
[["-", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22]]
1
308
4
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) begin(a), end(a) #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(5) typedef vector<int> vi; typedef vector<string> vs; typedef pair<short, short> P;...
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) begin(a), end(a) #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(5) typedef vector<int> vi; typedef vector<string> vs; typedef pair<short, short> P;...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19]]
1
299
2
#include <cstdio> int m, M, X, Y, x, y, i, j; main() { while (scanf("%d%d", &x, &y), x || y) { m = x * x + y * y, M = 90000; for (i = 150; i; i--) for (j = i + 1; j <= 150; j++, y = i * i + j * j) if (m == y && x < i) M = y, X = i, Y = j; else if (m < y && M >= y) M =...
#include <cstdio> int m, M, X, Y, x, y, i, j; main() { while (scanf("%d%d", &x, &y), x || y) { m = x * x + y * y, M = 90000; for (i = 150; i; i--) for (j = i + 1; j <= 150; j++) { y = i * i + j * j; if (m == y && x < i) M = y, X = i, Y = j; else if (m < y && M >= y) ...
[["-", 8, 9, 0, 7, 8, 7, 26, 34, 0, 21], ["+", 0, 52, 8, 9, 0, 7, 8, 7, 0, 25], ["+", 8, 9, 0, 7, 8, 7, 8, 9, 0, 45], ["-", 0, 52, 8, 9, 0, 7, 8, 7, 0, 25], ["+", 0, 7, 8, 7, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 7, 8, 7, 8, 9, 0, 46]]
1
155
6
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { vector<pair<int, pair<int, int>>> list; for (int i = 1; i <= 100; ++i) { for (int j = i + 1; j <= 100; ++j) { int v = i * i + j * j; list.push_back(pair<...
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { vector<pair<int, pair<int, int>>> list; for (int i = 1; i <= 150; ++i) { for (int j = i + 1; j <= 150; ++j) { int v = i * i + j * j; list.push_back(pair<...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
234
4
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; typedef pair<int, int> P; typedef long long LL; #define REP(i...
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; typedef pair<int, int> P; typedef long long LL; #define REP(i...
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 151]]
1
362
4
#include <algorithm> #include <iostream> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); ++i) #define rep(i, n) reps(i, 0, n) struct Rect { int h, w; int d() const { return h * h + w * w; } bool operator<(const Rect &r) const { return d() < r.d() || (d() == r.d() && h < r.h); } }...
#include <algorithm> #include <iostream> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); ++i) #define rep(i, n) reps(i, 0, n) struct Rect { int h, w; int d() const { return h * h + w * w; } bool operator<(const Rect &r) const { return d() < r.d() || (d() == r.d() && h < r.h); } }...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
197
2
#include <iostream> #define l(a, b) a *a + b *b #define INF 150 using namespace std; int main() { int h, w, mh, mw; while (cin >> h >> w && h | w) { mh = mw = INF; for (int i = INF; i > 0; i--) { for (int j = INF; j > i; j--) { if ((l(i, j) > l(h, w)) || (l(i, j) == l(h, w) && i > h)) { ...
#include <iostream> #define l(a, b) a *a + b *b #define INF 150 using namespace std; int main() { int h, w, mh, mw; while (cin >> h >> w && h | w) { mh = mw = INF; for (int i = INF; i > 0; i--) { for (int j = INF; j > i; j--) { if ((l(i, j) > l(h, w)) || (l(i, j) == l(h, w) && i > h)) { ...
[["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22]]
1
182
4
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #includ...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #includ...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47]]
1
535
2
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> VI; typedef vector<VI> VVI; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const int INF = numeric_limits<int>::max() / 2; const int NEG_INF = numeric_limits<int>::min() / 2; int m...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> VI; typedef vector<VI> VVI; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const int INF = numeric_limits<int>::max() / 2; const int NEG_INF = numeric_limits<int>::min() / 2; int m...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47]]
1
273
2
#include <algorithm> #include <iostream> #include <utility> #include <vector> using namespace std; #define vi vector<int> int main() { int i, j; int h, w; pair<int, pair<int, int>> p[22500]; int n = 0; for (i = 1; i <= 150; i++) for (j = 1; j <= 150; j++) { p[n].first = i * i + j * j; p[n].s...
#include <algorithm> #include <iostream> #include <utility> #include <vector> using namespace std; #define vi vector<int> int main() { int i, j; int h, w; pair<int, pair<int, int>> p[22500]; int n = 0; for (i = 1; i <= 150; i++) for (j = i + 1; j <= 150; j++) { p[n].first = i * i + j * j; p[...
[["+", 0, 7, 8, 7, 10, 11, 12, 16, 31, 22], ["+", 0, 7, 8, 7, 10, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
224
6
#include <iostream> using namespace std; int main() { int h, w; while (1) { cin >> h >> w; if (h == 0 && w == 0) break; int area = h * h + w * w; int minh = 200, minw = 200, mina = 100000000; for (int i = 1; i <= 150; i++) { for (int j = i; j <= 150; j++) { int newarea = i...
#include <iostream> using namespace std; int main() { int h, w; while (1) { cin >> h >> w; if (h == 0 && w == 0) break; int area = h * h + w * w; int minh = 200, minw = 200, mina = 100000000; for (int i = 1; i <= 150; i++) { for (int j = i + 1; j <= 150; j++) { int newarea...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
168
2
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; struct Tuple { double d; int h, w; Tuple(double d = 0.0, int h = 0, int w = 0) : d(d), h(h), w(w) {} bool operator<(const Tuple &t) const { if (d == t.d) { if (h == t.h) { return w < t.w; ...
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; struct Tuple { double d; int h, w; Tuple(double d = 0.0, int h = 0, int w = 0) : d(d), h(h), w(w) {} bool operator<(const Tuple &t) const { if (d == t.d) { if (h == t.h) { return w < t.w; ...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72]]
1
356
2
#include <bits/stdc++.h> using namespace std; int main(void) { while (1) { int h, w; cin >> h >> w; if (h == 0) break; bool flag = 0; int ans_i = 200, ans_j = 200; int temp = 2000000000; for (int i = 1; i < 200; i++) { for (int j = i + 1; j < 200; j++) { if (h * h + ...
#include <bits/stdc++.h> using namespace std; int main(void) { while (1) { int h, w; cin >> h >> w; if (h == 0) break; bool flag = 0; int ans_i = 200, ans_j = 200; int temp = 2000000000; for (int i = h + 1; i < 200; i++) { for (int j = i + 1; j < 200; j++) { if (h * ...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72]]
1
267
2
#include <iostream> using namespace std; int main() { int w, h; while (1) { cin >> w >> h; if (w == 0 && h == 0) break; int d = h * h + w * w; int H = 150; int W = 150; int D = 150 * 150 * 2; for (int i = 1; i <= 150; i++) { for (int j = i + 1; j <= 150; j++) { int z...
#include <iostream> using namespace std; int main() { int w, h; while (1) { cin >> h >> w; if (w == 0 && h == 0) break; int d = h * h + w * w; int H = 150; int W = 150; int D = 150 * 150 * 2; for (int i = 1; i <= 150; i++) { for (int j = i + 1; j <= 150; j++) { int z...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
251
4
#include <algorithm> #include <iostream> #define rng(x1, y1, x2, y2) \ (sum[y2][x2] + sum[y1][x1] - sum[y2][x1] - sum[y1][x2]) using namespace std; int H, W, ra, o, a[40][40], sum[40][40], dp[40][40][40][40]; int solve(int x1, int y1, int x2, int y2) { if (dp[y1][x...
#include <algorithm> #include <iostream> #define rng(x1, y1, x2, y2) \ (sum[y2][x2] + sum[y1][x1] - sum[y2][x1] - sum[y1][x2]) using namespace std; int H, W, ra, o, a[40][40], sum[40][40], dp[40][40][40][40]; int solve(int x1, int y1, int x2, int y2) { if (dp[y1][x...
[["-", 51, 34, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 34, 31, 2, 3, 4, 0, 5, 0, 6]]
1
676
2
#include <algorithm> #include <iostream> #pragma warning(disable : 4996) #define rng(x1, y1, x2, y2) \ (sum[y2][x2] + sum[y1][x1] - sum[y2][x1] - sum[y1][x2]) using namespace std; int H, W, ra, o, a[40][40], sum[40][40], dp[40][40][40][40]; inline int solve(int x1, i...
#include <algorithm> #include <iostream> #pragma warning(disable : 4996) #define rng(x1, y1, x2, y2) \ (sum[y2][x2] + sum[y1][x1] - sum[y2][x1] - sum[y1][x2]) using namespace std; int H, W, ra, o, a[40][40], sum[40][40], dp[40][40][40][40]; inline int solve(int x1, i...
[["-", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111]]
1
671
1
#include <algorithm> #include <map> #include <stdio.h> #include <string.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define INF (1 << 28) inline void cmax(int &a, int b) { if (a < b) a = b; } int n, m, S, f[32][32], _sum[32][32]; inline int sum(int x1, int y1, ...
#include <algorithm> #include <map> #include <stdio.h> #include <string.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define INF (1 << 28) inline void cmax(int &a, int b) { if (a < b) a = b; } int n, m, S, f[32][32], _sum[40][40]; inline int sum(int x1, int y1, ...
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
642
4
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; typedef pair<int, int> pii; #define rep(i, j) for (int i = 0; i < (j); i++) #define reps(i,...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; typedef pair<int, int> pii; #define rep(i, j) for (int i = 0; i < (j); i++) #define reps(i,...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
569
4
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; final int INF = Integer.MAX_V...
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; final int INF = Integer.MAX_V...
[["-", 12, 510, 15, 23, 0, 16, 31, 16, 31, 22], ["+", 12, 510, 15, 23, 0, 16, 31, 16, 31, 22]]
3
1,162
4
#include <iostream> using namespace std; int main() { while (true) { int h, w; cin >> h >> w; if (h == 0 && w == 0) break; int d = h * h + w * w; int H = 150; int W = 150; int D = 150 * 150 + 150 * 150; for (int y = 1; y <= 150; y++) { for (int x = y + 1; x <= 150; x++...
#include <iostream> using namespace std; int main() { while (true) { int h, w; cin >> h >> w; if (h == 0 && w == 0) break; int d = h * h + w * w; int H = 150; int W = 150; int D = 150 * 150 + 150 * 150; for (int y = 1; y <= 150; y++) { for (int x = y + 1; x <= 150; x++...
[["-", 0, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["-", 8, 9, 0, 57, 64, 9, 0, 43, 39, 40]]
1
264
6
#include <bits/stdc++.h> using namespace std; int main() { int w, h; int H, W; int min; while (1) { cin >> h >> w; if (w == 0 && h == 0) break; int length = w * w + h * h; min = 150 * 150; bool flag = false; for (int i = 1; i <= 150; i++) { for (int j = 1; j <= 150;...
#include <bits/stdc++.h> using namespace std; int main() { int w, h; int H, W; int min; while (1) { cin >> h >> w; if (w == 0 && h == 0) break; int length = w * w + h * h; min = 150 * 150; bool flag = false; for (int i = 1; i <= 150; i++) { for (int j = i + 1; j <= ...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
200
6
#include <algorithm> #include <iostream> #include <string> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #define all(in) in.begin(), in.end() using namespace std; typedef long long ll; typedef int Def; typedef pair<Def, Def> pii; typedef vector<...
#include <algorithm> #include <iostream> #include <string> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #define all(in) in.begin(), in.end() using namespace std; typedef long long ll; typedef int Def; typedef pair<Def, Def> pii; typedef vector<...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
208
4
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template <class S, class T> ostream &operator<<(ostream &out, const pair<S, T> &o) { out << "(" << o.first << "," << o.second << ")"; return out; } tem...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template <class S, class T> ostream &operator<<(ostream &out, const pair<S, T> &o) { out << "(" << o.first << "," << o.second << ")"; return out; } tem...
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 22], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 22]]
1
547
4
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int h, w; void solve() { int length2 = h * h + w * w; int minHeight = 150; int minWidth; int minLength = 255000; for (int height = 1; height <= 150; height++) { for (int width = height + 1; width <= 150; wid...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int h, w; void solve() { int length2 = h * h + w * w; int minHeight = 150; int minWidth; int minLength = 255000; for (int height = 1; height <= 150; height++) { for (int width = height + 1; width <= 150; wid...
[["-", 51, 16, 12, 23, 0, 16, 12, 16, 17, 47], ["+", 51, 16, 12, 23, 0, 16, 12, 16, 17, 18]]
1
189
2
#include <algorithm> #include <assert.h> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #incl...
#include <algorithm> #include <assert.h> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #incl...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
410
6
#include <algorithm> #include <cmath> #include <cstdio> #include <vector> using namespace std; struct Rec { int w, h, v; Rec(int _w, int _h) : w(_w), h(_h) { v = w * w + h * h; } bool operator<(const Rec &a) const { if (v != a.v) return v < a.v; return h < a.h; } }; int ind[1000][1000]; vector<...
#include <algorithm> #include <cmath> #include <cstdio> #include <vector> using namespace std; struct Rec { int w, h, v; Rec(int _w, int _h) : w(_w), h(_h) { v = w * w + h * h; } bool operator<(const Rec &a) const { if (v != a.v) return v < a.v; return h < a.h; } }; int ind[1000][1000]; vector<...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
267
4
#include <iostream> #include <map> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define mp(a, b) make_pair(a, b) int main() { multimap<pair<int, int>, pair<int, int>> m; rep(i, 110) rep(j, i) { if (i == 0 || j == 0) continue; // m.emplace(mp(i*i + j*j, i*j), mp(j, i)); m...
#include <iostream> #include <map> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define mp(a, b) make_pair(a, b) int main() { multimap<pair<int, int>, pair<int, int>> m; rep(i, 150) rep(j, i) { if (i == 0 || j == 0) continue; // m.emplace(mp(i*i + j*j, i*j), mp(j, i)); m...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104]]
1
176
6
S = sorted([[i,j] for i in range(1,100) for j in range(i,151)], key = lambda x:x[0]**2+x[1]**2) while True: h,w = list(map(int,input().split())) if h == 0: break hi,wi = S[S.index([h,w])+1] print(hi,wi)
S = sorted([[i,j] for i in range(1,100) for j in range(i+1,151)], key = lambda x:x[0]**2+x[1]**2) while True: h,w = list(map(int,input().split())) if h == 0: break hi,wi = S[S.index([h,w])+1] print(hi,wi)
[["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
102
2
#include <iostream> #include <utility> #include <vector> using namespace std; int main() { int m, t, p, r, i, j, k; while (1) { cin >> m >> t >> p >> r; if (m == 0) break; int ac[t] = {}, wa[t][p + 1], actime[t] = {}; for (i = 0; i < t; i++) { for (j = 0; j < p; j++) wa[i][j] = ...
#include <iostream> #include <utility> #include <vector> using namespace std; int main() { int m, t, p, r, i, j, k; while (1) { cin >> m >> t >> p >> r; if (m == 0) break; int ac[t] = {}, wa[t][p + 1], actime[t] = {}; for (i = 0; i < t; i++) { for (j = 0; j < p + 1; j++) wa[i][j...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
396
2
#include <bits/stdc++.h> #define REP(a, b, c) for (int a = b; a < (int)c; a++) #define REPE(a, b, c) for (int a = b; a <= (int)c; a++) #define REPD(a, b, c) for (int a = b; a > (int)c; a--) #define rep(a, b) REP(a, 0, b) #define repd(a, b) REPD(a, b, 0) class _datas { public: int m; int t; int p; int j; }; clas...
#include <bits/stdc++.h> #define REP(a, b, c) for (int a = b; a < (int)c; a++) #define REPE(a, b, c) for (int a = b; a <= (int)c; a++) #define REPD(a, b, c) for (int a = b; a > (int)c; a--) #define rep(a, b) REP(a, 0, b) #define repd(a, b) REPD(a, b, 0) class _datas { public: int m; int t; int p; int j; }; clas...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
479
2
#include <iostream> #include <string> using namespace std; int main() { int solved[51]; int time[51][11]; int team[51]; int m, t, p, r; while (true) { cin >> m >> t >> p >> r; if (m == 0 && t == 0 && p == 0 && r == 0) break; for (int i = 0; i < t; i++) { solved[i] = 0; for (int j...
#include <iostream> #include <string> using namespace std; int main() { int solved[50]; int time[50][10]; int team[50]; int m, t, p, r; while (true) { cin >> m >> t >> p >> r; if (m == 0 && t == 0 && p == 0 && r == 0) break; for (int i = 0; i < t; i++) { solved[i] = 0; for (int j...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 31, 13], ["+", 64, 1, 0, 11, 12, 16, 31, 16, 31, 13]]
1
443
10
#include <bits/stdc++.h> #define f first #define sf second.first #define ss second.second using namespace std; typedef pair<int, int> P; typedef pair<int, P> iP; int main() { int t, p, r, b; while (cin >> b >> t >> p >> r && t) { iP a[51]; int k[11][51] = {}; a[0] = iP(-1, P(-1, -1)); for (int i = ...
#include <bits/stdc++.h> #define f first #define sf second.first #define ss second.second using namespace std; typedef pair<int, int> P; typedef pair<int, P> iP; int main() { int t, p, r, b; while (cin >> b >> t >> p >> r && t) { iP a[51]; int k[11][51] = {}; a[0] = iP(-1, P(-1, -1)); for (int i = ...
[["-", 31, 118, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 118, 28, 69, 341, 342, 0, 16, 17, 33]]
1
305
4
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; class team { public: int num; // number of team int cnt; // solved problems int tim; // total consumed time team(void){}; team(int _num, int _cnt, int _ti...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; class team { public: int num; // number of team int cnt; // solved problems int tim; // total consumed time team(void){}; team(int _num, int _cnt, int _ti...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
638
2
#include <stdio.h> #include <string.h> typedef struct { int id; int ac; int time; int pt[300]; int ok[20]; } Player; int M, T, P, R; void makeScore(int n, Player *A) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= P; j++) { if (A[i].ok[j] == 0) { if (A[i].pt[j]) A[i].tim...
#include <stdio.h> #include <string.h> typedef struct { int id; int ac; int time; int pt[300]; int ok[20]; } Player; int M, T, P, R; void makeScore(int n, Player *A) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= P; j++) { if (A[i].ok[j] == 0) { if (A[i].pt[j]) A[i].tim...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
727
2
#include <iostream> using namespace std; int main() { while (true) { int M, T, P, R; cin >> M >> T >> P >> R; if (M == 0 && T == 0 && P == 0 && R == 0) break; int CP[T], TT[T], PT[T][P]; //正解数、時間計、ペナルティ for (int i = 0; i < T; i++) { CP[i] = TT[i] = 0; for (int j = 0; j < P; j+...
#include <iostream> using namespace std; int main() { while (true) { int M, T, P, R; cin >> M >> T >> P >> R; if (M == 0 && T == 0 && P == 0 && R == 0) break; int CP[T], TT[T], PT[T][P]; //正解数、時間計、ペナルティ for (int i = 0; i < T; i++) { CP[i] = TT[i] = 0; for (int j = 0; j < P; j+...
[]
1
435
0
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() using namespace std; typedef long long ll; typedef pair<int, int> P; const double EPS = 1e-10; const ll INF = 1000000000; const ll MAX = 100010; int main() { int M, T, P, R; while (cin >> M >> T >> P >> R, M + T + P + R) { pair<pair<int, int>, int...
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() using namespace std; typedef long long ll; typedef pair<int, int> P; const double EPS = 1e-10; const ll INF = 1000000000; const ll MAX = 100010; int main() { int M, T, P, R; while (cin >> M >> T >> P >> R, M + T + P + R) { pair<pair<int, int>, int...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107]]
1
342
4
#include <algorithm> #include <cstdio> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) typedef pair<int, int> pii; typedef pair<pii, int> piii; piii mk(int a, int b, int c) { return pii...
#include <algorithm> #include <cstdio> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) typedef pair<int, int> pii; typedef pair<pii, int> piii; piii mk(int a, int b, int c) { return pii...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
1
378
4
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int M, T, P, R; int m[2000], t[2000], p[2000], j[2000]; struct team { int n, s, t, w[2000]; }; bool comp(const team &t1, const team &t2) { if (t1.t == t2.t && t1.s == t2.s) return t1.n > t2.n; if (t1.s == t2....
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int M, T, P, R; int m[2000], t[2000], p[2000], j[2000]; struct team { int n, s, t, w[2000]; }; bool comp(const team &t1, const team &t2) { if (t1.t == t2.t && t1.s == t2.s) return t1.n > t2.n; if (t1.s == t2....
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
463
4
class Array def sb sort_by.with_index{ |e, index| [yield(e), index] } end end while true do mm, tt, pp, rr = gets.split.map(&:to_i) break if mm + tt + pp + rr == 0 wa = Array.new(tt, Array.new(pp, 0)) solved = Array.new(tt, 0) time = Array.new(tt, 0) rr.times do m, t, p, j = gets.split.map(&:to...
class Array def sb sort_by.with_index{ |e, index| [yield(e), index] } end end while true do mm, tt, pp, rr = gets.split.map(&:to_i) break if mm + tt + pp + rr == 0 wa = Array.new(tt).map{Array.new(pp,0)} solved = Array.new(tt, 0) time = Array.new(tt, 0) rr.times do m, t, p, j = gets.split.map(&...
[["-", 8, 170, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 0, 662, 12, 652, 486, 652, 3, 4, 0, 25], ["+", 0, 89, 8, 170, 0, 662, 12, 652, 17, 131], ["+", 0, 89, 8, 170, 0, 662, 12, 652, 735, 22], ["+", 8, 170, 0, 662, 12, 652, 196, 196, 0, 45], ["-", 8, 170, 0, 662, 12, 652, 3, 4, 0, 25], ["+", 8, 170, 0, 662, 12, 652, 196, 1...
4
255
7
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1187&lang=jp """ import sys from sys import stdin input = stdin.readline class Team(object): def __init__(self, id): self.id = id self.correct = 0 # ??£?§£??° self.time = 0 # ??????????...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1187&lang=jp """ import sys from sys import stdin input = stdin.readline class Team(object): def __init__(self, id): self.id = id self.correct = 0 # ??£?§£??° self.time = 0 # ??????????...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]]
5
492
2