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 <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int n, b, s; while (cin >> s, s) { int a[10] = {0}; while (s--) { cin >> b; a[b]++; } r(i, 10) { if (a[i]) r(j, a[n]) cout << '*'; else cout << '-'; co...
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int n, b, s; while (cin >> s, s) { int a[10] = {0}; while (s--) { cin >> b; a[b]++; } r(i, 10) { if (a[i]) r(j, a[i]) cout << '*'; else cout << '-'; co...
[["-", 31, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 31, 2, 3, 4, 0, 69, 341, 342, 0, 22]]
1
106
2
#include <cstdio> #include <vector> using namespace std; int main() { int n, num; while (scanf("%d", &n) && n != 0) { vector<int> ice(n, 0); for (int i = 0; i < n; i++) { scanf("%d", &num); ice[num]++; } for (int i = 0; i < n; i++) { if (ice[i] == 0) { printf("-"); } ...
#include <cstdio> #include <vector> using namespace std; int main() { int n, num; while (scanf("%d", &n) && n != 0) { vector<int> ice(10, 0); for (int i = 0; i < n; i++) { scanf("%d", &num); ice[num]++; } for (int i = 0; i < 10; i++) { if (ice[i] == 0) { printf("-"); ...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
148
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { vector<int> a(9); int n, sort; while (cin >> n) { if (n == 0) break; else { fill(a.begin(), a.end(), 0); for (int i = 0; i < n; i++) { cin >> sort; a[sort]++; } for (...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { vector<int> a(10); int n, sort; while (cin >> n) { if (n == 0) break; else { fill(a.begin(), a.end(), 0); for (int i = 0; i < n; i++) { cin >> sort; a[sort]++; } for (...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
157
2
#include <cstdio> main() { int n; while (scanf("%d", &n), n) { int p[10] = {0}, t; for (; n; n--) scanf("%d", &t), p[t]++; for (t = 0; t < 10; t++) { if (p[t]) for (n = p[t]; n; n--) printf("*"); else printf("-"); } } }
#include <cstdio> int main() { int n; while (scanf("%d", &n), n) { int p[10] = {0}, t; for (; n; n--) scanf("%d", &t), p[t]++; for (t = 0; t < 10; t++) { if (p[t]) for (n = p[t]; n; n--) printf("*"); else printf("-"); puts(""); } } }
[["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 75, 76, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 75, 76, 0, 1, 0, 35], ["+", 0, 7, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24]]
1
113
7
#include <cstdio> #include <iostream> using namespace std; int main(void) { int N; while (cin >> N, N) { int d[10]; for (int i = 0; i < 10; i++) d[i] = 0; int No; for (int i = 0; i < N; i++) { cin >> No; d[No - 1]++; } for (int i = 0; i < 10; i++) { if (d[i] == 0)...
#include <cstdio> #include <iostream> using namespace std; int main(void) { int N; while (cin >> N, N) { int d[10]; for (int i = 0; i < 10; i++) d[i] = 0; int No; for (int i = 0; i < N; i++) { cin >> No; d[No]++; } for (int i = 0; i < 10; i++) { if (d[i] == 0) ...
[["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13]]
1
153
2
#include <iostream> using namespace std; int main() { while (true) { int n = 0; int ice[10001]; for (int i = 0; i < 10001; i++) { ice[i] = 0; } cin >> n; if (n == 0) { return false; } for (int i = 0; i < n; i++) { int tmp; cin >> tmp; ice[tmp]++; ...
#include <iostream> using namespace std; int main() { while (true) { int n = 0; int ice[10001]; for (int i = 0; i < 10001; i++) { ice[i] = 0; } cin >> n; if (n == 0) { return false; } for (int i = 0; i < n; i++) { int tmp; cin >> tmp; ice[tmp]++; ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
159
2
n=int(input()) x=[0 for i in range(10)] while True: if n==0: break for i in range(n): a=int(input()) if a==0: x[0]+=1 elif a==1: x[1]+=1 elif a==2: x[2]+=1 elif a==3: x[3]+=1 elif a==4: x[4]+=1 elif a==5: x[5]+=1 elif a==6: x[6]+=1 e...
while True: n=int(input()) x=[0 for i in range(10)] if n==0: break for i in range(n): a=int(input()) if a==0: x[0]+=1 elif a==1: x[1]+=1 elif a==2: x[2]+=1 elif a==3: x[3]+=1 elif a==4: x[4]+=1 elif a==5: x[5]+=1 elif a==6: x[6]+=1 ...
[["+", 36, 36, 36, 36, 0, 656, 0, 52, 0, 89], ["+", 36, 36, 36, 36, 0, 656, 0, 52, 15, 146], ["+", 36, 36, 36, 36, 0, 656, 0, 52, 0, 102], ["-", 36, 36, 36, 36, 0, 656, 0, 52, 0, 89], ["-", 36, 36, 36, 36, 0, 656, 0, 52, 15, 146], ["-", 36, 36, 36, 36, 0, 656, 0, 52, 0, 102]]
5
201
6
#!/usr/bin/env python3 while True: n = int(input()) data = [0] * 10 if n == 0: break for _ in range(n): in_data = int(input()) data[in_data - 1] += 1 for d in data: for _ in range(d): print("*", end="") if d == 0: print("-") ...
#!/usr/bin/env python3 while True: n = int(input()) data = [0] * 10 if n == 0: break for _ in range(n): in_data = int(input()) data[in_data] += 1 for d in data: for _ in range(d): print("*", end="") if d == 0: print("-") els...
[["-", 0, 1, 0, 677, 31, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 677, 31, 206, 206, 657, 12, 612]]
5
94
2
#include <iostream> #include <string> using namespace std; string convert(int n) { string s = ""; while (n) { s += n % 8 + '0'; n /= 8; } string _s = ""; for (int i = s.size() - 1; i >= 0; i--) { char c = s[i]; if (c >= '6') c++; if (c >= '4') c++; _s += c; } return _...
#include <iostream> #include <string> using namespace std; string convert(int n) { string s = ""; while (n) { s += n % 8 + '0'; n /= 8; } string _s = ""; for (int i = s.size() - 1; i >= 0; i--) { char c = s[i]; if (c >= '4') c++; if (c >= '6') c++; _s += c; } return _...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
139
4
#define _USE_MATH_DEFINES #define INF 10000000 #include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> using namespace std; typ...
#define _USE_MATH_DEFINES #define INF 10000000 #include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> using namespace std; typ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
215
28
#include <iostream> #include <vector> using namespace std; const int d2o[] = {0, 1, 2, 3, 5, 6, 7, 9}; int main() { int n; while (cin >> n) { if (n == 0) break; vector<int> ans; while (n > 0) { ans.push_back(d2o[n % 8]); n /= 8; } for (int i = ans.size() - 1; i >= 0; --i) ...
#include <iostream> #include <vector> using namespace std; const int d2o[] = {0, 1, 2, 3, 5, 7, 8, 9}; int main() { int n; while (cin >> n) { if (n == 0) break; vector<int> ans; while (n > 0) { ans.push_back(d2o[n % 8]); n /= 8; } for (int i = ans.size() - 1; i >= 0; --i) ...
[["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13]]
1
121
4
#include <iostream> using namespace std; int main() { int n; while (cin >> n, n) { int d[99] = {0}, c = 0; while (n > 0) { d[c++] = n % 8; n /= 8; } while (c--) cout << "01235789"[d[c]] << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n; while (cin >> n, n) { int d[99] = {0}, c = 0; while (n > 0) { d[c++] = n % 8; n /= 8; } while (c--) cout << "01235789"[d[c]]; cout << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 52, 8, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22]]
1
83
2
#include <iostream> using namespace std; unsigned long int dec_to_oct(unsigned long int num) { int result = 0; for (int i = 1; num != 0; i *= 10) { result += (num % 8) * i; num = num / 8; } return result; } int main(void) { unsigned long int room_num; unsigned long int buf; unsigned long int new...
#include <iostream> using namespace std; unsigned long int dec_to_oct(unsigned long int num) { unsigned long int result = 0; for (int i = 1; num != 0; i *= 10) { result += (num % 8) * i; num = num / 8; } return result; } int main(void) { unsigned long int room_num; unsigned long int buf; unsigne...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
178
4
def ge(arr): for i in range(len(arr)): tmp = int(arr[i]) if tmp >= 4: tmp += 1 if tmp >= 6: tmp += 1 arr[i] = str(tmp) while True: n = int(input) if n == 0: break print("".join(ge(list(oct(n))[2:])))
def ge(arr): for i in range(len(arr)): tmp = int(arr[i]) if tmp >= 4: tmp += 1 if tmp >= 6: tmp += 1 arr[i] = str(tmp) return arr while True: n = int(input()) if n == 0: break print("".join(ge(list(oct(n))[2:])))
[["+", 0, 656, 0, 14, 8, 196, 0, 37, 0, 38], ["+", 0, 656, 0, 14, 8, 196, 0, 37, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
89
4
inputlist=[] while True: inputnum=int(input()) if(inputnum==0):break inputlist.append(inputnum) def octnpower(num): flag=0 maxi=0 maxj=0 if(num<8): temp[-1]=num return for i in range(1,11): for j in range(1,8): if(num>=(8**i)*j): flag=(8**i)*j maxi=i maxj=j else: temp[-maxi-1]=maxj ...
inputlist=[] while True: inputnum=int(input()) if(inputnum==0):break inputlist.append(inputnum) def octnpower(num): flag=0 maxi=0 maxj=0 if(num<8): temp[-1]=num return for i in range(1,11): for j in range(1,8): if(num>=(8**i)*j): flag=(8**i)*j maxi=i maxj=j else: temp[-maxi-1]=maxj ...
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
273
4
import static java.lang.Math.*; import static java.util.Arrays.*; import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); int INF = 1 << 28; double EPS = 1e-9; int m, n; int[][] a, b; void run() { for (;;) { m = s...
import static java.lang.Math.*; import static java.util.Arrays.*; import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); int INF = 1 << 28; double EPS = 1e-9; int m, n; int[][] a, b; void run() { for (;;) { m = s...
[["-", 0, 195, 8, 196, 0, 37, 0, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 37, 0, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 37, 0, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 37, 0, 16, 12, 22]]
3
753
4
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { final int n = sc.nextInt(); final int m = sc.nextInt(); if (n == 0 && m == 0) { break; } int[][] ma...
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { final int n = sc.nextInt(); final int m = sc.nextInt(); if (n == 0 && m == 0) { break; } int[][] ma...
[["+", 0, 7, 15, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 7, 15, 16, 12, 23, 0, 16, 12, 499]]
3
884
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef pair<int, int> P;...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef pair<int, int> P;...
[["-", 0, 2, 3, 4, 0, 16, 31, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 16, 31, 118, 119, 120]]
1
667
4
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef tuple<int, int> duo; const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; const int Mod = 1000000000 + 0; inline int in() { int x; scanf("%d", &x); return x; } int main() {...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef tuple<int, int> duo; const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; const int Mod = 1000000000 + 0; inline int in() { int x; scanf("%d", &x); return x; } int main() {...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
608
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define LT(a, b, c, d) (((a) < (c)) || ((a) == (c) ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define LT(a, b, c, d) (((a) < (c)) || ((a) == (c) ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
523
4
#include <iostream> using namespace std; int x[110][110]; int p[100][100][4]; int n, m; int main() { while (true) { cin >> n >> m; if (n == 0 && m == 0) { break; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> x[i][j]; } } for (int i = 0; i < m; i...
#include <iostream> using namespace std; int x[110][110]; int p[100][100][4]; int n, m; int main() { while (true) { cin >> n >> m; if (n == 0 && m == 0) { break; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> x[i][j]; } } for (int i = 0; i < m; i...
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
498
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #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 #define mp make_pair...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #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 #define mp make_pair...
[["+", 51, 34, 31, 2, 3, 4, 0, 66, 17, 67]]
1
437
2
#include <iostream> using namespace std; int n, m; int w[100][100]; int p[50][50]; int b; bool input() { cin >> n >> m; if (!n && !m) { return false; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> w[i][j]; } } for (int i = 0; i < m; ++i) { for (int j = 0; j < m; ...
#include <iostream> using namespace std; int n, m; int w[100][100]; int p[50][50]; int b; bool input() { cin >> n >> m; if (!n && !m) { return false; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> w[i][j]; } } for (int i = 0; i < m; ++i) { for (int j = 0; j < m; ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
619
4
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using na...
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using na...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
562
4
#include <iostream> using namespace std; typedef pair<int, int> P; int pic[50][50]; void rotate(int m) { int tmp[50][50]; for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { tmp[i][j] = pic[m - j - 1][i]; } } for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) pic[i][j] ...
#include <iostream> using namespace std; typedef pair<int, int> P; int pic[50][50]; void rotate(int m) { int tmp[50][50]; for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { tmp[i][j] = pic[m - j - 1][i]; } } for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) pic[i][j] ...
[["-", 31, 16, 31, 16, 12, 16, 31, 118, 119, 120], ["+", 31, 16, 31, 16, 12, 16, 31, 118, 119, 120], ["-", 0, 16, 31, 16, 12, 16, 31, 118, 119, 120], ["+", 0, 16, 31, 16, 12, 16, 31, 118, 119, 120]]
1
515
4
#include <cstdio> using namespace std; #define INF 101 int M, N; int f[100][100]; int p[50][50][4]; void check(int x, int y, int d, int &ansx, int &ansy) { int mx = INF, my = INF; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { if (p[j][i][d] == -1) continue; if (p[j][i][d] != ...
#include <cstdio> using namespace std; #define INF 101 int M, N; int f[100][100]; int p[50][50][4]; void check(int x, int y, int d, int &ansx, int &ansy) { int mx = INF, my = INF; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { if (p[j][i][d] == -1) continue; if (p[j][i][d] != ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 7, 8, 7, 15, 16, 17, 18], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
500
6
#include <iostream> #include <vector> using namespace std; int scene[100][100], picture[50][50], temporary[50][50]; int main() { while (true) { int n, m; cin >> n >> m; if (n == 0 && m == 0) { break; } for (int y = 0; y < n; ++y) { for (int x = 0; x < n; ++x) { cin >> scene[...
#include <iostream> #include <vector> using namespace std; int scene[100][100], picture[50][50], temporary[50][50]; int main() { while (true) { int n, m; cin >> n >> m; if (n == 0 && m == 0) { break; } for (int y = 0; y < n; ++y) { for (int x = 0; x < n; ++x) { cin >> scene[...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
515
4
#include <stdio.h> int pat[4][50][50]; int scen[100][100]; void rote(int s, int e, int m) { for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { pat[e][j][i] = pat[s][i][(m - 1) - j]; } } } int main(void) { int n, m; int patx, paty; bool end; while (1) { scanf("%d%d", &n, &m); ...
#include <stdio.h> int pat[4][50][50]; int scen[100][100]; void rote(int s, int e, int m) { for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { pat[e][j][i] = pat[s][i][(m - 1) - j]; } } } int main(void) { int n, m; int patx, paty; bool end; while (1) { scanf("%d%d", &n, &m); ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
575
4
#include <iostream> #include <vector> using namespace std; pair<int, int> match(const vector<vector<int>> &scenery, int x, int y, const vector<vector<int>> &picture) { const int M = picture.size(); pair<int, int> ans = make_pair(1000, 1000); for (int i = 0; i < M; i++) { for (int j = 0;...
#include <iostream> #include <vector> using namespace std; pair<int, int> match(const vector<vector<int>> &scenery, int x, int y, const vector<vector<int>> &picture) { const int M = picture.size(); pair<int, int> ans = make_pair(1000, 1000); for (int i = 0; i < M; i++) { for (int j = 0;...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
963
4
#include <iostream> #include <vector> using namespace std; #define INF 1 << 30 vector<vector<int>> rotate(vector<vector<int>> picture) { int m = picture.size(); vector<vector<int>> result(m, vector<int>(m)); for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) result[i][j] = picture[j][m - 1 - i]; ...
#include <iostream> #include <vector> using namespace std; #define INF 1 << 30 vector<vector<int>> rotate(vector<vector<int>> picture) { int m = picture.size(); vector<vector<int>> result(m, vector<int>(m)); for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) result[i][j] = picture[j][m - 1 - i]; ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 7, 8, 7, 15, 16, 12, 16, 17, 72], ["+", 0, 7, 8, 7, 15, 16, 12, 16, 12, 13]]
1
576
4
#include <iostream> using namespace std; int seen[100][100]; int pic[4][50][50]; int main() { int n, m; for (;;) { cin >> n >> m; if (!n && !m) break; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> seen[i][j]; for (int i = 0; i < m; i++) for (int j = 0;...
#include <iostream> using namespace std; int seen[100][100]; int pic[4][50][50]; int main() { int n, m; for (;;) { cin >> n >> m; if (!n && !m) break; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> seen[i][j]; for (int i = 0; i < m; i++) for (int j = 0;...
[["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 13], ["+", 0, 7, 8, 7, 15, 16, 31, 16, 17, 33], ["+", 0, 7, 8, 7, 15, 16, 31, 16, 12, 13]]
1
446
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int m, n; while (cin >> n >> m) { if (!(m | n)) break; bool matched[n][n]; int pic[n][n]; int pat[m][m]; int orig[m][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int m, n; while (cin >> n >> m) { if (!(m | n)) break; bool matched[n][n]; int pic[n][n]; int pat[m][m]; int orig[m][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72]]
1
722
2
from sys import stdin readline = stdin.readline from itertools import product from operator import itemgetter from math import isinf def scrap_top_left(picture): for py, px in product(range(len(picture)), repeat=2): if picture[py][px] != -1: return px, py def is_match(window, picture, wx, ...
from sys import stdin readline = stdin.readline from itertools import product from operator import itemgetter from math import isinf def scrap_top_left(picture): for py, px in product(range(len(picture)), repeat=2): if picture[py][px] != -1: return px, py def is_match(window, picture, wx, ...
[["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
380
2
import java.util.*; public class Main { static int h; static int w; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { w = sc.nextInt(); h = sc.nextInt(); if (w == 0 && h == 0) break; char[][] map; boolean[][] alMove; ma...
import java.util.*; public class Main { static int h; static int w; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { w = sc.nextInt(); h = sc.nextInt(); if (w == 0 && h == 0) break; char[][] map; boolean[][] alMove; ma...
[["-", 0, 52, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 17, 19]]
3
1,940
2
#include <iostream> #include <string> char maze[31][31], tempMaze[31][31]; int H, W; using namespace std; void changeDirection() { int i, j; for (i = 0; i < H; i++) { for (j = 0; j < W; j++) { if (maze[i][j] == 'E') { if (maze[i + 1][j] == '.' || maze[i + 1][j] == 'X') maze[i][j] = '...
#include <iostream> #include <string> char maze[31][31], tempMaze[31][31]; int H, W; using namespace std; void changeDirection() { int i, j; for (i = 0; i < H; i++) { for (j = 0; j < W; j++) { if (maze[i][j] == 'E') { if (maze[i + 1][j] == '.' || maze[i + 1][j] == 'X') maze[i][j] = '...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
1,543
2
while(h=gets.split[1].to_i)>u=t=0 a=[] m=(0...h).map{|i|gets.chars.map{|c|(d="WSEN".index c)&&a<<[u,i,d]};u+=1;$_} while a[0]&&181>t+=1 n=a.map{|i,j,d|[[i,j-1,3],[i-1,j,0],[i,j+1,1],[i+1,j,2]].rotate(d).find{|e,f|m[f][e]!=?#&&a.all?{|k,l|k!=e||l!=f}}} a=n.zip(a).map{|l,k|i,j,d=l;l ?n.all?{|e,f,g|i!=e||j!=f||d<=g}?l:k[0...
while(h=gets.split[1].to_i)>u=t=0 a=[] m=(0...h).map{|i|u=0;gets.chars.map{|c|(d="WSEN".index c)&&a<<[u,i,d];u+=1};$_} while a[0]&&181>t+=1 n=a.map{|i,j,d|[[i,j-1,3],[i-1,j,0],[i,j+1,1],[i+1,j,2]].rotate(d).find{|e,f|m[f][e]!=?#&&a.all?{|k,l|k!=e||l!=f}}} a=n.zip(a).map{|l,k|i,j,d=l;l ?n.all?{|e,f,g|i!=e||j!=f||d<=g}?l...
[["+", 12, 652, 196, 196, 8, 734, 0, 662, 31, 22], ["+", 12, 652, 196, 196, 8, 734, 0, 662, 0, 32], ["+", 12, 652, 196, 196, 8, 734, 0, 662, 12, 612], ["+", 0, 662, 12, 652, 196, 196, 8, 734, 0, 35], ["-", 196, 196, 8, 734, 0, 652, 196, 196, 0, 46], ["+", 196, 196, 8, 734, 0, 652, 196, 196, 0, 46]]
4
272
21
#include <stdio.h> long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } int main() { long long n, g, l, i, a[20], b[20], c[20]; while (scanf("%lld", &n), n) { for (i = 0; i < n; i++) scanf("%lld %lld", &a[i], &b[i...
#include <stdio.h> long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } int main() { long long n, g, l, i, a[20], b[20], c[20]; while (scanf("%lld", &n), n) { for (i = 0; i < n; i++) scanf("%lld %lld", &a[i], &b[i...
[["+", 8, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 85], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 8, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
0
295
4
#include <iostream> #include <string> using namespace std; double pow(int a) { double res = 1; for (int i = 0; i < a; i++) { res /= 2; } return res; } int main(int argc, char *argv[]) { double d; while (std::cin >> d) { if (d < 0) break; int digit = 8; string ans; for (int i = di...
#include <iostream> #include <string> using namespace std; double pow(int a) { double res = 1; for (int i = 0; i < a; i++) { res /= 2; } return res; } int main(int argc, char *argv[]) { double d; while (std::cin >> d) { if (d < 0) break; int digit = 7; string ans; for (int i = di...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
235
6
#include <bits/stdc++.h> using namespace std; int main() { double N; while (cin >> N, N >= 0) { int n = N * 16 + 1e-8; if (abs(N * 16 - (int)(N * 16)) < 1e-8 || n >= (1 << 12)) { puts("NA"); break; } for (int i = 11; i >= 0; i--) { printf("%d", (n >> i) & 1); if (i == 4) ...
#include <bits/stdc++.h> using namespace std; int main() { double N; while (cin >> N, N >= 0) { int n = N * 16 + 1e-8; if (abs(N * 16 - (int)(N * 16)) > 1e-8 || n >= (1 << 12)) { puts("NA"); continue; } for (int i = 11; i >= 0; i--) { printf("%d", (n >> i) & 1); if (i == 4)...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
128
4
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } template <class T> inline T sqr(T x) { return x * x; } typedef vector<int> v...
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } template <class T> inline T sqr(T x) { return x * x; } typedef vector<int> v...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
472
2
#include <algorithm> #include <cstdio> using namespace std; int main() { double x; while (scanf("%lf", &x)) { if (x < 0) break; x *= 16; if (x > (1 << 16) - 1) printf("NA"); else if (x == (int)x) { char str[20]; str[8] = '.'; str[13] = '\0'; int n = x; for ...
#include <algorithm> #include <cstdio> using namespace std; int main() { double x; while (scanf("%lf", &x)) { if (x < 0) break; x *= 16; if (x > (1 << 16) - 1) printf("NA\n"); else if (x == (int)x) { char str[20]; str[8] = '.'; str[13] = '\0'; int n = x; fo...
[["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
177
2
#include <iostream> #include <vector> using namespace std; int A[8]; int B[4]; int main(int argc, char **argv) { int a, c; double b; double d; while (1) { cin >> d; if (d < 0.0) break; a = (int)d; b = d - a; for (int i = 7; i >= 0; i--) { A[i] = a % 2; a /= 2; } ...
#include <iostream> #include <vector> using namespace std; int A[8]; int B[4]; int main(int argc, char **argv) { int a, c; double b; double d; while (1) { cin >> d; if (d < 0.0) break; a = (int)d; b = d - a; for (int i = 7; i >= 0; i--) { A[i] = a % 2; a /= 2; } ...
[["+", 0, 57, 64, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
219
6
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
374
6
#include <stdio.h> #include <string.h> struct cell { struct cell *prev; struct cell *next; int flag; } s[10000], *now; int main() { int i, flag, m, n, tmp; char str[10000], t[10000]; while (scanf("%d%d", &m, &n), m + n) { tmp = m; for (i = 0; i < n; i++) { if (i) s[i].prev = &s[i - ...
#include <stdio.h> #include <string.h> struct cell { struct cell *prev; struct cell *next; int flag; } s[10000], *now; int main() { int i, flag, m, n, tmp; char str[10000], t[10000]; while (scanf("%d%d", &m, &n), m + n) { tmp = m; for (i = 0; i <= m; i++) { if (i) s[i].prev = &s[i -...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 11, 12, 66, 28, 69, 71, 16, 31, 22], ["+", 0, 11, 12, 66, 28, 69, 71, 16, 31, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 1...
0
427
8
#include <algorithm> #include <cctype> #include <iostream> #include <vector> using namespace std; inline int prev(int idx, int size) { idx--; if (idx < 0) idx = size - 1; return idx; } inline void adv(int &idx, int size) { idx++; if (idx == size) idx = 0; } inline bool isNumber(const string &s, int...
#include <algorithm> #include <cctype> #include <iostream> #include <vector> using namespace std; inline int prev(int idx, int size) { idx--; if (idx < 0) idx = size - 1; return idx; } inline void adv(int &idx, int size) { idx++; if (idx == size) idx = 0; } inline bool isNumber(const string &s, int...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
565
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <set> #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 #define mp make_pair #define it ::iterator #define all(i...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <set> #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 #define mp make_pair #define it ::iterator #define all(i...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
383
4
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #define REP(i, k, n) for (int i = k; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int n, m; while (cin >> n >> m) { if (n == 0 && m == 0) break; string s,...
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #define REP(i, k, n) for (int i = k; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int n, m; while (cin >> n >> m) { if (n == 0 && m == 0) break; string s,...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 11, 31, 69, 28, 2, 3, 4, 0, 22], ["+", 0, 11, 31, 69, 28, 2, 3, 4, 0, 13]]
1
276
4
#include <algorithm> #include <cstdio> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main() { string mes[3] = {"Fizz", "Buzz", "FizzBuzz"}; int n, m; while (scanf("%d%d", &n, &m), n || m) { bool f[10000]; fill(f, f + 10000, true); int idx = 0, cnt ...
#include <algorithm> #include <cstdio> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main() { string mes[3] = {"Fizz", "Buzz", "FizzBuzz"}; int n, m; while (scanf("%d%d", &n, &m), n || m) { bool f[10000]; fill(f, f + 10000, true); int idx = 0, cnt ...
[["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46]]
1
329
4
#include <iostream> #include <string> using namespace std; string f(int d) { int q, x = 1; for (q = 0; d / x; q++) x *= 10; x /= 10; string b; for (int k = 0; k < q; k++) { b += d / x + '0'; d -= d / x * x; x /= 10; } return b; } main() { int m, n; while (cin >> n >> m, n) { int ...
#include <iostream> #include <string> using namespace std; string f(int d) { int q, x = 1; for (q = 0; d / x; q++) x *= 10; x /= 10; string b; for (int k = 0; k < q; k++) { b += d / x + '0'; d -= d / x * x; x /= 10; } return b; } main() { int m, n; while (cin >> n >> m, n) { int ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["-", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64...
1
393
8
#include <iostream> using namespace std; int main() { while (true) { string a, b; cin >> a; cin >> b; if (a == "0") break; int hit = 0; int blow = 0; for (int i = 0; i < 4; ++i) { if (a[i] == b[i]) hit++; } for (int i = 0; i < 4; ++i) { for (int j = 0; j...
#include <iostream> using namespace std; int main() { while (true) { string a, b; cin >> a; cin >> b; if (a == "0") break; int hit = 0; int blow = 0; for (int i = 0; i < 4; ++i) { if (a[i] == b[i]) hit++; } for (int i = 0; i < 4; ++i) { for (int j = 0; j...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
147
2
loop do l = gets.chomp break if l == "0 0" answer, call = l.split.map {|s| s.split("")} hit = answer.zip(call).select {|a| a.inject(:==)}.size blow = (Set[*answer] & Set[*call]).size - hit puts "#{hit} #{blow}" end
require 'set' loop do l = gets.chomp break if l == "0 0" answer, call = l.split.map {|s| s.split("")} hit = answer.zip(call).select {|a| a.inject(:==)}.size blow = (Set[*answer] & Set[*call]).size - hit puts "#{hit} #{blow}" end
[["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 62], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 6]]
4
88
4
while True: r, a= input().split() if r==a==0: break print(sum(1 for i, j in zip(r, a) if i==j), sum(1 for i in range(len(r)) for j in range(len(a)) if r[i]==a[j] and i!=j))
while True: r, a= input().split() if r==a=='0': break print(sum(1 for i, j in zip(r, a) if i==j), sum(1 for i in range(len(r)) for j in range(len(a)) if r[i]==a[j] and i!=j))
[["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 654], ["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 655]]
5
83
2
if __name__ == '__main__': while True: a,b = list(map(str,input().split(' '))) if a == 0 and b == 0: break a = list(a) b = list(b) # print a br = 0 hit = 0 for i,data in enumerate(b): if data in a: ...
if __name__ == '__main__': while True: a,b = list(map(str,input().split(' '))) if a == '0' and b == '0': break # print a,b a = list(a) b = list(b) # print a br = 0 hit = 0 for i,data in enumerate(b): if data in...
[["+", 0, 57, 15, 679, 31, 666, 0, 557, 0, 654], ["+", 0, 57, 15, 679, 31, 666, 0, 557, 0, 655], ["+", 0, 57, 15, 679, 12, 666, 0, 557, 0, 654], ["+", 0, 57, 15, 679, 12, 666, 0, 557, 0, 655]]
5
98
4
import static java.lang.Integer.parseInt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; /* * Problem B: Thanksgiving */ public class Main { public static void main(String[] args) throws IOException { Buf...
import static java.lang.Integer.parseInt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; /* * Problem B: Thanksgiving */ public class Main { public static void main(String[] args) throws IOException { Buf...
[["-", 75, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 75, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
341
2
#include <stdio.h> int main() { int n, m, p[1000], i, j, sum = 0, k; while (1) { scanf("%d %d", &n, &m); if (n == 0 && m == 0) break; for (i = 0; i < n; i++) scanf("%d", &p[i]); for (i = 0; i < n - 1; i++) { for (j = 0; j < n - i - 1; j++) { if (p[j] < p[j + 1]) { ...
#include <stdio.h> int main() { int n, m, p[1000], i, j, sum, k; while (1) { scanf("%d %d", &n, &m); if (n == 0 && m == 0) break; for (i = 0; i < n; i++) scanf("%d", &p[i]); for (i = 0; i < n - 1; i++) { for (j = 0; j < n - i - 1; j++) { if (p[j] < p[j + 1]) { k...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
236
6
#include <stdio.h> int main() { int N, M; int n[1001] = {}; while (1) { int s = 0; scanf("%d %d", &N, M); if (N == 0 && M == 0) break; for (int i = 1; i <= N; i++) scanf("%d", &n[i]); for (int i = 1; i <= N; i++) for (int j = N; j > i; j--) if (n[j] > n[j - 1]) { ...
#include <stdio.h> int main() { int N, M; int n[1001] = {}; while (1) { int s = 0; scanf("%d %d", &N, &M); if (N == 0 && M == 0) break; for (int i = 1; i <= N; i++) scanf("%d", &n[i]); for (int i = 1; i <= N; i++) for (int j = N; j > i; j--) if (n[j] > n[j - 1]) {...
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
1
201
1
#include <algorithm> #include <iostream> #include <vector> int main() { int n, m; // n:konyu m:hukuro std::cin >> n >> m; while (n != 0 || m != 0) { std::vector<int> price; price.resize(n); for (int i = 0; i < n; ++i) { std::cin >> price[i]; // input } std::sort(price.begin(), price.en...
#include <algorithm> #include <iostream> #include <vector> int main() { int n, m; // n:konyu m:hukuro std::cin >> n >> m; while (n != 0 || m != 0) { std::vector<int> price; price.resize(n); for (int i = 0; i < n; ++i) { std::cin >> price[i]; // input } std::sort(price.begin(), price.en...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
168
2
#include <algorithm> #include <iostream> #include <vector> int main() { int n, m; // n:konyu m:hukuro std::cin >> n >> m; while (n != 0 || m != 0) { std::vector<int> price; price.resize(n); for (int i = 0; i < n; ++i) { std::cin >> price[i]; // input } std::sort(price.begin(), price.en...
#include <algorithm> #include <iostream> #include <vector> int main() { int n, m; // n:purchase number, m:capacity of the bag std::cin >> n >> m; while (n != 0 || m != 0) { std::vector<int> price; // price:the price of vegetable price.resize(n); for (int i = 0; i < n; ++i) { std::cin >> price[...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
168
2
#include <algorithm> #include <iostream> using namespace std; int n, m, x[1000000]; long long sum1, sum2; int main() { while (true) { sum1 = 0; sum2 = 0; cin >> n >> m; if (n == 0 && m == 0) { break; } for (int i = 0; i < n; i++) { cin >> x[i]; sum1 += x[i]; } sort(x,...
#include <algorithm> #include <iostream> using namespace std; int n, m, x[1000000]; long long sum1, sum2; int main() { while (true) { sum1 = 0; sum2 = 0; cin >> n >> m; if (n == 0 && m == 0) { break; } for (int i = 0; i < n; i++) { cin >> x[i]; sum1 += x[i]; } sort(x,...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
142
6
#include <algorithm> #include <stdio.h> #pragma warning(disable : 4996) using namespace std; int n, m, p[1000]; int main() { while (true) { scanf("%d%d", &n, &m); if (n == 0 && m == 0) break; for (int i = 0; i < n; i++) scanf("%d", &p[i]); sort(p, p + n); int ret = 0; for (int i = ...
#include <algorithm> #include <stdio.h> #pragma warning(disable : 4996) using namespace std; int n, m, p[1000]; int main() { while (true) { scanf("%d%d", &n, &m); if (n == 0 && m == 0) break; for (int i = 0; i < n; i++) scanf("%d", &p[i]); sort(p, p + n); int ret = 0; for (int i = ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 109], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 22]]
1
156
4
#include <algorithm> #include <functional> #include <iostream> #include <vector> /*The function calculates vegetables which you purchase.*/ int purchase_price(const int n, const int m) { // The price of purchased vegetables std::vector<int> purchase; // input for (int i = 0; i < n; ++i) { int tmp; st...
#include <algorithm> #include <functional> #include <iostream> #include <vector> /*The function calculates vegetables which you purchase.*/ int purchase_price(const int n, const int m) { // The price of purchased vegetables std::vector<int> purchase; // input for (int i = 0; i < n; ++i) { int tmp; st...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 345, 348], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 0, 349], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 141, 22]]
1
201
4
#include <algorithm> #include <iostream> #include <vector> int main() { std::vector<int> vegetables; int num, cap, price, i; while (std::cin >> num >> cap) { if (num == 0 && cap == 0) { break; } int sum = 0; for (i = 0; i < num; ++i) { std::cin >> price; vegetables.push_back...
#include <algorithm> #include <iostream> #include <vector> int main() { std::vector<int> vegetables; int num, cap, price, i; while (std::cin >> num >> cap) { if (num == 0 && cap == 0) { break; } int sum = 0; for (i = 0; i < num; ++i) { std::cin >> price; vegetables.push_back...
[["+", 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
160
26
#include <algorithm> #include <iostream> using namespace std; int main() { int a, b, i, sum = 0; int c[a]; while (1) { cin >> a >> b; if (a == 0 && b == 0) break; for (i = 0; i < a; i++) { cin >> c[i]; sum += c[i]; } sort(c, c + a); reverse(c, c + a); for (i = b - 1;...
#include <algorithm> #include <iostream> using namespace std; int main() { int a, b, i, sum = 0; int c[10000]; while (1) { cin >> a >> b; if (a == 0 && b == 0) break; for (i = 0; i < a; i++) { cin >> c[i]; sum += c[i]; } sort(c, c + a); reverse(c, c + a); for (i = b ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
140
2
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int m, n; while (cin >> n >> m, n) { int plz[1050] = {0}, total = 0, cnt = 1; for (int i = 0; i < n; i++) { cin >> plz[i]; } sort(plz, plz + n); reverse(plz, plz + n); for (in...
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int m, n; while (cin >> n >> m, n) { int plz[1050] = {0}, total = 0, cnt = 1; for (int i = 0; i < n; i++) { cin >> plz[i]; } sort(plz, plz + n); reverse(plz, plz + n); for (in...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
148
2
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main(int argc, char *argv[]) { int price[1000]; int n, m, pack, hoge, howmach; while (cin ...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main(int argc, char *argv[]) { int price[1000]; int n, m, pack, hoge, howmach; while (cin ...
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
162
4
#define M 26 P[M], A[M], B[M]; int R(a) { return P[a] == a ? a : (P[a] = R(P[a])); } char s[99]; main(k, l, d, x, y) { for (; scanf("%d", &l), l; puts(k < M || d ? "NG" : "OK")) { for (k = 0; k < M; k++) A[k] = B[k] = 0, P[k] = k; for (k = 0; k < l; k++) scanf("%s", s), x = *s - 97, y = s[strlen(s...
#define M 26 P[M], A[M], B[M]; int R(a) { return P[a] == a ? a : (P[a] = R(P[a])); } char s[99]; main(k, l, d, x, y) { for (; scanf("%d", &l), l; puts(k < M || d ? "NG" : "OK")) { for (k = 0; k < M; k++) A[k] = B[k] = 0, P[k] = k; for (k = 0; k < l; k++) scanf("%s", s), x = *s - 97, y = s[strlen(s...
[["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
0
268
22
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <vector> using namespace std; char in[33]; int n, deg[26]; bool v[26]; vector<int> e[26]; void dfs(int c) { v[c] = 1; for (vector<int>::iterator i = e[c].begin(); i < e[c].end(); i++) if (!v[*i]) ...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <vector> using namespace std; char in[33]; int n, deg[26]; bool v[26]; vector<int> e[26]; void dfs(int c) { v[c] = 1; for (vector<int>::iterator i = e[c].begin(); i < e[c].end(); i++) if (!v[*i]) ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
328
1
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #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 <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) ...
[["+", 0, 52, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 18], ["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 47], ["-", 0, 52, 8, 9, 0, 43, 49, 80, 0, 70], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 24], ["-", 0, 52, 8, 9, 0, 43, 49, 80, 0, 73], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 25], ["-", 8, 9, 0, 57,...
1
533
9
#include <cstring> #include <iostream> #include <sstream> #include <string> using namespace std; int graph[26][26]; void DFS(int i) { for (int j = 0; j < 26; j++) { if (graph[i][j] != 0) { graph[i][j]--; DFS(j); } } } int main() { int n; while (cin >> n) { if (!n) break; int ...
#include <cstring> #include <iostream> #include <sstream> #include <string> using namespace std; int graph[26][26]; void DFS(int i) { for (int j = 0; j < 26; j++) { if (graph[i][j] != 0) { graph[i][j]--; DFS(j); } } } int main() { int n; while (cin >> n) { if (!n) break; int ...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
380
2
<?php for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ ) { $input = explode(" ", trim(fgets(STDIN))); if( 0 == $input[0] && 0 == $input[1] ) { break; } $r = str_split($input[0]); $a = str_split($input[1]); $hit = 0; $brow = 0; $loop_r = 0; foreach( $r as $r_char ) { $loop_a = 0...
<?php for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ ) { $input = explode(" ", trim(fgets(STDIN))); if( 0 == $input[0] && 0 == $input[1] ) { break; } $r = str_split($input[0]); $a = str_split($input[1]); ...
[["-", 0, 7, 0, 9, 0, 608, 0, 613, 63, 141], ["-", 0, 9, 0, 608, 0, 613, 3, 3, 0, 24], ["-", 0, 9, 0, 608, 0, 613, 3, 3, 0, 25]]
6
183
3
import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner cin = new Scanner(System.in); for (;;) { String n = cin.next(); String m = cin.next(); if ((n + m).equals("00")) break; char[] s1 = n.toCharArray(); ...
import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner cin = new Scanner(System.in); for (;;) { String n = cin.next(); String m = cin.next(); if ((n + m).equals("00")) break; char[] s1 = n.toCharArray(); ...
[["-", 0, 11, 12, 74, 51, 23, 0, 16, 12, 499], ["+", 0, 11, 12, 74, 51, 23, 0, 16, 12, 499]]
3
264
2
import java.util.Scanner; class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); while (true) { String r, a; r = scan.next(); a = scan.next(); if (r.equals("0") && a.equals("0")) break; int hit = 0, blow = 0; for (int i = 0; i <...
import java.util.Scanner; class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); while (true) { String r, a; r = scan.next(); a = scan.next(); if (r.equals("0") && a.equals("0")) break; int hit = 0, blow = 0; for (int i = 0; i <...
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 499], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 499], ["-", 0, 57, 15, 15, 0, 16, 12, 23, 0, 24], ["-", 0, 57, 15, 15, 0, 16, 12, 23, 0, 25]]
3
185
4
#include <iostream> #include <string> using namespace std; int main() { string taroNomber; string hanakoNomber; int hitCount = 0; int blowCount = 0; while (true) { cin >> taroNomber >> hanakoNomber; if (taroNomber == "0" && hanakoNomber == "0") { break; } hitCount = 0; blowCount = 0...
#include <iostream> #include <string> using namespace std; int main() { string taroNomber; string hanakoNomber; int hitCount = 0; int blowCount = 0; while (true) { cin >> taroNomber >> hanakoNomber; if (taroNomber == "0" && hanakoNomber == "0") { break; } hitCount = 0; blowCount = 0...
[["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
162
4
#include <iostream> #include <string> using namespace std; int main() { while (1) { string stra, strb; cin >> stra >> strb; int h, b; if ((stra == "0") && (strb == "0")) { break; } for (int i = 0; i < 4; i++) { if (stra[i] == strb[i]) { h++; } for (int j = 0;...
#include <iostream> #include <string> using namespace std; int main() { while (1) { string stra, strb; cin >> stra >> strb; int h = 0, b = 0; if ((stra == "0") && (strb == "0")) { break; } for (int i = 0; i < 4; i++) { if (stra[i] == strb[i]) { h++; } for (in...
[["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
147
4
#include <iostream> #include <string> using namespace std; int main() { while (1) { string r; string a; cin >> r >> a; if ((r == "0") && (a == "0")) { break; } int h = 0, b = 0; for (int i; i < 4; i++) { for (int j = 0; j < 4; j++) { if (r[i] == a[j]) { if (...
#include <iostream> #include <string> using namespace std; int main() { while (1) { string r; string a; cin >> r >> a; if ((r == "0") && (a == "0")) { break; } int h = 0, b = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (r[i] == a[j]) { ...
[["+", 8, 9, 0, 7, 10, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 103, 0, 104], ["+", 8, 9, 0, 1, 0, 16, 12, 103, 0, 44]]
1
139
6
#include <iostream> int main() { int h, b, i, j; std::string r, a; while (std::cin >> r >> a, r != "0" && a != "0") { for (h = b = i = 0; i < 4; i++) for (j = 4; j-- > 0;) if (a[i] == r[j]) i = j ? h++ : b++; printf("%d %d\n", h, b); } }
#include <iostream> int main() { int h, b, i, j; std::string r, a; while (std::cin >> r >> a, r != "0" && a != "0") { for (h = b = i = 0; i < 4; i++) for (j = 4; j-- > 0;) if (a[i] == r[j]) i == j ? h++ : b++; printf("%d %d\n", h, b); } }
[["-", 8, 7, 8, 57, 64, 1, 0, 11, 17, 32], ["+", 8, 57, 64, 1, 0, 41, 15, 16, 17, 60]]
1
111
7
#include <iostream> int main() { int h, b, i, j; std::string r, a; while (std::cin >> r >> a, r != "0" && a != "0") { for (h = b = i = 0; i < 4; i++) for (j = 4; j-- > 0;) if (a[i] == r[j]) i = j ? h++ : b++; printf("%d %d\n", h, b); } }
#include <iostream> int main() { int h, b, i, j; std::string r, a; while (std::cin >> r >> a, r != "0" && a != "0") { h = b = i = 0; for (; i < 4; i++) for (j = 4; j-- > 0;) if (a[i] == r[j]) i == j ? h++ : b++; printf("%d %d\n", h, b); } }
[["-", 8, 9, 0, 52, 8, 9, 0, 7, 0, 88], ["-", 8, 9, 0, 52, 8, 9, 0, 7, 0, 24], ["+", 8, 9, 0, 52, 8, 9, 0, 7, 0, 88], ["+", 8, 9, 0, 52, 8, 9, 0, 7, 0, 24], ["+", 8, 9, 0, 52, 8, 9, 0, 7, 0, 35], ["-", 8, 7, 8, 57, 64, 1, 0, 11, 17, 32], ["+", 8, 57, 64, 1, 0, 41, 15, 16, 17, 60]]
1
111
7
#include <iostream> #include <queue> int main() { std::priority_queue<u_int> vegetable; u_int n, m, price; while (1) { std::cin >> n >> m; if (n == 0 && m == 0) break; for (u_int i = 0; i < n; ++i) { std::cin >> price; vegetable.push(price); } u_int sum = 0; for (u_in...
#include <iostream> #include <queue> int main() { std::priority_queue<u_int> vegetable; u_int n, m, price; while (1) { std::cin >> n >> m; if (n == 0 && m == 0) break; for (u_int i = 0; i < n; ++i) { std::cin >> price; vegetable.push(price); } u_int sum = 0; for (u_in...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
138
2
#include <iostream> #include <queue> int main() { int n, m; while (std::cin >> n >> m) { if (n == 0 && m == 0) { break; } std::priority_queue<int> que; int vegetable; for (int i = 0; i < n; ++i) { std::cin >> vegetable; que.push(vegetable); } int price = 0; for (in...
#include <iostream> #include <queue> int main() { int n, m; while (std::cin >> n >> m) { if (n == 0 && m == 0) { break; } std::priority_queue<int> que; int vegetable; for (int i = 0; i < n; ++i) { std::cin >> vegetable; que.push(vegetable); } int price = 0; for (in...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
145
2
#include <iostream> #include <queue> int main() { int m, n; while (std::cin >> n >> m) { // n,mがゼロで終了 if ((n = m) == 0) { break; } int sum_cost = 0; std::priority_queue<int> vegetable; for (int i = 0; i < n; ++i) { int cost; std::cin >> cost; vegetable.push(cost); ...
#include <iostream> #include <queue> int main() { int m, n; while (std::cin >> n >> m) { // n,mがゼロで終了 if (n == 0 && m == 0) { break; } int sum_cost = 0; std::priority_queue<int> vegetable; for (int i = 0; i < n; ++i) { int cost; std::cin >> cost; vegetable.push(cos...
[["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["-", 15, 339, 51, 16, 31, 23, 0, 42, 0, 32], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 25]]
1
145
6
class ProblemB def solve while true total = 0 n, m = gets.split.map(&:to_i) return total if n <= 0 pn = gets.split.map(&:to_i).sort {|a, b| b <=> a } while pn.count > 0 t = [] m.times do |i| t.push pn.shift break if pn.count <= 0 end ...
class ProblemB def solve while true total = 0 n, m = gets.split.map(&:to_i) break if n <= 0 pn = gets.split.map(&:to_i).sort {|a, b| b <=> a } while pn.count > 0 t = [] m.times do t.push pn.shift break if pn.count <= 0 end t.pop ...
[["-", 0, 89, 8, 170, 0, 751, 8, 38, 0, 38], ["-", 8, 170, 0, 751, 8, 38, 0, 4, 0, 22], ["+", 0, 89, 8, 170, 0, 751, 8, 94, 0, 94], ["-", 8, 170, 0, 652, 196, 737, 54, 758, 0, 139], ["-", 8, 170, 0, 652, 196, 737, 54, 758, 0, 22], ["+", 8, 736, 0, 89, 8, 170, 0, 652, 735, 22]]
4
115
7
for i in range(1, 101): count = 0 temp = 0 SetCount = 0 try: str1 = input() list1 = str1.split(" ") str2 = input() list2 = str2.split(" ") list2.sort(reverse=True) for m in range(0, int(list1[0])): if (m+1) % int(list1[1]) == 0: ...
for i in range(1, 101): count = 0 temp = 0 SetCount = 0 try: str1 = input() list1 = str1.split(" ") str2 = input() list2 = str2.split(" ") list2.sort(key=int, reverse=True) for m in range(0, int(list1[0])): if (m+1) % int(list1[1]) == 0: ...
[["+", 0, 1, 0, 652, 3, 4, 0, 653, 141, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 0, 32], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 51, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21]]
5
119
4
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class Main { public static void main(String[] args) { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] bit = new String[10]; bit[0] = "0111111"; bit[1] = "000011...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class Main { public static void main(String[] args) { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] bit = new String[10]; bit[0] = "0111111"; bit[1] = "000011...
[["-", 8, 196, 0, 1, 0, 11, 12, 504, 516, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 504, 516, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 504, 71, 499], ["+", 8, 196, 0, 1, 0, 11, 12, 504, 71, 22]]
3
355
4
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] disp = {"0111111", "0000110", "1011011", "1011111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111", "0000000"}; ...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] disp = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111", "0000000"}; ...
[["-", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491], ["+", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491]]
3
286
2
import java.util.*; public class Main { public static void main(String[] args) { String digits[] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"}; Scanner stdIn = new Scanner(System.in); while (stdIn.hasNext()) { ...
import java.util.*; public class Main { public static void main(String[] args) { String digits[] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"}; Scanner stdIn = new Scanner(System.in); while (stdIn.hasNext()) { ...
[["-", 0, 52, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 0, 52, 8, 196, 0, 7, 8, 196, 0, 46]]
3
255
2
import java.util.Scanner; public class Main { final static String zero = "0000000"; public static void main(String[] args) { int[] num = {077, 06, 0133, 0117, 0146, 0155, 0175, 0147, 0177, 0157}; int n; Scanner in = new Scanner(System.in); while ((n = in.nextInt()) != -1) { int now = 0; ...
import java.util.Scanner; public class Main { final static String zero = "0000000"; public static void main(String[] args) { int[] num = {077, 06, 0133, 0117, 0146, 0155, 0175, 047, 0177, 0157}; int n; Scanner in = new Scanner(System.in); while ((n = in.nextInt()) != -1) { int now = 0; ...
[["-", 8, 196, 0, 503, 49, 200, 51, 518, 0, 524], ["+", 8, 196, 0, 503, 49, 200, 51, 518, 0, 524]]
3
163
2
#include <stdio.h> int main() { char d[][8] = {"0111111", "0000110", "1011011", "1010000", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"}; int n, m, i; while (scanf("%d", &n), n + 1) { char l[8] = {"00000000"}; while (n--) { scanf("%d", &m); for (i = 0; i < ...
#include <stdio.h> int main() { char d[][8] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"}; int n, m, i; while (scanf("%d", &n), n + 1) { char l[8] = {"0000000"}; while (n--) { scanf("%d", &m); for (i = 0; i < 7...
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
0
180
4
#include <stdio.h> int ans[7] = {0, 0, 0, 0, 0, 0, 0}; int num[10][7] = {{0, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 0}, {1, 0, 1, 1, 0, 1, 1}, {1, 0, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0}, {1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 1, 1, 0, 1}, {0, 0, 0, 0, 1, 1, 1}, ...
#include <stdio.h> int ans[7] = {0, 0, 0, 0, 0, 0, 0}; int num[10][7] = {{0, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 0}, {1, 0, 1, 1, 0, 1, 1}, {1, 0, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0}, {1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 1, 1, 0, 1}, {0, 1, 0, 0, 1, 1, 1}, ...
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
0
339
2
n, v; s; S[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f}; main(b, i) { for (; scanf("%d", &n), ~n;) { s = 0; for (; n--;) { scanf("%d", &v); b = S[v] ^ s; if (b) { for (i = 7; i--;) putchar('0' + (b >> i) % 2); puts(""); } s ^= b; ...
n, v; s; S[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f}; main(b, i) { for (; scanf("%d", &n), ~n;) { s = 0; for (; n--;) { scanf("%d", &v); b = S[v] ^ s; for (i = 7; i--;) putchar('0' + (b >> i) % 2); puts(""); s ^= b; } } exit(0); }
[["-", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["-", 0, 7, 8, 9, 0, 57, 15, 23, 0, 24], ["-", 0, 7, 8, 9, 0, 57, 15, 23, 0, 22], ["-", 0, 7, 8, 9, 0, 57, 15, 23, 0, 25], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
0
140
6
#include <stdio.h> int main() { int i, j, n, num, prev; char segment[] = "0000000"; char nums[][8] = {"0111111", "0000110", "1011001", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111", "0000000"}; do { scanf("%d", &n); if (n == -1) ...
#include <stdio.h> int main() { int i, j, n, num, prev; char segment[] = "0000000"; char nums[][8] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111", "0000000"}; do { scanf("%d", &n); if (n == -1) ...
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
0
210
2
#include <stdio.h> #define M 110 int main(void) { int i; int n, num[M]; int sign[8], light[8]; for (;;) { scanf("%d", &n); if (n == -1) break; for (i = 0; i < n; i++) scanf("%d", &num[i]); for (i = 0; i < 8; i++) light[i] = 0; for (i = 0; i < n; i++) { if (num[i]...
#include <stdio.h> #define M 110 int main(void) { int i; int n, num[M]; int sign[8], light[8]; for (;;) { scanf("%d", &n); if (n == -1) break; for (i = 0; i < n; i++) scanf("%d", &num[i]); for (i = 0; i < 8; i++) light[i] = 0; for (i = 0; i < n; i++) { if (num[i]...
[["+", 0, 11, 12, 41, 15, 23, 0, 91, 17, 111]]
0
3,230
2
#include <stdio.h> int main(void) { unsigned int current; unsigned int need; int n, i, j, sn; unsigned int bit[7]; int data[10] = { 0x3f, // 0: 0011 1111 0x06, // 1: 0000 0110 0x5a, // 2: 0101 1011 0x4f, // 3: 0100 1111 0x66, // 4: 0110 0110 0x6d, // 5: 0110 1101 0x7...
#include <stdio.h> int main(void) { unsigned int current; unsigned int need; int n, i, j, sn; unsigned int bit[7]; int data[10] = { // n: gfe dcba 0x3f, // 0: 011 1111 0x06, // 1: 000 0110 0x5b, // 2: 101 1011 0x4f, // 3: 100 1111 0x66, // 4: 110 0110 0x6d, // 5: 110...
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
0
207
2
#include <stdio.h> void out(int s) { int i; for (i = 6; i >= 0; i--) { printf("%d", s >> i & 1); } printf("\n"); } int main() { int p[10] = {077, 06, 0133, 0117, 0146, 0155, 0175, 0147, 0177, 0157}; int n, s, a; while (scanf("%d", &n) == 1 && n != -1) { s = 0; while (n--) { scanf("%d", ...
#include <stdio.h> void out(int s) { int i; for (i = 6; i >= 0; i--) { printf("%d", s >> i & 1); } printf("\n"); } int main() { int p[10] = {077, 06, 0133, 0117, 0146, 0155, 0175, 047, 0177, 0157}; int n, s, a; while (scanf("%d", &n) == 1 && n != -1) { s = 0; while (n--) { scanf("%d", &...
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
0
147
2
#include <stdio.h> #include <string.h> int main(void) { int len, i, num, j; char seg[12][9] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1101101", "1111101", "1111111", "1101111"}, dis[9]; while (scanf("%d", &len) != EOF && len != -1) { strcpy(dis, "0000000...
#include <stdio.h> #include <string.h> int main(void) { int len, i, num, j; char seg[12][9] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"}, dis[9]; while (scanf("%d", &len) != EOF && len != -1) { strcpy(dis, "0000000...
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
0
202
4
#include <iostream> using namespace std; int main() { while (1) { int n, num, j = 0; string sig = "0000000", str; cin >> n; if (n == -1) break; for (int k = 0; k < n; k++) { cin >> num; string ans = ""; if (num == 0) str = "0111111"; else if (num == 1) ...
#include <iostream> using namespace std; int main() { while (1) { int n, num, j = 0; string sig = "0000000", str; cin >> n; if (n == -1) break; for (int k = 0; k < n; k++) { cin >> num; string ans = ""; if (num == 0) str = "0111111"; else if (num == 1) ...
[["-", 0, 57, 64, 1, 0, 11, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 11, 12, 5, 0, 6]]
1
255
2
#include <stdio.h> int main() { int N, x; int A[8] = {0, 0, 0, 0, 0, 0, 0}; int n[8] = {0, 0, 0, 0, 0, 0, 0}; int n0[8] = {0, 1, 1, 1, 1, 1, 1}; int n1[8] = {0, 0, 0, 0, 1, 1, 0}; int n2[8] = {1, 0, 1, 1, 0, 1, 1}; int n3[8] = {1, 0, 0, 1, 1, 1, 1}; int n4[8] = {1, 1, 0, 0, 1, 1, 0}; int n5[8] = {1, ...
#include <stdio.h> int main() { int N, x; int A[8] = {0, 0, 0, 0, 0, 0, 0}; int n[8] = {0, 0, 0, 0, 0, 0, 0}; int n0[8] = {0, 1, 1, 1, 1, 1, 1}; int n1[8] = {0, 0, 0, 0, 1, 1, 0}; int n2[8] = {1, 0, 1, 1, 0, 1, 1}; int n3[8] = {1, 0, 0, 1, 1, 1, 1}; int n4[8] = {1, 1, 0, 0, 1, 1, 0}; int n5[8] = {1, ...
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
719
2
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <util...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <util...
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
231
4
#include <bits/stdc++.h> using namespace std; main() { unsigned long num[11] = {63, 6, 91, 79, 66, 109, 125, 39, 127, 111, 0}; int n, a, b = 10; while (cin >> n, n != -1) { bitset<7> now((unsigned long)0); b = 10; for (int i = 0; i < n; i++) { cin >> a; now = num[b] ^ num[a]; for (in...
#include <bits/stdc++.h> using namespace std; main() { unsigned long num[11] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111, 0}; int n, a, b = 10; while (cin >> n, n != -1) { bitset<7> now((unsigned long)0); b = 10; for (int i = 0; i < n; i++) { cin >> a; now = num[b] ^ num[a]; for (i...
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
143
2
#include <stdio.h> #define MAX 20000 #define MYSCAN scanf int main(void) { int n, m; int i, j; int nowseg[7]; int seg[10][7] = {{0, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 1, 1, 0, 1, 1}, {1, 0, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0}, {1, 1, 0, 1, 1, 0, 1}, ...
#include <stdio.h> #define MAX 20000 #define MYSCAN scanf int main(void) { int n, m; int i, j; int nowseg[7]; int seg[10][7] = {{0, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 0}, {1, 0, 1, 1, 0, 1, 1}, {1, 0, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0}, {1, 1, 0, 1, 1, 0, 1}, ...
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
1
347
2
#include <algorithm> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <vector> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define debug(x) cout << "debug ...
#include <algorithm> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <vector> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define debug(x) cout << "debug ...
[["-", 49, 50, 51, 83, 0, 83, 0, 5, 0, 6], ["+", 49, 50, 51, 83, 0, 83, 0, 5, 0, 6]]
1
223
4