buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
import java.util.Scanner; public class Main { static Scanner sc; static int C1, C2, C3, count; public static void main(String[] args) { sc = new Scanner(System.in); new Main(); } Main() { while (sc.hasNext()) { C1 = sc.nextInt(); C2 = sc.nextInt(); C3 = sc.nextInt(); for (int i = 1; i <= 10; i++) { if (!(i == C1 || i == C2 || i == C3)) { if (i + C1 + C2 <= 20) count++; } } Print(); } } void Print() { if (count >= 4) System.out.println("YES"); else System.out.println("NO"); } }
import java.util.Scanner; public class Main { static Scanner sc; static int C1, C2, C3, count; public static void main(String[] args) { sc = new Scanner(System.in); new Main(); } Main() { while (sc.hasNext()) { C1 = sc.nextInt(); C2 = sc.nextInt(); C3 = sc.nextInt(); count = 0; for (int i = 1; i <= 10; i++) { if (!(i == C1 || i == C2 || i == C3)) { if (i + C1 + C2 <= 20) count++; } } Print(); } } void Print() { if (count >= 4) System.out.println("YES"); else System.out.println("NO"); } }
[["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 499], ["+", 8, 519, 0, 52, 8, 196, 0, 1, 0, 35]]
3
179
4
#include <stdio.h> int main(void) { int c1, c2, c3, i; int n = 0; while (scanf("%d %d %d", &c1, &c2, &c3) != EOF) { for (i = 1; i <= 10; i++) { if (i != c1 && i != c2 && i != c3 && c1 + c2 + i <= 20) n++; } if (n >= 4) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }
#include <stdio.h> int main(void) { int c1, c2, c3, i; int n = 0; while (scanf("%d %d %d", &c1, &c2, &c3) != EOF) { for (i = 1; i <= 10; i++) { if (i != c1 && i != c2 && i != c3 && c1 + c2 + i <= 20) n++; } if (n >= 4) { printf("YES\n"); } else { printf("NO\n"); } n = 0; } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
115
4
#include <stdio.h> int main() { int c1, c2, c3, i, count; int card[10]; while (scanf("%d %d %d", &c1, &c2, &c3) != EOF) { for (i = 0; i < 10; i++) card[i] = 0; card[c1 - 1] = 1; card[c2 - 1] = 1; card[c3 - 1] = 1; count = 0; for (i = 0; i + c1 + c2 < 21; i++) { if (card[i - 1] == 0) count++; } if (count > 3) printf("YES\n"); else printf("NO\n"); } return 0; }
#include <stdio.h> int main() { int c1, c2, c3, i, count; int card[10]; while (scanf("%d %d %d", &c1, &c2, &c3) != EOF) { for (i = 0; i < 10; i++) card[i] = 0; card[c1 - 1] = 1; card[c2 - 1] = 1; card[c3 - 1] = 1; count = 0; for (i = 1; i + c1 + c2 < 21; i++) { if (card[i - 1] == 0) count++; } if (count > 3) printf("YES\n"); else printf("NO\n"); } return 0; }
[["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13]]
0
157
2
#include <stdio.h> int main() { int i; int a, b, c, d; while (scanf("%d%d%d", &a, &b, &c) != -1) { d = 0; for (i = 1; i < 11; i++) { if (i != a && i != b && i != c) if (a + b + i <= 20) d++; } if (d > 3) printf("YES"); else printf("NO"); } return 0; }
#include <stdio.h> int main() { int i; int a, b, c, d; while (scanf("%d%d%d", &a, &b, &c) != -1) { d = 0; for (i = 1; i < 11; i++) { if (i != a && i != b && i != c) if (a + b + i <= 20) d++; } if (d > 3) puts("YES"); else puts("NO"); } return 0; }
[["-", 8, 9, 0, 57, 64, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 2, 63, 22], ["-", 0, 57, 75, 76, 0, 1, 0, 2, 63, 22], ["+", 0, 57, 75, 76, 0, 1, 0, 2, 63, 22]]
0
112
4
#include <stdio.h> int main() { int c1, c2, c3; int card[11]; while (scanf("%d %d %d", &c1, &c2, &c3) != EOF) { int i; int cnt = 0; for (i = 0; i < 11; i++) card[i] = i; card[c1] = 0; card[c2] = 0; card[c3] = 0; for (i = 1; i < 11; i++) { if (card[i] > 0 && c1 + c2 + card[i] <= 20) cnt++; } if (cnt >= 3) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }
#include <stdio.h> int main() { int c1, c2, c3; int card[11]; while (scanf("%d %d %d", &c1, &c2, &c3) != EOF) { int i; int cnt = 0; for (i = 0; i < 11; i++) card[i] = i; card[c1] = 0; card[c2] = 0; card[c3] = 0; for (i = 1; i < 11; i++) { if (card[i] > 0 && c1 + c2 + card[i] <= 20) cnt++; } if (cnt >= 4) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
160
2
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; public class Main { public static void main(String args[]) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { String line; int count = 0; while ((line = br.readLine()) != null) { if (line.isEmpty()) break; char[] chars = line.toCharArray(); char[] charsR = new char[chars.length]; for (int i = 0; i < chars.length; i++) { charsR[chars.length - 1 - i] = chars[i]; } String r = charsR.toString(); if (r.equals(line)) { count++; } } br.close(); System.out.println(count); } catch (Exception e) { e.printStackTrace(); } } }
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; public class Main { public static void main(String args[]) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { String line; int count = 0; while ((line = br.readLine()) != null) { if (line.isEmpty()) break; char[] chars = line.toCharArray(); char[] charsR = new char[chars.length]; for (int i = 0; i < chars.length; i++) { charsR[chars.length - 1 - i] = chars[i]; } String r = String.valueOf(charsR); // System.out.println(r); if (r.equals(line)) { count++; } } br.close(); System.out.println(count); } catch (Exception e) { e.printStackTrace(); } } }
[["-", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 22]]
3
206
5
import java.util.Scanner; class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); String str; int ans = 0; while (scan.hasNext()) { str = scan.next(); char[] ch = str.toCharArray(); for (int i = 0; i < ch.length; i++) { if (ch.length == 1) { ans++; break; } if (ch[i] != ch[ch.length - 1]) break; if (i >= ch.length) { ans++; break; } } } System.out.println(ans); } }
import java.util.Scanner; class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); String str; int ans = 0; while (scan.hasNext()) { str = scan.next(); char[] ch = str.toCharArray(); for (int i = 0; i < ch.length; i++) { if (ch.length == 1) { ans++; break; } if (ch[i] != ch[ch.length - i - 1]) { break; } if (i >= ch.length / 2) { ans++; break; } } } System.out.println(ans); } }
[["+", 0, 16, 12, 504, 71, 16, 31, 16, 12, 22], ["+", 15, 15, 0, 16, 12, 504, 71, 16, 17, 33], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]]
3
146
6
#include <stdio.h> #include <string.h> int main(void) { char a[101]; char b[101]; int c = 0, l; while (scanf("%s", a) != EOF) { l = strlen(a); int i, j; for (i = 0, j = l - 1; i < l - 1; i++, j--) { b[i] = a[j]; } b[l] = '\0'; if (strcmp(a, b) == 0) c++; } printf("%d\n", c); return 0; }
#include <stdio.h> #include <string.h> int main(void) { char a[101]; char b[101]; int c = 0, l; while (scanf("%s", a) != EOF) { l = strlen(a); int i, j; for (i = 0, j = l - 1; i < l; i++, j--) { b[i] = a[j]; } b[l] = '\0'; if (strcmp(a, b) == 0) c++; } printf("%d\n", c); return 0; }
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
0
129
2
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 100 int main(void) { int i, j, x, count = 0; char s[N], str[N]; for (; fgets(s, sizeof(str), stdin) != NULL;) { sscanf(str, "%s", &str); x = 0; j = strlen(str) - 1; i = 0; while (j > i) { if (str[i] != str[j]) { x++; break; } i++; j--; if (i >= j) break; } if (x == 0) count++; } printf("%d\n", count); return 0; }
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 101 int main(void) { int i, j, x, count = 0; char s[N], str[N]; for (; fgets(s, sizeof(str), stdin) != NULL;) { sscanf(s, "%s", &str); x = 0; j = strlen(str) - 1; i = 0; while (j > i) { if (str[i] != str[j]) { x++; break; } i++; j--; if (i >= j) break; } if (x == 0) count++; } printf("%d\n", count); return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
152
4
#include <stdio.h> #include <string.h> int is_odd_Symmetry(const char str[], int len); int is_even_Symmetry(const char str[], int len); int main(void) { char str[100]; int cnt = 0; int len; while (scanf("%s", str) != EOF) { len = (int)strlen(str); if (len == 1) { cnt++; } else { if (len % 2 != 0) { if (is_odd_Symmetry(str, len)) { cnt++; } } else if (len % 2 == 0) { if (is_even_Symmetry(str, len)) { cnt++; } } } } printf("%d\n", cnt); return (0); } int is_odd_Symmetry(const char str[], int len) { int i, range; int count = 0; range = len / 2; for (i = 0; i < range; i++) { if (str[i] == str[len - i - 1]) { count++; } } if (count == range) { return (1); } else { return (0); } } int is_even_Symmetry(const char str[], int len) { int i, range; int count = 0; range = (len / 2); for (i = 0; i <= range; i++) { if (str[i] == str[len - i - 1]) { count++; } } if (count == range) return (1); else return (0); }
#include <stdio.h> #include <string.h> int is_odd_Symmetry(const char str[], int len); int is_even_Symmetry(const char str[], int len); int main(void) { char str[100]; int cnt = 0; int len; while (scanf("%s", str) != EOF) { len = (int)strlen(str); if (len == 1) { cnt++; } else { if (len % 2 != 0) { if (is_odd_Symmetry(str, len)) { cnt++; } } else if (len % 2 == 0) { if (is_even_Symmetry(str, len)) { cnt++; } } } } printf("%d\n", cnt); return (0); } int is_odd_Symmetry(const char str[], int len) { int i, range; int count = 0; range = len / 2; for (i = 0; i < range; i++) { if (str[i] == str[len - i - 1]) { count++; } } if (count == range) { return (1); } else { return (0); } } int is_even_Symmetry(const char str[], int len) { int i, range; int count = 0; range = (len / 2); for (i = 0; i < range; i++) { if (str[i] == str[len - i - 1]) { count++; } } if (count == range) return (1); else return (0); }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
0
326
2
#include <stdio.h> #include <string.h> int main() { char str[101]; long len; int counter = 0; int a = 0; int i; char j; while (scanf("%s", str) != EOF) { counter = 0; len = strlen(str); for (i = 0; i < len; i++) { j = str[len - i]; if (j != str[i]) { counter++; } } if (counter == 0) { a++; } } printf("%d\n", a); return 0; }
#include <stdio.h> #include <string.h> int main() { char str[101]; long len; int counter = 0; int a = 0; int i; char j; while (scanf("%s", str) != EOF) { counter = 0; len = strlen(str); for (i = 0; i < len; i++) { j = str[len - 1 - i]; if (j != str[i]) { counter++; } } if (counter == 0) { a++; } } printf("%d\n", a); return 0; }
[["+", 0, 11, 12, 69, 71, 16, 31, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 69, 71, 16, 17, 33]]
0
123
2
#include <iostream> #include <string> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s; int count = 0; while (cin >> s) { if (s.size() == 1) { count++; } else { bool flag = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() - i - 1]) { flag = false; } } if (flag == false) { count++; } } } cout << count << endl; return 0; }
#include <iostream> #include <string> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s; int count = 0; while (cin >> s) { if (s.size() == 1) { count++; } else { bool flag = true; rep(i, s.size() / 2) { if (s[i] != s[s.size() - i - 1]) { flag = false; } } if (flag == true) { count++; } } } cout << count << endl; return 0; }
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 147], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 146]]
1
122
2
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <utility> #include <vector> typedef long long int ll; using namespace std; string a, b; int main() { int cnt = 0; while (cin >> a) { b = a; reverse(&b[0], &b[b.size() - 1]); if (b == a) cnt++; } cout << cnt << endl; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <utility> #include <vector> typedef long long int ll; using namespace std; string a, b; int main() { int cnt = 0; while (cin >> a) { b = a; reverse(&b[0], &b[b.size()]); if (b == a) cnt++; } cout << cnt << endl; }
[["-", 0, 66, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 66, 28, 69, 341, 342, 0, 16, 12, 13]]
1
90
2
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) for (int i = 0; i < (n); i++) #define sz(obj) ((int)(obj).size()) int main() { string str; int cnt = 0; while (cin >> str) { int ccnt = 0; REP(i, sz(str) / 2) if (str[i] == str[sz(str) - (i + 1)]) ccnt++; if (ccnt == sz(str) / 2) cnt++; cout << cnt << endl; } }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) for (int i = 0; i < (n); i++) #define sz(obj) ((int)(obj).size()) int main() { string str; int cnt = 0; while (cin >> str) { int ccnt = 0; REP(i, sz(str) / 2) if (str[i] == str[sz(str) - (i + 1)]) ccnt++; if (ccnt == sz(str) / 2) cnt++; } cout << cnt << endl; }
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
113
2
#include <iostream> #include <string> using namespace std; int main() { string s; int cnt = 0, flag; while (cin >> s) { bool flag = false; int l = s.length(); for (int i = 0; i <= l / 2; i++) { if (s[i + 1] != s[l - i]) { flag = true; break; } } if (flag == false) cnt++; } cout << cnt << endl; }
#include <iostream> #include <string> using namespace std; int main() { string s; int cnt = 0, flag; while (cin >> s) { bool flag = false; int l = s.length(); for (int i = 0; i <= l / 2; i++) { if (s[i] != s[l - i - 1]) { flag = true; break; } } if (flag == false) cnt++; } cout << cnt << endl; }
[["-", 51, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
103
4
#include <bits/stdc++.h> using namespace std; int main() { string s; int c = 0, p = 0; while (cin >> s) { p++; for (int i = 0; i <= s.size() / 2; i++) { if (s[i] != s[s.size() - 1] - i) { c++; break; } } } cout << p - c << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int c = 0, p = 0; while (cin >> s) { p++; for (int i = 0; i <= s.size() / 2; i++) { if (s[i] != s[s.size() - 1 - i]) { c++; break; } } } cout << p - c << endl; }
[["-", 51, 16, 12, 16, 31, 69, 341, 342, 0, 73], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 73]]
1
92
2
#include <algorithm> #include <iostream> using namespace std; int main() { string inStr, buf; int cnt = 0; while (cin >> inStr, !cin.eof()) { buf = inStr; sort(inStr.rbegin(), inStr.rend()); if (buf == inStr) cnt++; } cout << cnt << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { string inStr, buf; int cnt = 0; while (cin >> inStr, !cin.eof()) { buf = inStr; reverse(inStr.begin(), inStr.end()); if (buf == inStr) cnt++; } cout << cnt << endl; return 0; }
[["-", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
76
6
#include <bitset> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { bitset<60001> is_prime; is_prime.set(); is_prime[0] = false, is_prime[1] = true; for (int i = 2; i * i <= 60000; i++) { for (int j = i + i; j <= 60000; j += i) { is_prime[j] = false; } } vector<int> prime; for (int i = 0; i <= 60000; i++) { if (is_prime[i]) { prime.push_back(i); } } int n; while (scanf("%d ", &n) == 1) { if (n == 0) { break; } int c = 0; for (int i = 0; i < prime.size(); i++) { if (prime[i] > n / 2) { break; } if (is_prime[n - prime[i]]) { c++; } } printf("%d\n", c); } return 0; }
#include <bitset> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { bitset<60001> is_prime; is_prime.set(); is_prime[0] = false, is_prime[1] = false; for (int i = 2; i * i <= 60000; i++) { for (int j = i + i; j <= 60000; j += i) { is_prime[j] = false; } } vector<int> prime; for (int i = 0; i <= 60000; i++) { if (is_prime[i]) { prime.push_back(i); } } int n; while (scanf("%d ", &n) == 1) { if (n == 0) { break; } int c = 0; for (int i = 0; i < prime.size(); i++) { if (prime[i] > n / 2) { break; } if (is_prime[n - prime[i]]) { c++; } } printf("%d\n", c); } return 0; }
[["-", 8, 9, 0, 1, 0, 34, 12, 11, 12, 146], ["+", 8, 9, 0, 1, 0, 34, 12, 11, 12, 147]]
1
225
2
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; const double EPS = 1e-9; typedef vector<int> vint; typedef pair<int, int> pint; #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) template <class T> T RoundOff(T a) { return int(a + .5 - (a < 0)); } template <class T, class C> void chmax(T &a, C b) { if (a < b) a = b; } template <class T, class C> void chmin(T &a, C b) { if (b < a) a = b; } template <class T, class C> pair<T, C> mp(T a, C b) { return make_pair(a, b); } template <class T> vector<bool> getPrimeTable(T max) { vector<bool> table(max + 1); fill(table.begin(), table.end(), false); table[2] = true; for (T i = 3; i <= max; i++) { table[i] = true; for (T j = 2; j * j <= i; j++) { if (!(i % j)) { table[i] = false; break; } } } return table; } int main() { vector<bool> prime = getPrimeTable(50000); int n; while (cin >> n) { int res = 0; REP(i, 1, n / 2 + 1) if (prime[i] && prime[n - i]) res++; cout << res << endl; } }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; const double EPS = 1e-9; typedef vector<int> vint; typedef pair<int, int> pint; #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) template <class T> T RoundOff(T a) { return int(a + .5 - (a < 0)); } template <class T, class C> void chmax(T &a, C b) { if (a < b) a = b; } template <class T, class C> void chmin(T &a, C b) { if (b < a) a = b; } template <class T, class C> pair<T, C> mp(T a, C b) { return make_pair(a, b); } template <class T> vector<bool> getPrimeTable(T max) { vector<bool> table(max + 1); fill(table.begin(), table.end(), false); table[2] = true; for (T i = 3; i <= max; i++) { table[i] = true; for (T j = 2; j * j <= i; j++) { if (!(i % j)) { table[i] = false; break; } } } return table; } int main() { vector<bool> prime = getPrimeTable(50000); int n; while (cin >> n && n) { int res = 0; REP(i, 1, n / 2 + 1) if (prime[i] && prime[n - i]) res++; cout << res << endl; } }
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
410
2
#include <cmath> #include <iostream> #include <vector> using namespace std; int main() { int n; int not_prime[51000]; int ans; int idx; not_prime[0] = not_prime[1] = 1; for (int i = 2; i <= 50000; i++) not_prime[i] = 0; for (int i = 2; i <= sqrt(50000); i++) { if (not_prime[i] == 0) { for (int j = 2 * i; j <= 50000; j += i) { not_prime[j] = 1; } } } // for(int i=0;i<=50000;i++) cout << not_prime[i] << " "; while (1) { cin >> n; if (n == 0) break; ans = 0; for (int i = 2; i <= n / 2 + 1; i++) { if (not_prime[i] == 0 && not_prime[n - i] == 0) ans++; } cout << ans << endl; } return 0; }
#include <cmath> #include <iostream> #include <vector> using namespace std; int main() { int n; int not_prime[51000]; int ans; int idx; not_prime[0] = not_prime[1] = 1; for (int i = 2; i <= 50000; i++) not_prime[i] = 0; for (int i = 2; i <= sqrt(50000); i++) { if (not_prime[i] == 0) { for (int j = 2 * i; j <= 50000; j += i) { not_prime[j] = 1; } } } // for(int i=0;i<=50000;i++) cout << not_prime[i] << " "; while (1) { cin >> n; if (n == 0) break; ans = 0; for (int i = 2; i <= n / 2; i++) { if (not_prime[i] == 0 && not_prime[n - i] == 0) ans++; } cout << ans << endl; } return 0; }
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
193
2
#include <iostream> using namespace std; bool is_prime[50001]; void sieve() { for (int i = 0; i < 50001; i++) { is_prime[i] = true; } is_prime[0] = is_prime[1] = false; for (int i = 2; i < 50001; i++) { if (is_prime[i]) { for (int j = 2 * i; j < 50001; j += i) { is_prime[j] = false; } } } } int main() { int n; sieve(); while (cin >> n) { if (n == 0) break; int ans = 0; for (int i = 2; i <= (n + 1) / 2; i++) { if (is_prime[i]) { if (is_prime[n - i]) { ans++; } } } cout << ans << endl; } }
#include <iostream> using namespace std; bool is_prime[50001]; void sieve() { for (int i = 0; i < 50001; i++) { is_prime[i] = true; } is_prime[0] = is_prime[1] = false; for (int i = 2; i < 50001; i++) { if (is_prime[i]) { for (int j = 2 * i; j < 50001; j += i) { is_prime[j] = false; } } } } int main() { int n; sieve(); while (cin >> n) { if (n == 0) break; int ans = 0; for (int i = 2; i <= n / 2; i++) { if (is_prime[i]) { if (is_prime[n - i]) { ans++; } } } cout << ans << endl; } }
[["-", 0, 7, 15, 16, 12, 16, 31, 23, 0, 24], ["-", 15, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["-", 15, 16, 12, 16, 31, 23, 0, 16, 12, 13], ["-", 0, 7, 15, 16, 12, 16, 31, 23, 0, 25]]
1
189
4
#include <cstdio> using namespace std; int sosu[55555]; main() { int N; sosu[0] = 1; sosu[1] = 1; for (int j = 2; j < 224; j++) { if (sosu[j] == 1) continue; for (int i = j * j; i < 50001; i *= j) { sosu[i] = 1; } } while (1) { scanf("%d", &N); if (N == 0) break; int res = 0; for (int i = 2; i <= N / 2; i++) { int a = N - i; if (sosu[a] == 0 && sosu[i] == 0) { res++; } } printf("%d\n", res); } }
#include <cstdio> using namespace std; int sosu[55555]; main() { int N; sosu[0] = 1; sosu[1] = 1; for (int j = 2; j < 224; j++) { if (sosu[j] == 1) continue; for (int i = j + j; i < 50001; i += j) { sosu[i] = 1; } } while (1) { scanf("%d", &N); if (N == 0) break; int res = 0; for (int i = 2; i <= N / 2; i++) { int a = N - i; if (sosu[a] == 0 && sosu[i] == 0) { res++; } } printf("%d\n", res); } }
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 48], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 8, 9, 0, 7, 26, 11, 17, 108], ["+", 0, 7, 8, 9, 0, 7, 26, 11, 17, 107]]
1
172
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool isPrime(int n) { if (n <= 1 || n != 2 && (n & 1) == 0) return false; for (int i = 3; i * i <= n; i += 2) if (n % i == 0) return false; return true; } int main() { vector<int> primes; for (int i = 2; i <= 50000; i++) if (isPrime(i)) primes.push_back(i); int n, ans; while (cin >> n) { ans = 0; for (int i = 0; i < primes.size(); i++) { if (n / 2 < primes[i]) break; if (binary_search(primes.begin(), primes.end(), n - primes[i])) ans++; } cout << ans << endl; } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool isPrime(int n) { if (n <= 1 || n != 2 && (n & 1) == 0) return false; for (int i = 3; i * i <= n; i += 2) if (n % i == 0) return false; return true; } int main() { vector<int> primes; for (int i = 2; i <= 50000; i++) if (isPrime(i)) primes.push_back(i); int n, ans; while (cin >> n, n) { ans = 0; for (int i = 0; i < primes.size(); i++) { if (n / 2 < primes[i]) break; if (binary_search(primes.begin(), primes.end(), n - primes[i])) ans++; } cout << ans << endl; } return 0; }
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
196
2
#include <bitset> #include <cmath> #include <iostream> #include <list> int main() { const int max = 50021; std::bitset<max + 1> bitTable; bitTable.set(0); bitTable.set(1); int loop = sqrt(max); for (int i = 2; i <= loop; ++i) { if (bitTable.test(i) == false) { for (int j = i * i; j <= max; j += i) { bitTable.set(j); } } } std::list<int> primeList; for (int i = 2; i <= max; ++i) if (bitTable.test(i) == false) primeList.push_back(i); int n; while (std::cin >> n) { if (n == 0 || n > max) break; std::list<int>::iterator itr = primeList.begin(); int num; for (num = 0; itr != primeList.end(); ++itr) { if (n - (*itr << 1) <= 0) break; if (bitTable.test(n - *itr) == false) ++num; } std::cout << num << std::endl; } return 0; }
#include <bitset> #include <cmath> #include <iostream> #include <list> int main() { const int max = 50021; std::bitset<max + 1> bitTable; bitTable.set(0); bitTable.set(1); int loop = sqrt(max); for (int i = 2; i <= loop; ++i) { if (bitTable.test(i) == false) { for (int j = i * i; j <= max; j += i) { bitTable.set(j); } } } std::list<int> primeList; for (int i = 2; i <= max; ++i) if (bitTable.test(i) == false) primeList.push_back(i); int n; while (std::cin >> n) { if (n == 0 || n > max) break; std::list<int>::iterator itr = primeList.begin(); int num; for (num = 0; itr != primeList.end(); ++itr) { if (n - (*itr << 1) < 0) break; if (bitTable.test(n - *itr) == false) ++num; } std::cout << num << std::endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
255
2
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, n) FOR(i, 0, (n)-1) const double EPS = 1e-12; const double PI = acos(-1.0); const int INF = INT_MAX / 10; int main() { vi prime(50000 + 1, 1); prime[0] = prime[1] = 0; FOR(i, 2, sqrt(50000) + 1) { if (prime[i]) { for (int j = i * 2; j <= 50000; j += i) { prime[j] = 0; } } } int n; while (cin >> n, n) { int m = n / 2 + (n % 2); int ans = 0; FOR(i, 2, m) { if (prime[i] && prime[n - i]) { ans++; } } cout << ans << endl; } return 0; }
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, n) FOR(i, 0, (n)-1) const double EPS = 1e-12; const double PI = acos(-1.0); const int INF = INT_MAX / 10; int main() { vi prime(50000 + 1, 1); prime[0] = prime[1] = 0; FOR(i, 2, sqrt(50000) + 1) { if (prime[i]) { for (int j = i * 2; j <= 50000; j += i) { prime[j] = 0; } } } int n; while (cin >> n, n) { int m = n / 2; int ans = 0; FOR(i, 2, m) { if (prime[i] && prime[n - i]) { ans++; } } cout << ans << endl; } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 43, 49, 50, 51, 16, 12, 23, 0, 24], ["-", 49, 50, 51, 16, 12, 23, 0, 16, 31, 22], ["-", 49, 50, 51, 16, 12, 23, 0, 16, 17, 109], ["-", 49, 50, 51, 16, 12, 23, 0, 16, 12, 13], ["-", 0, 43, 49, 50, 51, 16, 12, 23, 0, 25]]
1
330
6
#include <cmath> #include <iostream> #include <vector> typedef std::vector<int> vi; vi PRIMES, S; int prime(int n) { int i = 0, j = 1, h = (n + 1) / 2, x, r = (int)pow(n, .5); vi s(h), p; while (j <= n) { s[i++] = j; j += 2; } for (i = 1; i < h; i++) if (x = s[i]) { p.push_back(x); if (i <= r) for (j = x * x / 2; j < h; j += x) s[j] = 0; } PRIMES = p; S = s; return 0; } int f0056(int n) { int x = 0, i, e; if (n < 4) return 0; if (n == 4) return 1; if (n % 2 == 1) if (S[(n - 2) / 2]) return 1; for (i = 0; i < PRIMES.size(); i++) { e = PRIMES[i]; if (e > n / 2) break; if (S[(n - e) / 2]) x++; } return x; } int main(void) { int n; prime(105000); while (true) { std::cin >> n; if (n == 0) break; std::cout << f0056(n) << "\n"; } }
#include <cmath> #include <iostream> #include <vector> typedef std::vector<int> vi; vi PRIMES, S; int prime(int n) { int i = 0, j = 1, h = (n + 1) / 2, x, r = (int)pow(n, .5); vi s(h), p; while (j <= n) { s[i++] = j; j += 2; } for (i = 1; i < h; i++) if (x = s[i]) { p.push_back(x); if (i <= r) for (j = x * x / 2; j < h; j += x) s[j] = 0; } PRIMES = p; S = s; return 0; } int f0056(int n) { int x = 0, i, e; if (n < 4) return 0; if (n == 4) return 1; if (n % 2 == 1) { if (S[(n - 2) / 2]) return 1; } else for (i = 0; i < PRIMES.size(); i++) { e = PRIMES[i]; if (e > n / 2) break; if (S[(n - e) / 2]) x++; } return x; } int main(void) { int n; prime(105000); while (true) { std::cin >> n; if (n == 0) break; std::cout << f0056(n) << "\n"; } }
[["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
1
324
3
#include <iostream> #define N 50000 using namespace std; bool isP[N + 1]; void make_isP() { isP[0] = isP[1] = false; for (int i = 2; i <= N; i++) isP[i] = true; for (int i = 2; i * i <= N; i++) { if (!isP[i]) continue; for (int j = i * i; j <= N; j += i) isP[j] = false; } } int main() { make_isP(); int n, cnt; while (cin >> n && n) { cnt = 0; for (int i = n; i >= n / 2; i--) { if (isP[i] && isP[n - i]) { cnt++; } } cout << cnt << endl; } return 0; }
#include <iostream> #define N 50000 using namespace std; bool isP[N + 1]; void make_isP() { isP[0] = isP[1] = false; for (int i = 2; i <= N; i++) isP[i] = true; for (int i = 2; i * i <= N; i++) { if (!isP[i]) continue; for (int j = i * i; j <= N; j += i) isP[j] = false; } } int main() { make_isP(); // for(int i=0;i<=20;i++)cout<<i<<" "<<isP[i]<<endl; int n, cnt; while (cin >> n && n) { cnt = 0; for (int i = 0; i <= n / 2; i++) { if (isP[i] && isP[n - i]) { cnt++; } } cout << cnt << endl; } return 0; }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 20], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 52, 8, 9, 0, 7, 26, 27, 17, 68], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29]]
1
183
6
#include <iostream> bool sosuu[50001]; void init() { for (int i = 0; i < 50001; i++) sosuu[i] = true; sosuu[0] = sosuu[1] = false; for (int i = 2; i * i < 50001; i++) { if (sosuu[i]) { for (int j = i * 2; j < 50001; j += i) sosuu[j] = false; } } } int main() { init(); int n; while (std::cin >> n, n) { int cnt = 0; for (int i = 1; i <= n / 2; i += 2) { if (sosuu[i] && sosuu[n - i]) cnt++; } std::cout << cnt << std::endl; } return 0; }
#include <iostream> bool sosuu[50001]; void init() { for (int i = 0; i < 50001; i++) sosuu[i] = true; sosuu[0] = sosuu[1] = false; for (int i = 2; i * i < 50001; i++) { if (sosuu[i]) { for (int j = i * 2; j < 50001; j += i) sosuu[j] = false; } } } int main() { init(); int n; while (std::cin >> n, n) { int cnt = 0; for (int i = 2; i <= n / 2; i++) { if (sosuu[i] && sosuu[n - i]) cnt++; } std::cout << cnt << std::endl; } return 0; }
[["-", 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, 26, 11, 17, 107], ["-", 0, 52, 8, 9, 0, 7, 26, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29]]
1
177
5
primes = Array.new(50000, true) primes[0, 2] = [false, false] 2.upto(50000 - 1){|x| if primes[x] m = 2 while x * m <= 999_999 primes[x * m] = false m += 1 end end } while true n = gets.to_i break if n == 0 sum = 0 3.upto(n/2){|x| sum += 1 if primes[x] && primes[n - x]} puts sum end
primes = Array.new(50000, true) primes[0, 2] = [false, false] 2.upto(50000 - 1){|x| if primes[x] m = 2 while x * m <= 999_999 primes[x * m] = false m += 1 end end } while true n = gets.to_i break if n == 0 sum = 0 2.upto(n/2){|x| sum += 1 if primes[x] && primes[n - x]} puts sum end
[["-", 0, 493, 0, 89, 8, 170, 0, 652, 486, 612], ["+", 0, 493, 0, 89, 8, 170, 0, 652, 486, 612]]
4
108
2
def primes(max) nums = Array.new(max + 1, 1) nums[0] = nums[1] = 0 (2..Math.sqrt(max)).each do |sieve| if nums[sieve] == 1 (2 * sieve).step(max, sieve).each do |num| nums[num] = 0 end end end nums end max = 50 primes = primes(max) nums = (2..max).select { |num| primes[num] == 1 } while line = gets n = line.chomp.to_i break if n == 0 answer = 0 for i in nums j = n - i break if i > j answer += 1 if primes[j] == 1 end puts answer end
def primes(max) nums = Array.new(max + 1, 1) nums[0] = nums[1] = 0 (2..Math.sqrt(max)).each do |sieve| if nums[sieve] == 1 (2 * sieve).step(max, sieve).each do |num| nums[num] = 0 end end end nums end max = 50_000 primes = primes(max) nums = (2..max).select { |num| primes[num] == 1 } while line = gets n = line.chomp.to_i break if n == 0 answer = 0 for i in nums j = n - i break if i > j answer += 1 if primes[j] == 1 end puts answer end
[["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612]]
4
156
2
sn = 50000.0**0.5 + 1 is_prime = [false, false] + [true]*49999 (2..sn).each do |i| next unless is_prime[i] (i*i).step(50000, i).each do |j| is_prime[j] = false end end plist = (2..50000).to_a.select{ |i| is_prime[i] } while gets s = $_.to_i tmp = plist.dup l = tmp.shift h = tmp.pop c = 0 until tmp.empty? if l + h == s c += 1 l = tmp.shift elsif l + h < s l = tmp.shift else h = tmp.pop end end c += 1 if l*2 == s or h*2 == s or l+h == s puts c end
sn = 50000.0**0.5 + 1 is_prime = [false, false] + [true]*49999 (2..sn).each do |i| next unless is_prime[i] (i*i).step(50000, i).each do |j| is_prime[j] = false end end plist = (2..50000).to_a.select{ |i| is_prime[i] } while gets s = $_.to_i break if s == 0 tmp = plist.dup l = tmp.shift h = tmp.pop c = 0 until tmp.empty? if l + h == s c += 1 l = tmp.shift elsif l + h < s l = tmp.shift else h = tmp.pop end end c += 1 if l*2 == s or h*2 == s or l+h == s puts c end
[["+", 0, 89, 8, 170, 0, 751, 8, 94, 0, 94], ["+", 0, 493, 0, 89, 8, 170, 0, 751, 0, 121], ["+", 0, 89, 8, 170, 0, 751, 15, 738, 31, 22], ["+", 0, 89, 8, 170, 0, 751, 15, 738, 17, 60], ["+", 0, 89, 8, 170, 0, 751, 15, 738, 12, 612]]
4
169
5
import sys f = sys.stdin def create_prime(n): prime = [1] * (n + 1) prime[:2] = [0, 0] for i in range(len(prime)): if prime[i]: for j in range(2 * i, len(prime), i): prime[j] = 0 return prime sieve = create_prime(50000) prime = [] for i in range(25001): if sieve[i]: prime.append(i) while True: n = int(f.readline()) if n == 0: break cnt = 0 temp = n // 2 + 1 for i in prime: if i > temp: break if sieve[n - i]: cnt += 1 print(cnt)
import sys f = sys.stdin def create_prime(n): prime = [1] * (n + 1) prime[:2] = [0, 0] for i in range(len(prime)): if prime[i]: for j in range(2 * i, len(prime), i): prime[j] = 0 return prime sieve = create_prime(50000) prime = [] for i in range(25001): if sieve[i]: prime.append(i) while True: n = int(f.readline()) if n == 0: break cnt = 0 temp = n // 2 for i in prime: if i > temp: break if sieve[n - i]: cnt += 1 print(cnt)
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]]
5
162
2
N = 50001 lst = [True] * N lst[0] = False lst[1] = False for i in range(2, int(N ** 0.5) + 1): if lst[i]: for j in range(i * i, N, i): lst[j] = False primes = [i for i in range(1, N) if lst[i]] for s in sys.stdin: n = int(s) if n == 0: break elif n % 2 == 1: if lst[n - 2]: print((1)) else: print((0)) elif n == 4: print((1)) else: counter = 0 for prime0 in primes: prime1 = n - prime0 if prime0 <= prime1 and lst[prime1]: #print(prime0, prime1) counter += 1 print(counter)
import sys N = 50001 lst = [True] * N lst[0] = False lst[1] = False for i in range(2, int(N ** 0.5) + 1): if lst[i]: for j in range(i * i, N, i): lst[j] = False primes = [i for i in range(1, N) if lst[i]] for s in sys.stdin: n = int(s) if n == 0: break elif n % 2 == 1: if lst[n - 2]: print((1)) else: print((0)) elif n == 4: print((1)) else: counter = 0 for prime0 in primes: prime1 = n - prime0 if prime0 <= prime1 and lst[prime1]: #print(prime0, prime1) counter += 1 print(counter)
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
176
2
import java.util.Scanner; class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n; int ans; while (scan.hasNextInt()) { n = scan.nextInt(); ans = 1; for (int i = 1; i < n; i++) { ans += n; } System.out.println(ans); } } }
import java.util.Scanner; class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n; int ans; while (scan.hasNextInt()) { n = scan.nextInt(); ans = 1; for (int i = 1; i <= n; i++) { ans += i; } System.out.println(ans); } } }
[["-", 0, 52, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22]]
3
91
4
import java.util.*; public class Main { public static void main(String[] args) { new Main().run(); } Scanner sc = new Scanner(System.in); int[] lines = new int[10001]; void run() { part(); while (sc.hasNext()) { int n = sc.nextInt(); System.out.println(lines[n]); } } void part() { lines[0] = 1; lines[1] = 2; lines[2] = 4; lines[3] = 7; for (int i = 4; i < lines.length; i++) { lines[i] = lines[i - 1] + lines[i - 2]; } } }
import java.util.*; public class Main { public static void main(String[] args) { new Main().run(); } Scanner sc = new Scanner(System.in); int[] lines = new int[10001]; void run() { part(); while (sc.hasNext()) { int n = sc.nextInt(); System.out.println(lines[n]); } } void part() { lines[0] = 1; lines[1] = 2; lines[2] = 4; lines[3] = 7; for (int i = 4; i < lines.length; i++) { lines[i] = lines[i - 1] + i; } } }
[["-", 0, 1, 0, 11, 12, 16, 12, 504, 516, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 0, 70], ["-", 0, 11, 12, 16, 12, 504, 71, 16, 17, 33], ["-", 0, 11, 12, 16, 12, 504, 71, 16, 12, 499], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 0, 73]]
3
167
5
#include <stdio.h> int main(void) { int a; while (scanf("%d", &a) != EOF) { printf("%d", (a * (a + 1) + 2) / 2); } return 0; }
#include <stdio.h> int main(void) { int a; while (scanf("%d", &a) != EOF) { printf("%d\n", (a * (a + 1) + 2) / 2); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
52
1
#include <stdio.h> int main(void) { int a = 1, n; int i; while (scanf("%d", &n) != EOF) { for (i = 1; i <= n; i++) a += i; printf("%d\n", a); } return 0; }
#include <stdio.h> int main(void) { int a, n; int i; while (scanf("%d", &n) != EOF) { a = 1; for (i = 1; i <= n; i++) a += i; printf("%d\n", a); } return 0; }
[["-", 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
65
6
#include <stdio.h> int main(void) { int n, m; char str[100]; for (; fgets(str, sizeof(str), stdin) != NULL;) { sscanf(str, "%d", &n); m = (n * n + 2) / 2; printf("%d\n", m); } return 0; }
#include <stdio.h> int main(void) { int n, m; char str[100]; for (; fgets(str, sizeof(str), stdin) != NULL;) { sscanf(str, "%d", &n); m = (n * n + n + 2) / 2; printf("%d\n", m); } return 0; }
[["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72]]
0
77
2
#include <stdio.h> int main(void) { int i, n, sum; while (scanf("%d", &n) != EOF) { sum = 1; for (i = 1; i <= n; i++) { sum += i; } printf("%d", sum); } return 0; }
#include <stdio.h> int main(void) { int i, n, sum; while (scanf("%d", &n) != EOF) { sum = 1; for (i = 1; i <= n; i++) { sum += i; } printf("%d\n", sum); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
67
1
main(a) { while (~scanf("%d", &a)) printf("%d\n", 1 + a * (+1) / 2); }
main(a) { while (~scanf("%d", &a)) printf("%d\n", 1 + a * (a + 1) / 2); }
[["-", 0, 16, 12, 16, 31, 16, 12, 23, 0, 13], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 13]]
0
37
4
#include <stdio.h> int main() { int n, roop, area = 1; while (scanf("%d", &n) != EOF) { for (roop = 1; roop <= n; roop++) { area += roop; } printf("%d\n", area + 1); area = 0; } return 0; }
#include <stdio.h> int main() { int n, roop, area = 1; while (scanf("%d", &n) != EOF) { for (roop = 1; roop <= n; roop++) { area += roop; } printf("%d\n", area); area = 1; } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
0
71
4
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { char buf[81]; int n = 0; while (scanf("%s\n", buf) != EOF) { int t = 0; for (int i = 0; buf[i] != '\0'; ++i) { char c = buf[i]; if (isdigit(c)) t = t * 10 + (c - '0'); else { n += t; t = 0; } } } printf("%d\n", n); return 0; }
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { char buf[81]; int n = 0; while (scanf("%s\n", buf) != EOF) { int t = 0; for (int i = 0; buf[i] != '\0'; ++i) { char c = buf[i]; if (isdigit(c)) t = t * 10 + (c - '0'); else { n += t; t = 0; } } n += t; } printf("%d\n", n); return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
142
4
#include <iostream> #include <string> using namespace std; int main() { string s; int sum = 0; while (cin >> s) { int n = 0; int idx = 0; for (int i = 0; i < s.size(); i++) { if ('0' <= s[i] && s[i] <= '9') n = n * 10 + s[i] - '0'; else if (n) { sum += n; n = 0; } } } cout << sum << endl; }
#include <iostream> #include <string> using namespace std; int main() { string s; int sum = 0; while (cin >> s) { int n = 0; int idx = 0; for (int i = 0; i < s.size(); i++) { if ('0' <= s[i] && s[i] <= '9') n = n * 10 + s[i] - '0'; else if (n) { sum += n; n = 0; } } sum += n; } cout << sum << endl; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
116
4
#include <iostream> using namespace std; int main() { string s; int ans = 0; while (cin >> s) { for (int i = 0, t = 0; i < s.size(); i++) { if (s[i] >= '0' && s[i] <= '9') t = t * 10 + s[i] - '0'; else if (t != 0) { ans += t; t = 0; } } } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { string s; int ans = 0; while (cin >> s) { s += '.'; for (int i = 0, t = 0; i < s.size(); i++) { if (s[i] >= '0' && s[i] <= '9') t = t * 10 + s[i] - '0'; else if (t != 0) { ans += t; t = 0; } } } cout << ans << endl; return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 104], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 125], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
113
6
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; string s; int main(void) { int ans = 0; while (cin >> s) { int c = 0; for (int i = 0; i < (int)s.size(); i++) { if ('0' <= s[i] && s[i] <= '9') { c *= 10; c += s[i] - '0'; } else { ans += c; c = 0; } } } cout << ans << endl; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; string s; int main(void) { int ans = 0; while (cin >> s) { int c = 0; for (int i = 0; i < (int)s.size(); i++) { if ('0' <= s[i] && s[i] <= '9') { c *= 10; c += s[i] - '0'; } else { ans += c; c = 0; } } ans += c; } cout << ans << endl; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
117
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; inline int to_int(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string to_str(T x) { ostringstream sout; sout << x; return sout.str(); } typedef long long ll; int main() { string sent; // prevs: 個々の数 ans: answer int prevs = 0, ans = 0; while (cin >> sent) { for (int i = 0; i < sent.size(); i++) { if (sent[i] >= '0' && sent[i] <= '9') { prevs *= 10; prevs += sent[i] - '0'; } else { ans += prevs; prevs = 0; } } ans += prevs; } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; inline int to_int(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string to_str(T x) { ostringstream sout; sout << x; return sout.str(); } typedef long long ll; int main() { string sent; // prevs: 個々の数 ans: answer int prevs = 0, ans = 0; while (cin >> sent) { for (int i = 0; i < sent.size(); i++) { if (sent[i] >= '0' && sent[i] <= '9') { prevs *= 10; prevs += sent[i] - '0'; } else { ans += prevs; prevs = 0; } } ans += prevs; prevs = 0; } cout << ans << endl; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
203
4
#include <iostream> #include <string> using namespace std; int main() { string in; int ans = 0; while (getline(cin, in)) { int cnt = 0; for (int i = 0; i < in.size(); ++i) { if ('0' <= in[i] && in[i] <= '9') { cnt *= 10; cnt += in[i] - '0'; } else { ans += cnt; cnt = 0; } } } cout << ans << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { string in; int ans = 0; while (getline(cin, in)) { int cnt = 0; for (int i = 0; i < in.size(); ++i) { if ('0' <= in[i] && in[i] <= '9') { cnt *= 10; cnt += in[i] - '0'; } else { ans += cnt; cnt = 0; } } ans += cnt; } cout << ans << endl; return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
115
4
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string.h> using namespace std; int main() { string in; int num = 0; while (cin >> in) { bool flag = false; int temp = 0; for (int i = 0; i < in.length(); i++) { if ('0' <= in[i] && in[i] <= '9') { temp = temp * 10 + (in[i] - '0'); flag = true; } else if (flag == true) { num += temp; temp = 0; flag = false; } } } cout << num << endl; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string.h> using namespace std; int main() { string in; int num = 0; while (cin >> in) { bool flag = false; int temp = 0; for (int i = 0; i <= in.length(); i++) { if ('0' <= in[i] && in[i] <= '9') { temp = temp * 10 + (in[i] - '0'); flag = true; } else if (flag == true) { num += temp; temp = 0; flag = false; } } } cout << num << endl; }
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
138
2
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; int main() { int len; char num[6] = {'\0'}; int total = 0; char s[86]; while (cin >> s) { for (int i = 0; i < strlen(s) - 1; i++) { len = 0; if (s[i] >= '0' && s[i] <= '9') { for (int j = i; j < i + 5; j++) { if (!(s[j] >= '0' && s[j] <= '9')) break; num[len] = s[j]; len++; } len--; } total += atoi(num); i += len; memset(num, '\0', sizeof(num)); } } cout << total << endl; }
#include <cstdlib> #include <cstring> #include <iostream> using namespace std; int main() { int len; char num[6] = {'\0'}; int total = 0; char s[86]; while (cin >> s) { for (int i = 0; i <= strlen(s) - 1; i++) { len = 0; if (s[i] >= '0' && s[i] <= '9') { for (int j = i; j < i + 5; j++) { if (!(s[j] >= '0' && s[j] <= '9')) break; num[len] = s[j]; len++; } len--; } total += atoi(num); i += len; memset(num, '\0', sizeof(num)); } } cout << total << endl; }
[["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
189
4
a=[] while gets a<<$_.chomp.split(/[a-z]+/).map(&:to_i) end p a.flatten.inject(:+)
a=[] while gets a<<$_.chomp.split(/[^0-9]+/).map(&:to_i) end p a.flatten.inject(:+)
[["-", 12, 652, 486, 652, 3, 4, 0, 575, 0, 6], ["+", 12, 652, 486, 652, 3, 4, 0, 575, 0, 6]]
4
34
2
#!/usr/bin/env ruby sum = 0 while line = gets stc = line.chomp.split('') ary = [] stc.each do |chr| if chr =~ /^[0-9]+$/ ary << chr.to_i else unless ary.length.zero? ary = ary.reverse (ary.length).times do |i| sum += ary[i] * (10 ** i) end ary = [] end end end end puts sum
#!/usr/bin/env ruby sum = 0 while line = gets stc = line.split('') ary = [] stc.each do |chr| if chr =~ /^[0-9]+$/ ary << chr.to_i else unless ary.length.zero? ary = ary.reverse (ary.length).times do |i| sum += ary[i] * (10 ** i) end ary = [] end end end end puts sum
[["-", 8, 170, 0, 662, 12, 652, 486, 652, 735, 22], ["-", 0, 89, 8, 170, 0, 662, 12, 652, 17, 131]]
4
87
2
suicide = 0 while True: try: sentence = input() start = None last = None for index, char in enumerate(sentence): if char.isdigit(): start = index elif not start == None and not char.isdigit(): last = index suicide += int(sentence[start:last]) start = None last = None else: if not start == None: suicide += int(sentence[start:]) except EOFError: print(suicide) break
suicide = 0 while True: try: sentence = input() start = None last = None for index, char in enumerate(sentence): if char.isdigit(): if start == None: start = index elif not start == None and not char.isdigit(): last = index suicide += int(sentence[start:last]) start = None last = None else: if not start == None: suicide += int(sentence[start:]) except EOFError: print(suicide) break
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 685], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 102], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
98
5
ans=0 while True: try: n=input() tmp='' for i in n: if i.isdigit(): tmp+=i elif len(tmp): ans+=int(tmp) tmp='' except: if len(tmp): ans+=int(tmp) tmp='' break print(ans)
ans=0 while True: try: n=input() tmp='' for i in n: if i.isdigit(): tmp+=i elif len(tmp): ans+=int(tmp) tmp='' if len(tmp): ans+=int(tmp) tmp='' except: break print(ans)
[["-", 0, 52, 8, 196, 0, 246, 0, 671, 0, 672], ["-", 0, 52, 8, 196, 0, 246, 0, 671, 0, 102], ["+", 0, 52, 8, 196, 0, 246, 0, 671, 0, 672], ["+", 0, 52, 8, 196, 0, 246, 0, 671, 0, 102]]
5
71
4
ans = "" while True: try: memo = input() except: break for m in memo: ans = ans+m if m.isdigit() else ans+"@" print(sum(ans.replace("@", " ").split()))
ans = "" while True: try: memo = input() except: break for m in memo: ans = ans+m if m.isdigit() else ans+"@" print(sum(map(int, ans.replace("@", " ").split())))
[["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
61
5
import re try: ls = num = [] result = 0 while True: ls.append(input()) except: for i in ls: for s in range(re.findall(r'\d+', i)): result += int(s) print(result)
import re try: ls = [] result = 0 while True: ls.append(input()) except: for i in ls: for s in re.findall(r'\d+', i): result += int(s) print(result)
[["-", 8, 196, 0, 1, 0, 662, 12, 662, 31, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 7, 12, 652, 63, 22], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 24], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
58
11
import re l=0 try: while True: x=input() for i in re.findall(r'\d+',x): lst+=int(i) except: print(l)
import re l=0 try: while True: x=input() for i in re.findall(r'\d+',x): l+=int(i) except: print(l)
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22]]
5
41
2
s="".join([s for s in sys.stdin]) p=re.compile('\d+') x=p.findall(s) print(sum(map(int,x)))
import sys,re s="".join([s for s in sys.stdin]) p=re.compile('\d+') x=p.findall(s) print(sum(map(int,x)))
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 21]]
5
47
4
import java.util.Scanner; public class Main { private Scanner sc; public static void main(String[] args) { new Main(); } public Main() { sc = new Scanner(System.in); int[][] table = new int[2][1000]; for (int i = 0; i < table.length; i++) { for (int j = 0; j < table[0].length; j++) { table[i][j] = 0; } } int index = 0; while (sc.hasNextLine() == true) { String line = sc.nextLine(); if (line.equals("")) { index++; continue; } String[] nico = line.split(","); table[index][Integer.parseInt(nico[0]) - 1]++; } for (int i = 0; i < table[0].length; i++) { int num = 0; boolean flag = true; for (int j = 0; j < table.length; j++) { if (table[j][i] > 0) num = num + table[j][i]; else flag = false; } if (flag == true) { System.out.println((i + 1) + "," + num); } } } }
import java.util.Scanner; public class Main { private Scanner sc; public static void main(String[] args) { new Main(); } public Main() { sc = new Scanner(System.in); int[][] table = new int[2][1000]; for (int i = 0; i < table.length; i++) { for (int j = 0; j < table[0].length; j++) { table[i][j] = 0; } } int index = 0; while (sc.hasNextLine() == true) { String line = sc.nextLine(); if (line.equals("")) { index++; continue; } String[] nico = line.split(","); table[index][Integer.parseInt(nico[0]) - 1]++; } for (int i = 0; i < table[0].length; i++) { int num = 0; boolean flag = true; for (int j = 0; j < table.length; j++) { if (table[j][i] > 0) num = num + table[j][i]; else flag = false; } if (flag == true) { System.out.println((i + 1) + " " + num); } } } }
[["-", 3, 4, 0, 16, 31, 16, 12, 5, 0, 491], ["+", 3, 4, 0, 16, 31, 16, 12, 5, 0, 491]]
3
295
2
#include <stdio.h> #include <string.h> int p[10010], n[10010]; int main() { char line[100]; int a, b; int flag = 1; int i; while (gets(line) != NULL) { if (line[0] == '\n') flag = 0; else { sscanf(line, "%d,%d", &a, &b); if (flag) p[a]++; else n[a]++; } } for (i = 0; i < 10010; i++) { if (p[i] > 0 && n[i] > 0) { printf("%d %d\n", i, p[i] + n[i]); } } return 0; }
#include <stdio.h> #include <string.h> int p[10010], n[10010]; int main() { char line[100]; int a, b; int flag = 1; int i; while (fgets(line, 99, stdin) != NULL) { if (line[0] == '\n') flag = 0; else { sscanf(line, "%d,%d", &a, &b); if (flag) p[a]++; else n[a]++; } } for (i = 0; i < 10010; i++) { if (p[i] > 0 && n[i] > 0) { printf("%d %d\n", i, p[i] + n[i]); } } return 0; }
[["-", 0, 52, 15, 23, 0, 16, 31, 2, 63, 22], ["+", 0, 52, 15, 23, 0, 16, 31, 2, 63, 22], ["+", 15, 23, 0, 16, 31, 2, 3, 4, 0, 21], ["+", 15, 23, 0, 16, 31, 2, 3, 4, 0, 13], ["+", 15, 23, 0, 16, 31, 2, 3, 4, 0, 22]]
0
157
6
#include <stdio.h> #include <string.h> int size = 0; struct Cust { int num, total, flg; } c[1000], tmp; int find(struct Cust x) { int i; for (i = 0; i < size; i++) { if (c[i].num == x.num) return i; } return -1; } void insert(struct Cust x) { int i; x.total = 1; x.flg = 0; for (i = size++; i > 0 && c[i - 1].num > c[i].num; i--) { c[i] = c[i - 1]; } c[i] = x; } int main(void) { int i, x, pos; char buff[64]; memset(c, 0, sizeof(c)); while (1) { fgets(buff, 64, stdin); if (buff[0] < '0' || '9' < buff[0]) break; sscanf(buff, "%d,%d", &tmp.num, &x); if ((pos = find(tmp)) == -1) { insert(tmp); } else { c[pos].total++; } } while (1) { if (fgets(buff, 64, stdin) == NULL) break; sscanf(buff, "%d %d", &tmp.num, &x); if ((pos = find(tmp)) != -1) { c[pos].flg = 1; c[pos].total++; } } for (i = 0; i < size; i++) { if (c[i].flg) printf("%d %d\n", c[i].num, c[i].total); } return 0; }
#include <stdio.h> #include <string.h> int size = 0; struct Cust { int num, total, flg; } c[1000], tmp; int find(struct Cust x) { int i; for (i = 0; i < size; i++) { if (c[i].num == x.num) return i; } return -1; } void insert(struct Cust x) { int i; x.total = 1; x.flg = 0; for (i = size++; i > 0 && c[i - 1].num > x.num; i--) { c[i] = c[i - 1]; } c[i] = x; } int main(void) { int i, x, pos; char buff[64]; memset(c, 0, sizeof(c)); while (1) { fgets(buff, 64, stdin); if (buff[0] < '0' || '9' < buff[0]) break; sscanf(buff, "%d,%d", &tmp.num, &x); if ((pos = find(tmp)) == -1) { insert(tmp); } else { c[pos].total++; } } while (1) { if (fgets(buff, 64, stdin) == NULL) break; sscanf(buff, "%d %d", &tmp.num, &x); if ((pos = find(tmp)) != -1) { c[pos].flg = 1; c[pos].total++; } } for (i = 0; i < size; i++) { if (c[i].flg) printf("%d %d\n", c[i].num, c[i].total); } return 0; }
[["-", 15, 16, 12, 16, 12, 118, 28, 69, 28, 22], ["-", 15, 16, 12, 16, 12, 118, 28, 69, 0, 70], ["-", 15, 16, 12, 16, 12, 118, 28, 69, 71, 22], ["-", 15, 16, 12, 16, 12, 118, 28, 69, 0, 73], ["+", 0, 7, 15, 16, 12, 16, 12, 118, 28, 22]]
0
384
5
#include <stdio.h> #define isNum(a) (a <= '9' && a >= '0') #define N_MAX 500 // 適当 char ch; int c[N_MAX], f[N_MAX]; int parseInt() { int res = ch - '0'; while (ch = getchar(), isNum(ch)) res = res * 10 + ch - '0'; return res; } int main(void) { int n; for (n = 0; n < N_MAX; n++) c[n] = f[n] = 0; while (ch = getchar(), isNum(ch)) { n = parseInt(); c[n]++, f[n] = -1; while (ch != '\n') ch = getchar(); } while (ch = getchar(), isNum(ch)) { n = parseInt(); c[n]++, f[n] = f[n] ? 1 : 0; while (ch != '\n') ch = getchar(); } for (n = 0; n < N_MAX; n++) if (f[n] == 1) printf("%d %d\n", n, c[n]); return 0; }
#include <stdio.h> #define isNum(a) (a <= '9' && a >= '0') #define N_MAX 10000 // 適当 char ch; int c[N_MAX], f[N_MAX]; int parseInt() { int res = ch - '0'; while (ch = getchar(), isNum(ch)) res = res * 10 + ch - '0'; return res; } int main(void) { int n; for (n = 0; n < N_MAX; n++) c[n] = f[n] = 0; while (ch = getchar(), isNum(ch)) { n = parseInt(); c[n]++, f[n] = -1; while (ch != '\n') ch = getchar(); } while (ch = getchar(), isNum(ch)) { n = parseInt(); c[n]++, f[n] = f[n] ? 1 : 0; while (ch != '\n') ch = getchar(); } for (n = 0; n < N_MAX; n++) if (f[n] == 1) printf("%d %d\n", n, c[n]); return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
0
246
2
#include <bits/stdc++.h> using namespace std; int main(void) { string s; int a[3][1010]; while (getline(cin, s), s != "") { int c, d; stringstream ss(s); ss >> c >> d; a[0][c]++; } while (getline(cin, s), s != "") { int c, d; stringstream ss(s); ss >> c >> d; a[1][c]++; } for (int i = 1; i < 1001; i++) { if (a[0][i] > 0 && a[1][i] > 0) { cout << i << " " << a[0][i] + a[1][i]; } } }
#include <bits/stdc++.h> using namespace std; int main(void) { string s; int a[3][1010]; while (getline(cin, s), s != "") { int c, d; stringstream ss(s); ss >> c >> d; a[0][c]++; } while (getline(cin, s), s != "") { int c, d; stringstream ss(s); ss >> c >> d; a[1][c]++; } for (int i = 1; i < 1001; i++) { if (a[0][i] > 0 && a[1][i] > 0) { cout << i << " " << a[0][i] + a[1][i] << "\n"; } } }
[["+", 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, 44]]
1
173
4
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; const int INF = 1 << 30; const int MOD = 1e9 + 7; const int dy[] = {1, 0, -1, 0}; const int dx[] = {0, 1, 0, -1}; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; vector<int> result1(1010, 0), result2(1010, 0); while (getline(cin, s), s != "") { int idx = -1; for (int i = 0; i < s.size(); i++) if (s[i] == ',') idx = i; if (idx == -1) break; int c = stoi(s.substr(0, idx)); result1[c]++; } while (cin >> s) { int idx = -1; for (int i = 0; i < s.size(); i++) if (s[i] == ',') idx = i; int c = stoi(s.substr(0, idx)); result2[c]++; } for (int i = 0; i < result1.size(); i++) { if (result1[i] + result2[i] >= 2) cout << i << " " << result1[i] + result2[i] << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; const int INF = 1 << 30; const int MOD = 1e9 + 7; const int dy[] = {1, 0, -1, 0}; const int dx[] = {0, 1, 0, -1}; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; vector<int> result1(1010, 0), result2(1010, 0); while (getline(cin, s), s != "") { int idx = -1; for (int i = 0; i < s.size(); i++) if (s[i] == ',') idx = i; if (idx == -1) break; int c = stoi(s.substr(0, idx)); result1[c]++; } while (cin >> s) { int idx = -1; for (int i = 0; i < s.size(); i++) if (s[i] == ',') idx = i; int c = stoi(s.substr(0, idx)); result2[c]++; } for (int i = 0; i < result1.size(); i++) { if (result1[i] && result2[i]) cout << i << " " << result1[i] + result2[i] << endl; } return 0; }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
329
4
#include <iostream> #include <string> using namespace std; string S; int x[100000][2]; int c = 0; int main() { while (getline(cin, S)) { if (S.size() == 0) { c++; } string T[2]; int ok = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == ',') { ok++; } else { T[ok] += S[i]; } } x[stoi(T[0])][c]++; } for (int i = 0; i < 99999; i++) { if (x[i][0] >= 1 && x[i][1] >= 1) { cout << i << ' ' << x[i][0] + x[i][1] << endl; } } return 0; }
#include <iostream> #include <string> using namespace std; string S; int x[100000][2]; int c = 0; int main() { while (getline(cin, S)) { if (S.size() == 0) { c++; continue; } string T[2]; int ok = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == ',') { ok++; } else { T[ok] += S[i]; } } x[stoi(T[0])][c]++; } for (int i = 0; i < 99999; i++) { if (x[i][0] >= 1 && x[i][1] >= 1) { cout << i << ' ' << x[i][0] + x[i][1] << endl; } } return 0; }
[["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35]]
1
201
2
#include <cstdlib> #include <iostream> #include <map> #include <string> using namespace std; int main() { string in; map<int, int> c, d; map<int, int>::iterator p; //¡ŒŽ‚̓ǂݍž‚Ý while (getline(cin, in)) { if (in.size() == 1) break; int n = atoi(in.c_str()); p = c.find(n); if (c.end() == p) c.insert(pair<int, int>(n, 1)); else ++(p->second); } //æŒŽ‚̓ǂݍž‚Ý‚ð‚µ‚Äd‚ɍ¡ŒŽ‚Ì•ª‚Æ‚ ‚킹‚Ä“ü—Í //‚½‚¾‚µA¡ŒŽ‚ÌŽæˆø‚ª‚È‚¢‚à‚͔̂ò‚΂µ‚Ă܂·B while (getline(cin, in)) { int n = atoi(in.c_str()); p = c.find(n); if (c.end() == p) continue; else { if (d.find(n) == d.end()) d.insert(pair<int, int>(n, p->second + 1)); else d.find(n)->second++; } } //æŒŽ‚̃f[ƒ^‚ðo—Í for (p = d.begin(); p != d.end(); ++p) { cout << (p->first) << " " << (p->second) << endl; } return 0; }
#include <cstdlib> #include <iostream> #include <map> #include <string> using namespace std; int main() { string in; map<int, int> c, d; map<int, int>::iterator p; //¡ŒŽ‚̓ǂݍž‚Ý while (getline(cin, in)) { if (in.size() == 0) break; int n = atoi(in.c_str()); p = c.find(n); if (c.end() == p) c.insert(pair<int, int>(n, 1)); else ++(p->second); } //æŒŽ‚̓ǂݍž‚Ý‚ð‚µ‚Äd‚ɍ¡ŒŽ‚Ì•ª‚Æ‚ ‚킹‚Ä“ü—Í //‚½‚¾‚µA¡ŒŽ‚ÌŽæˆø‚ª‚È‚¢‚à‚͔̂ò‚΂µ‚Ă܂·B while (getline(cin, in)) { int n = atoi(in.c_str()); p = c.find(n); if (c.end() == p) continue; else { if (d.find(n) == d.end()) d.insert(pair<int, int>(n, p->second + 1)); else d.find(n)->second++; } } //æŒŽ‚̃f[ƒ^‚ðo—Í for (p = d.begin(); p != d.end(); ++p) { cout << (p->first) << " " << (p->second) << endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
264
2
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using namespace std; typedef long long Int; typedef vector<int> vint; typedef pair<int, int> pint; #define mp make_pair template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() { int x; scanf("%d", &x); return x; } vector<pint> kokyaku; vector<int> pr, nw; int main() { int n; string str; bool pre = true; while (getline(cin, str)) { if (str.size() == 1) { pre = false; continue; } n = 0; int i; for (i = 0; str[i] != ','; i++) { n = n * 10 + str[i] - '0'; } for (i = 0; i < kokyaku.size(); i++) { if (kokyaku[i].first == n) { kokyaku[i].second++; break; } } if (i == kokyaku.size()) { kokyaku.push_back(pint(n, 1)); } if (pre) { for (i = 0; i < pr.size(); i++) { if (pr[i] == n) { break; } } if (i == pr.size()) { pr.push_back(n); } } else { for (i = 0; i < nw.size(); i++) { if (nw[i] == n) { break; } } if (i == nw.size()) { nw.push_back(n); } } } sort(kokyaku.begin(), kokyaku.end()); sort(nw.begin(), nw.end()); sort(pr.begin(), pr.end()); int i; for (i = 0; i < kokyaku.size(); i++) { if (find(pr.begin(), pr.end(), kokyaku[i].first) != pr.end() && find(nw.begin(), nw.end(), kokyaku[i].first) != nw.end()) cout << kokyaku[i].first << " " << kokyaku[i].second << endl; } return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using namespace std; typedef long long Int; typedef vector<int> vint; typedef pair<int, int> pint; #define mp make_pair template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() { int x; scanf("%d", &x); return x; } vector<pint> kokyaku; vector<int> pr, nw; int main() { int n; string str; bool pre = true; while (getline(cin, str)) { if (str.size() == 0) { pre = false; continue; } n = 0; int i; for (i = 0; str[i] != ','; i++) { n = n * 10 + str[i] - '0'; } for (i = 0; i < kokyaku.size(); i++) { if (kokyaku[i].first == n) { kokyaku[i].second++; break; } } if (i == kokyaku.size()) { kokyaku.push_back(pint(n, 1)); } if (pre) { for (i = 0; i < pr.size(); i++) { if (pr[i] == n) { break; } } if (i == pr.size()) { pr.push_back(n); } } else { for (i = 0; i < nw.size(); i++) { if (nw[i] == n) { break; } } if (i == nw.size()) { nw.push_back(n); } } } sort(kokyaku.begin(), kokyaku.end()); sort(nw.begin(), nw.end()); sort(pr.begin(), pr.end()); int i; for (i = 0; i < kokyaku.size(); i++) { if (find(pr.begin(), pr.end(), kokyaku[i].first) != pr.end() && find(nw.begin(), nw.end(), kokyaku[i].first) != nw.end()) cout << kokyaku[i].first << " " << kokyaku[i].second << endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
610
2
#define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; int main() { int num, date; map<int, set<int>> m1; map<int, set<int>> m2; string str; bool next = false; while (getline(cin, str)) { if (str.empty()) { next = true; continue; } sscanf(str.c_str(), "%d,%d", &num, &date); if (!next) m1[num].insert(date + 100); else { if (m1[num].size() > 0 && m2[num].size() == 0) m2[num] = m1[num]; m2[num].insert(date); } } for (map<int, set<int>>::iterator it = m2.begin(); it != m2.end(); it++) { printf("%d %d\n", it->first, it->second.size()); } }
#define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; int main() { int num, date; map<int, set<int>> m1; map<int, set<int>> m2; string str; bool next = false; while (getline(cin, str)) { if (str.empty()) { next = true; continue; } sscanf(str.c_str(), "%d,%d", &num, &date); if (!next) m1[num].insert(date + 100); else { if (m1[num].size() > 0) { if (m2[num].size() == 0) m2[num] = m1[num]; m2[num].insert(date); } } } for (map<int, set<int>>::iterator it = m2.begin(); it != m2.end(); it++) { printf("%d %d\n", it->first, it->second.size()); } }
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 0, 25], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46]]
1
252
6
a,b=gets(p).split("\n\n"); c=[0]*2000;d=[0]*2000; ans=[]; a.split.map{|s|b=s.to_i;c[b]+=1} b.split.map{|s|b=s.to_i;ans<<b if c[b]>0;d[b]+=1} ans=ans.sort.uniq; ans.map{|a|puts "#{a} #{c[a]+d[a]}"}
a,b=gets(p).split("\n\n"); c=[0]*2000;d=[0]*2000; ans=[]; a.split.map{|s|l=s.to_i;c[l]+=1} b.split.map{|s|b=s.to_i;ans<<b if c[b]>0;d[b]+=1} ans=ans.sort.uniq; ans.map{|a|puts "#{a} #{c[a]+d[a]}"}
[["-", 0, 652, 196, 196, 8, 734, 0, 662, 31, 22], ["+", 0, 652, 196, 196, 8, 734, 0, 662, 31, 22], ["-", 196, 196, 8, 734, 0, 755, 31, 742, 0, 22], ["+", 196, 196, 8, 734, 0, 755, 31, 742, 0, 22]]
4
110
4
pm = {} while (s = gets) != "\n" (n, c) = s.chomp.split(/,/).map(&:to_i) pm[n] = [] if !pm.key?(n) pm[n].push(c) end tm = {} while (s = gets) != "\n" (n, c) = s.chomp.split(/,/).map(&:to_i) tm[n] = [] if !tm.key?(n) tm[n].push(c) end pm.keys.sort.each do |k| if tm.key?(k) puts "#{k} #{pm[k].size + tm[k].size}" end end
pm = {} while (s = gets) != "\n" (n, c) = s.chomp.split(/,/).map(&:to_i) pm[n] = [] if !pm.key?(n) pm[n].push(c) end tm = {} while s = gets (n, c) = s.chomp.split(/,/).map(&:to_i) tm[n] = [] if !tm.key?(n) tm[n].push(c) end pm.keys.sort.each do |k| if tm.key?(k) puts "#{k} #{pm[k].size + tm[k].size}" end end
[["-", 0, 493, 0, 89, 15, 738, 31, 739, 0, 24], ["-", 0, 493, 0, 89, 15, 738, 31, 739, 0, 25], ["-", 36, 36, 0, 493, 0, 89, 15, 738, 17, 79], ["-", 0, 493, 0, 89, 15, 738, 12, 557, 0, 62], ["-", 0, 493, 0, 89, 15, 738, 12, 557, 0, 44]]
4
164
6
import sys b=0 a=[{},{}] for e in sys.stdin: if'\n'==e:b=1 else:c_=e.split(',');c=int(c);a[b].setdefault(c,0);a[b][c]+=1 for k in sorted({*a[0]}&{*a[1]}):print(k,a[0][k]+a[1][k])
import sys b=0 a=[{},{}] for e in sys.stdin: if'\n'==e:b=1 else:c,_=e.split(',');c=int(c);a[b].setdefault(c,0);a[b][c]+=1 for k in sorted({*a[0]}&{*a[1]}):print(k,a[0][k]+a[1][k])
[["-", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 684, 0, 21]]
5
114
4
data1, data2 = [],[] while True: try: n,day = list(map(int, input().split(","))) data1.append(n) except: break while True: try: n,day = list(map(int, input().split(","))) data2.append(n) except: break data = sorted(list(set(data1))) for i in data: if data2.count(i) > 0: print(i, data1.count(data)+data2.count(data))
data1, data2 = [],[] while True: try: n,day = list(map(int, input().split(","))) data1.append(n) except: break while True: try: n,day = list(map(int, input().split(","))) data2.append(n) except: break data = sorted(list(set(data1))) for i in data: if data2.count(i) > 0: print(i, data1.count(i)+data2.count(i))
[["-", 3, 4, 0, 657, 31, 652, 3, 4, 0, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 22], ["-", 3, 4, 0, 657, 12, 652, 3, 4, 0, 22], ["+", 3, 4, 0, 657, 12, 652, 3, 4, 0, 22]]
5
126
4
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { if (line.isEmpty()) { break; } String maru = getNum('o', line); String batu = getNum('x', line); if (check(maru)) { System.out.println("o"); } else if (check(batu)) { System.out.println("x"); } else { System.out.println("d"); } } } private static boolean check(String a) { if (a.contains("123") || a.contains("456") || a.contains("789")) { return true; } if (a.contains("1") && a.contains("5") && a.contains("9") || (a.contains("3") && a.contains("5") && a.contains("7"))) { return true; } char[] chs = new char[a.length()]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { chs[i] = a.charAt(j * 3 + i); } } String b = String.valueOf(chs); if (b.contains("147") || b.contains("258") || b.contains("369")) { return true; } return false; } private static String getNum(char a, String line) { char[] chs = line.toCharArray(); for (int i = 0; i < chs.length; i++) { if (chs[i] == a) { chs[i] = (char)(i + 1 + '0'); } } return String.valueOf(chs); } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { if (line.isEmpty()) { break; } String maru = getNum('o', line); String batu = getNum('x', line); if (check(maru)) { System.out.println("o"); } else if (check(batu)) { System.out.println("x"); } else { System.out.println("d"); } } } private static boolean check(String a) { if (a.contains("123") || a.contains("456") || a.contains("789")) { return true; } if ((a.contains("1") && a.contains("5") && a.contains("9")) || (a.contains("3") && a.contains("5") && a.contains("7"))) { return true; } char[] chs = new char[a.length()]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { chs[i * 3 + j] = a.charAt(j * 3 + i); } } String b = String.valueOf(chs); if (b.contains("147") || b.contains("258") || b.contains("369")) { return true; } return false; } private static String getNum(char a, String line) { char[] chs = line.toCharArray(); for (int i = 0; i < chs.length; i++) { if (chs[i] == a) { chs[i] = (char)(i + 1 + '0'); } } return String.valueOf(chs); } }
[["+", 0, 57, 15, 15, 0, 16, 31, 23, 0, 24], ["+", 0, 57, 15, 15, 0, 16, 31, 23, 0, 25], ["+", 0, 11, 31, 504, 71, 16, 31, 16, 17, 48], ["+", 0, 11, 31, 504, 71, 16, 31, 16, 12, 499], ["+", 0, 1, 0, 11, 31, 504, 71, 16, 17, 72], ["+", 0, 1, 0, 11, 31, 504, 71, 16, 12, 22]]
3
465
6
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); for (; scanner.hasNext();) { String input = scanner.next(); String[][] map = new String[3][3]; for (int i = 0; i < input.length(); i++) { map[i / 3][i % 3] = input.substring(i, i + 1); } String output = "d"; for (int i = 0; i < 3; i++) { int count = 1; for (int j = 0; j < 3; j++) { if (map[i][j].equals("s")) { break; } if (j > 0) { if (map[i][j].equals(map[i][j - 1])) { count++; } else { break; } } } if (count == 3) { output = map[i][0]; break; } } for (int i = 0; i < 3; i++) { int count = 1; for (int j = 0; j < 3; j++) { if (map[j][i].equals("s")) { break; } if (j > 0) { if (map[j][i].equals(map[j - 1][i])) { count++; } else { break; } } } if (count == 3) { output = map[i][0]; break; } } int count = 1; for (int i = 0; i < 3; i++) { if (map[i][i].equals("s")) { break; } if (i > 0) { if (map[i][i].equals(map[i - 1][i - 1])) { count++; } else { break; } } } if (count == 3) { output = map[0][0]; } count = 1; for (int i = 0; i < 3; i++) { int j = 2 - i; if (map[i][j].equals("s")) { break; } if (i > 0) { if (map[i][j].equals(map[i - 1][j + 1])) { count++; } else { break; } } } if (count == 3) { output = map[0][2]; } System.out.println(output); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); for (; scanner.hasNext();) { String input = scanner.next(); String[][] map = new String[3][3]; for (int i = 0; i < input.length(); i++) { map[i / 3][i % 3] = input.substring(i, i + 1); } String output = "d"; for (int i = 0; i < 3; i++) { int count = 1; for (int j = 0; j < 3; j++) { if (map[i][j].equals("s")) { break; } if (j > 0) { if (map[i][j].equals(map[i][j - 1])) { count++; } else { break; } } } if (count == 3) { output = map[i][0]; break; } } for (int i = 0; i < 3; i++) { int count = 1; for (int j = 0; j < 3; j++) { if (map[j][i].equals("s")) { break; } if (j > 0) { if (map[j][i].equals(map[j - 1][i])) { count++; } else { break; } } } if (count == 3) { output = map[0][i]; break; } } int count = 1; for (int i = 0; i < 3; i++) { if (map[i][i].equals("s")) { break; } if (i > 0) { if (map[i][i].equals(map[i - 1][i - 1])) { count++; } else { break; } } } if (count == 3) { output = map[0][0]; } count = 1; for (int i = 0; i < 3; i++) { int j = 2 - i; if (map[i][j].equals("s")) { break; } if (i > 0) { if (map[i][j].equals(map[i - 1][j + 1])) { count++; } else { break; } } } if (count == 3) { output = map[0][2]; } System.out.println(output); } } }
[["-", 0, 1, 0, 11, 12, 504, 516, 504, 71, 22], ["+", 0, 1, 0, 11, 12, 504, 516, 504, 71, 499], ["-", 64, 196, 0, 1, 0, 11, 12, 504, 71, 499], ["+", 64, 196, 0, 1, 0, 11, 12, 504, 71, 22]]
3
581
4
import java.io.*; import java.util.*; class Main { public static void main(String[] args) { final Scanner stdin = new Scanner(System.in); while (stdin.hasNextLine()) { final String input = stdin.nextLine(); final boolean winO = win('o', input); final boolean winX = win('x', input); if (winO) { System.out.println('o'); } else if (winX) { System.out.println('x'); } else { System.out.println('d'); } } } static boolean win(char ch, String input) { for (int i = 0; i < 3; i++) { int count = 0; for (int j = 0; j < 3; j++) { if (input.charAt(3 * i + j) == ch) { count++; } } if (count == 3) { return true; } count = 0; for (int j = 0; j < 3; j++) { if (input.charAt(3 * j + i) == ch) { count++; } } if (count == 3) { return true; } } if (input.charAt(3 * 0 + 0) == ch && input.charAt(3 * 1 + 1) == ch && input.charAt(3 * 2 + 2) == ch) { return true; } if (input.charAt(3 * 2 + 0) == ch && input.charAt(3 * 1 + 1) == ch && input.charAt(3 * 2 + 0) == ch) { return true; } return false; } }
import java.io.*; import java.util.*; class Main { public static void main(String[] args) { final Scanner stdin = new Scanner(System.in); while (stdin.hasNextLine()) { final String input = stdin.nextLine(); final boolean winO = win('o', input); final boolean winX = win('x', input); if (winO) { System.out.println('o'); } else if (winX) { System.out.println('x'); } else { System.out.println('d'); } } } static boolean win(char ch, String input) { for (int i = 0; i < 3; i++) { int count = 0; for (int j = 0; j < 3; j++) { if (input.charAt(3 * i + j) == ch) { count++; } } if (count == 3) { return true; } count = 0; for (int j = 0; j < 3; j++) { if (input.charAt(3 * j + i) == ch) { count++; } } if (count == 3) { return true; } } if (input.charAt(3 * 0 + 0) == ch && input.charAt(3 * 1 + 1) == ch && input.charAt(3 * 2 + 2) == ch) { return true; } if (input.charAt(3 * 2 + 0) == ch && input.charAt(3 * 1 + 1) == ch && input.charAt(3 * 0 + 2) == ch) { return true; } return false; } }
[["-", 31, 492, 3, 4, 0, 16, 31, 16, 12, 499], ["-", 12, 16, 31, 492, 3, 4, 0, 16, 17, 72], ["+", 12, 16, 31, 492, 3, 4, 0, 16, 17, 72], ["+", 12, 16, 31, 492, 3, 4, 0, 16, 12, 499]]
3
353
4
char *p = "012345678036147258048246", f, s[]; main(i) { for (; read(0, s, 10); i || puts("d")) for (i = 24; i > 1; f - 's' && f == s[p[i + 1] - 48] & f == s[p[i + 2] - 48] && puts(&f, i = 1)) f = s[p[i -= 3] - 48]; }
char *p = "012345678036147258048246", f, s[11]; main(i) { for (; read(0, s, 10); i || puts("d")) for (i = 24; i > 1; f - 's' && f == s[p[i + 1] - 48] & f == s[p[i + 2] - 48] && puts(&f, i = 1)) f = s[p[i -= 3] - 48]; }
[["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
0
109
1
// AOJ Volume 0 Problem 0066 #include <stdio.h> #include <stdlib.h> int main(void) { char in_str[81]; int field[9]; int i, j; int check; while (scanf("%s", in_str) != EOF) { for (i = 0; i < 9; i++) { if (in_str[i] == 'o') { field[i] = 1; } else if (in_str[i] == 'x') { field[i] = -1; } else { field[i] = 0; } } for (i = 0; i < 3; i++) { check = 0; for (j = 0; j < 3; j++) { check += field[i * 3 + j]; } if (abs(check) == 3) { goto end; } for (j = 0; j < 3; j++) { check += field[i + j * 3]; } if (abs(check) == 3) { goto end; } } check = field[0] + field[4] + field[8]; if (abs(check) == 3) { goto end; } check = field[2] + field[4] + field[6]; end: if (check == 3) { printf("o\n"); } else if (check == -3) { printf("x\n"); } else { printf("d\n"); } } return (0); }
// AOJ Volume 0 Problem 0066 #include <stdio.h> #include <stdlib.h> int main(void) { char in_str[81]; int field[9]; int i, j; int check; while (scanf("%s", in_str) != EOF) { for (i = 0; i < 9; i++) { if (in_str[i] == 'o') { field[i] = 1; } else if (in_str[i] == 'x') { field[i] = -1; } else { field[i] = 0; } } for (i = 0; i < 3; i++) { check = 0; for (j = 0; j < 3; j++) { check += field[i * 3 + j]; } if (abs(check) == 3) { goto end; } check = 0; for (j = 0; j < 3; j++) { check += field[i + j * 3]; } if (abs(check) == 3) { goto end; } } check = field[0] + field[4] + field[8]; if (abs(check) == 3) { goto end; } check = field[2] + field[4] + field[6]; end: if (check == 3) { printf("o\n"); } else if (check == -3) { printf("x\n"); } else { printf("d\n"); } } return (0); }
[["+", 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]]
0
311
4
#include <stdio.h> int main(void) { int i; int end; char board[3][3]; while (scanf("%c%c%c%c%c%c%c%c%c", &board[0][0], &board[0][1], &board[0][2], &board[1][0], &board[1][1], &board[1][2], &board[2][0], &board[2][1], &board[2][2]) != EOF) { end = 0; for (i = 0; i < 3; i++) { if (board[i][0] != 's' && board[i][0] == board[i][1] && board[i][1] == board[i][2]) { printf("%c\n", board[i][0]); end = 1; break; } } if (end) { getchar(); continue; } for (i = 0; i < 3; i++) { if (board[0][i] != 's' && board[0][i] == board[0][i] && board[1][i] == board[2][i]) { printf("%c\n", board[0][i]); end = 1; break; } } if (end) { getchar(); continue; } if (board[0][0] != 's' && board[0][0] == board[1][1] && board[1][1] == board[2][2]) { printf("%c\n", board[0][0]); getchar(); continue; } if (board[0][2] != 's' && board[0][2] == board[1][1] && board[1][1] == board[2][0]) { printf("%c\n", board[0][2]); getchar(); continue; } puts("d"); getchar(); } return 0; }
#include <stdio.h> int main(void) { int i; int end; char board[3][3]; while (scanf("%c%c%c%c%c%c%c%c%c", &board[0][0], &board[0][1], &board[0][2], &board[1][0], &board[1][1], &board[1][2], &board[2][0], &board[2][1], &board[2][2]) != EOF) { end = 0; for (i = 0; i < 3; i++) { if (board[i][0] != 's' && board[i][0] == board[i][1] && board[i][1] == board[i][2]) { printf("%c\n", board[i][0]); end = 1; break; } } if (end) { getchar(); continue; } for (i = 0; i < 3; i++) { if (board[0][i] != 's' && board[0][i] == board[1][i] && board[1][i] == board[2][i]) { printf("%c\n", board[0][i]); end = 1; break; } } if (end) { getchar(); continue; } if (board[0][0] != 's' && board[0][0] == board[1][1] && board[1][1] == board[2][2]) { printf("%c\n", board[0][0]); getchar(); continue; } if (board[0][2] != 's' && board[0][2] == board[1][1] && board[1][1] == board[2][0]) { printf("%c\n", board[0][2]); getchar(); continue; } puts("d"); getchar(); } return 0; }
[["-", 31, 16, 12, 16, 12, 69, 28, 69, 71, 13], ["+", 31, 16, 12, 16, 12, 69, 28, 69, 71, 13]]
0
470
2
#include <iostream> using namespace std; string s; main() { while (cin >> s) { int f = 0; for (int i = 0; i < 3; i++) { if (s[i * 3] != 's' && s[i * 3] == s[i * 3 + 1] && s[i * 3] == s[i * 3 + 2]) { f = 1; cout << s[i * 3] << endl; } } for (int i = 0; i < 3; i++) { if (s[i] != 's' && s[i] == s[i + 3] && s[i] == s[i + 6]) { f = 1; cout << s[i] << endl; } } if (s[0] != 's' && s[0] == s[4] && s[0] == s[9]) { f = 1; cout << s[0] << endl; } if (s[2] != 's' && s[2] == s[4] && s[2] == s[6]) { f = 1; cout << s[2] << endl; } if (!f) cout << "d" << endl; } }
#include <iostream> using namespace std; string s; main() { while (cin >> s) { int f = 0; for (int i = 0; i < 3; i++) { if (s[i * 3] != 's' && s[i * 3] == s[i * 3 + 1] && s[i * 3] == s[i * 3 + 2]) { f = 1; cout << s[i * 3] << endl; } } for (int i = 0; i < 3; i++) { if (s[i] != 's' && s[i] == s[i + 3] && s[i] == s[i + 6]) { f = 1; cout << s[i] << endl; } } if (s[0] != 's' && s[0] == s[4] && s[0] == s[8]) { f = 1; cout << s[0] << endl; } if (s[2] != 's' && s[2] == s[4] && s[2] == s[6]) { f = 1; cout << s[2] << endl; } if (!f) cout << "d" << endl; } }
[["-", 51, 16, 12, 16, 12, 69, 341, 342, 0, 13], ["+", 51, 16, 12, 16, 12, 69, 341, 342, 0, 13]]
1
276
2
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string s; while (cin >> s) { string ox = "ox"; string res = "d"; for (int i = 0; i < 2; ++i) { bool ok = false; if (s[0] == ox[i] && s[0] == s[1] && s[1] == s[2]) ok = true; if (s[0] == ox[i] && s[3] == s[4] && s[4] == s[5]) ok = true; if (s[0] == ox[i] && s[6] == s[7] && s[7] == s[8]) ok = true; if (s[0] == ox[i] && s[0] == s[3] && s[3] == s[6]) ok = true; if (s[0] == ox[i] && s[1] == s[4] && s[4] == s[7]) ok = true; if (s[0] == ox[i] && s[2] == s[5] && s[5] == s[8]) ok = true; if (s[0] == ox[i] && s[0] == s[4] && s[4] == s[8]) ok = true; if (s[0] == ox[i] && s[2] == s[4] && s[4] == s[6]) ok = true; if (ok) res = ox[i]; } cout << res << endl; } return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string s; while (cin >> s) { string ox = "ox"; string res = "d"; for (int i = 0; i < 2; ++i) { bool ok = false; if (s[0] == ox[i] && s[0] == s[1] && s[1] == s[2]) ok = true; if (s[3] == ox[i] && s[3] == s[4] && s[4] == s[5]) ok = true; if (s[6] == ox[i] && s[6] == s[7] && s[7] == s[8]) ok = true; if (s[0] == ox[i] && s[0] == s[3] && s[3] == s[6]) ok = true; if (s[1] == ox[i] && s[1] == s[4] && s[4] == s[7]) ok = true; if (s[2] == ox[i] && s[2] == s[5] && s[5] == s[8]) ok = true; if (s[0] == ox[i] && s[0] == s[4] && s[4] == s[8]) ok = true; if (s[2] == ox[i] && s[2] == s[4] && s[4] == s[6]) ok = true; if (ok) res = ox[i]; } cout << res << endl; } return 0; }
[["-", 31, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["+", 31, 16, 31, 16, 31, 69, 341, 342, 0, 13]]
1
370
10
#include <bits/stdc++.h> using namespace std; #define FOR(i, s, n) for (int i = s; i < (int)n; i++) #define per(i, n) for (int i = n; i >= 0; i--) #define ROF(i, s, n) for (int i = s; i >= (int)n; i--) #define FORIT(i, A) for (auto i : A) #define PRINT(x) cout << (x) << "\n" #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define MP make_pair #define EACH(i, n) \ for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i) #define SZ(a) int((a).size()) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define CLR(a) memset((a), 0, sizeof(a)) #define NCLR(a) memset((a), -1, sizeof(a)) #define dump(x) cout << #x << " = " << (x) << "\n"; #define debug(x) \ cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << "\n"; #define sq(n) (n) * (n) typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef unsigned int uint; typedef unsigned long long ull; typedef priority_queue<int> maxpq; typedef priority_queue<int, vector<int>, greater<int>> minpq; static const double EPS = 1e-10; static const double PI = acos(-1.0); static const int mod = 1000000007; static const int INF = 1 << 30; static const LL LL_INF = 1152921504606846976; static const int dx[] = {-1, 0, 1, 0, 1, -1, 1, -1}; static const int dy[] = {0, -1, 0, 1, 1, 1, -1, -1}; string s; string win; int main() { while (cin >> s) { VS _array(3); for (int i = 0; i < 3; i++) { _array[i] = s.substr(i * 3, 3); } win = "d"; for (int i = 0; i < 3; i++) { if (i == 0) { if (_array[i][i] != 's' && _array[i][i] == _array[i + 1][i + 1] && _array[i][i] == _array[i + 2][i + 2]) { win = _array[0].substr(0, 1); break; } } if (_array[0][i] != 's' && _array[0][i] == _array[1][i] && _array[0][i] == _array[2][i]) { win = _array[0].substr(i, 1); break; } if (_array[i][0] != 's' && _array[i][0] == _array[i][1] && _array[i][0] == _array[i][2]) { win = _array[i].substr(0, 1); break; } if (i == 2) { if (_array[0][i] != 's' && _array[0][i] == _array[1][i - 1] && _array[i][i] == _array[2][i - 2]) { win = _array[0].substr(i, 1); break; } } } printf("%s\n", win.c_str()); } return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, s, n) for (int i = s; i < (int)n; i++) #define per(i, n) for (int i = n; i >= 0; i--) #define ROF(i, s, n) for (int i = s; i >= (int)n; i--) #define FORIT(i, A) for (auto i : A) #define PRINT(x) cout << (x) << "\n" #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define MP make_pair #define EACH(i, n) \ for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i) #define SZ(a) int((a).size()) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define CLR(a) memset((a), 0, sizeof(a)) #define NCLR(a) memset((a), -1, sizeof(a)) #define dump(x) cout << #x << " = " << (x) << "\n"; #define debug(x) \ cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << "\n"; #define sq(n) (n) * (n) typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef unsigned int uint; typedef unsigned long long ull; typedef priority_queue<int> maxpq; typedef priority_queue<int, vector<int>, greater<int>> minpq; static const double EPS = 1e-10; static const double PI = acos(-1.0); static const int mod = 1000000007; static const int INF = 1 << 30; static const LL LL_INF = 1152921504606846976; static const int dx[] = {-1, 0, 1, 0, 1, -1, 1, -1}; static const int dy[] = {0, -1, 0, 1, 1, 1, -1, -1}; string s; string win; int main() { while (cin >> s) { VS _array(3); for (int i = 0; i < 3; i++) { _array[i] = s.substr(i * 3, 3); } win = "d"; for (int i = 0; i < 3; i++) { if (i == 0) { if (_array[i][i] != 's' && _array[i][i] == _array[i + 1][i + 1] && _array[i][i] == _array[i + 2][i + 2]) { win = _array[0].substr(0, 1); break; } } if (_array[0][i] != 's' && _array[0][i] == _array[1][i] && _array[0][i] == _array[2][i]) { win = _array[0].substr(i, 1); break; } if (_array[i][0] != 's' && _array[i][0] == _array[i][1] && _array[i][0] == _array[i][2]) { win = _array[i].substr(0, 1); break; } if (i == 2) { if (_array[0][i] != 's' && _array[0][i] == _array[1][i - 1] && _array[0][i] == _array[2][i - 2]) { win = _array[0].substr(i, 1); break; } } } printf("%s\n", win.c_str()); } return 0; }
[["-", 12, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 69, 28, 69, 341, 342, 0, 13]]
1
678
2
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int stoi(string x) { stringstream ss; ss << x; int tmp; ss >> tmp; return tmp; } string itos(int x) { stringstream ss; ss << x; return ss.str(); } string ta; bool win(char x) { bool f = 0; for (int i = 0; i < 9; i += 3) { if (ta[i] == x && ta[i + 1] == x && ta[i + 2] == x) f = 1; } for (int i = 0; i < 3; i++) { if (ta[i] == x && ta[i + 3] == x && ta[i + 6] == x) f = 1; } if (ta[2] == x && ta[4] == x && ta[6] == x) f = 1; if (ta[0] == x && ta[4] == x && ta[8] == x) f = 1; return f; } int main() { while (cin >> ta) { if (win('o')) cout << 'o' << endl; if (win('x')) cout << 'x' << endl; else cout << 'd' << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int stoi(string x) { stringstream ss; ss << x; int tmp; ss >> tmp; return tmp; } string itos(int x) { stringstream ss; ss << x; return ss.str(); } string ta; bool win(char x) { bool f = 0; for (int i = 0; i < 9; i += 3) { if (ta[i] == x && ta[i + 1] == x && ta[i + 2] == x) f = 1; } for (int i = 0; i < 3; i++) { if (ta[i] == x && ta[i + 3] == x && ta[i + 6] == x) f = 1; } if (ta[2] == x && ta[4] == x && ta[6] == x) f = 1; if (ta[0] == x && ta[4] == x && ta[8] == x) f = 1; return f; } int main() { while (cin >> ta) { if (win('o')) cout << 'o' << endl; else if (win('x')) cout << 'x' << endl; else cout << 'd' << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95]]
1
303
1
#include <bits/stdc++.h> #define SIZE 300005 #define MOD 1000000007LL #define INF 1 << 30 #define LLINF 1LL << 60 #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i <= b; i++) #define DOWN(i, b, a) for (int i = b; i >= a; i--) #define SET(a, c) memset(a, c, sizeof a) #define FORALL(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define FOREACH(i, c) for (auto(i) : (c)) #define BIT(i, j) ((i) >> (j)) & 1 #define ALL(o) (o).begin(), (o).end() #define ERASE(o) (o).erase(unique((o).begin(), (o).end()), (o).end()) #define SQ(x) ((x) * (x)) using namespace std; typedef long long ll; typedef valarray<int> Array; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; typedef pair<double, double> Pdd; template <typename T> inline void priv(vector<T> a) { REP(i, a.size()) { cout << a[i] << ((i == a.size() - 1) ? "\n" : " "); } } ll gcd(ll a, ll b) { int c = max(a, b); int d = min(a, b); return c == 0 || d == 0 ? c : gcd(c % d, d); } ll lcm(ll a, ll b) { return a == 0 || b == 0 ? 0 : a * b / gcd(a, b); } char solve(string s) { REP(i, 3) { if (s[i * 3] == s[i * 3 + 1] && s[i * 3] == s[i * 3 + 2] && s[i * 3] != 's') return s[i * 3]; if (s[i] == s[i + 3] && s[i + 3] == s[i + 6] && s[i] != 's') return s[i * 3]; } if (s[0] == s[4] && s[4] == s[8] && s[4] != 's') return s[4]; if (s[2] == s[4] && s[4] == s[6] && s[4] != 's') return s[4]; return 'd'; } int main() { string s; while (cin >> s) cout << solve(s) << endl; return 0; }
#include <bits/stdc++.h> #define SIZE 300005 #define MOD 1000000007LL #define INF 1 << 30 #define LLINF 1LL << 60 #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i <= b; i++) #define DOWN(i, b, a) for (int i = b; i >= a; i--) #define SET(a, c) memset(a, c, sizeof a) #define FORALL(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define FOREACH(i, c) for (auto(i) : (c)) #define BIT(i, j) ((i) >> (j)) & 1 #define ALL(o) (o).begin(), (o).end() #define ERASE(o) (o).erase(unique((o).begin(), (o).end()), (o).end()) #define SQ(x) ((x) * (x)) using namespace std; typedef long long ll; typedef valarray<int> Array; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; typedef pair<double, double> Pdd; template <typename T> inline void priv(vector<T> a) { REP(i, a.size()) { cout << a[i] << ((i == a.size() - 1) ? "\n" : " "); } } ll gcd(ll a, ll b) { int c = max(a, b); int d = min(a, b); return c == 0 || d == 0 ? c : gcd(c % d, d); } ll lcm(ll a, ll b) { return a == 0 || b == 0 ? 0 : a * b / gcd(a, b); } char solve(string s) { REP(i, 3) { if (s[i * 3] == s[i * 3 + 1] && s[i * 3] == s[i * 3 + 2] && s[i * 3] != 's') return s[i * 3]; if (s[i] == s[i + 3] && s[i] == s[i + 6] && s[i] != 's') return s[i]; } if (s[0] == s[4] && s[4] == s[8] && s[4] != 's') return s[4]; if (s[2] == s[4] && s[4] == s[6] && s[4] != 's') return s[4]; return 'd'; } int main() { string s; while (cin >> s) cout << solve(s) << endl; return 0; }
[["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 64, 37, 0, 69, 341, 342, 0, 16, 17, 48], ["-", 64, 37, 0, 69, 341, 342, 0, 16, 12, 13]]
1
499
4
#include <bits/stdc++.h> using namespace std; int main() { int dat[3][3]; char in; int sum; while (cin >> in) { if (in == 'o') dat[0][0] = 1; else if (in == 'x') dat[0][0] = -1; else dat[0][0] = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (!i && !j) continue; cin >> in; if (in == 'o') dat[i][j] = 1; else if (in == 'x') dat[i][j] = -1; else dat[i][j] = 0; } } /*judge*/ for (int i = 0; i < 3; i++) { sum = 0; for (int j = 0; j < 3; j++) { sum += dat[i][j]; } if (sum == 3 || sum == -3) goto END; } for (int i = 0; i < 3; i++) { sum = 0; for (int j = 0; j < 3; j++) { sum += dat[j][i]; } if (sum == 3 || sum == -3) goto END; } sum = 0; for (int i = 0; i < 3; i++) sum += dat[i][i]; if (sum == 3 || sum == -3) goto END; sum = 0; for (int i = 0; i < 3; i++) sum += dat[i][3 - i]; END:; if (sum == 3) cout << 'o' << endl; else if (sum == -3) cout << 'x' << endl; else cout << 'd' << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int dat[3][3]; char in; int sum; while (cin >> in) { if (in == 'o') dat[0][0] = 1; else if (in == 'x') dat[0][0] = -1; else dat[0][0] = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (!i && !j) continue; cin >> in; if (in == 'o') dat[i][j] = 1; else if (in == 'x') dat[i][j] = -1; else dat[i][j] = 0; } } /*judge*/ for (int i = 0; i < 3; i++) { sum = 0; for (int j = 0; j < 3; j++) { sum += dat[i][j]; } if (sum == 3 || sum == -3) goto END; } for (int i = 0; i < 3; i++) { sum = 0; for (int j = 0; j < 3; j++) { sum += dat[j][i]; } if (sum == 3 || sum == -3) goto END; } sum = 0; for (int i = 0; i < 3; i++) sum += dat[i][i]; if (sum == 3 || sum == -3) goto END; sum = 0; for (int i = 0; i < 3; i++) sum += dat[i][2 - i]; END:; if (sum == 3) cout << 'o' << endl; else if (sum == -3) cout << 'x' << endl; else cout << 'd' << endl; } return 0; }
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 31, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 31, 13]]
1
411
2
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; ++i) #define REPR(i, n) for (int i = n; i >= 0; --i) #define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr) #define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr) #define FOR(i, a, b) for (int i = a; i < b; ++i) #define SORT(v, n) sort(v, v + n) #define SORTV(v) sort(v.begin(), v.end()) #define ALL(v) v.begin(), v.end() #define llong long long #define INF 999999999 #define SUR 1000000007 #define pb push_back #define pf push_front #define MP make_pair int dx[] = {0, 0, -1, 1}; int dy[] = {1, -1, 0, 0}; using namespace std; typedef pair<int, int> pii; int main() { string s; while (cin >> s) { bool f = false; REP(i, 3) { int n = i * 3; if (s[n] != 's' && s[n] == s[n + 1] && s[n] == s[n + 2]) { cout << s[n] << endl; f = true; break; } if (s[n] != 's' && s[n] == s[n + 3] && s[n] == s[n + 6]) { cout << s[n] << endl; f = true; break; } } if (s[4] != 's' && !f && ((s[0] == s[4] && s[0] == s[8]) || (s[2] == s[4] && s[2] == s[6]))) { cout << s[4] << endl; f = true; } if (!f) { cout << "d" << endl; } } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; ++i) #define REPR(i, n) for (int i = n; i >= 0; --i) #define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr) #define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr) #define FOR(i, a, b) for (int i = a; i < b; ++i) #define SORT(v, n) sort(v, v + n) #define SORTV(v) sort(v.begin(), v.end()) #define ALL(v) v.begin(), v.end() #define llong long long #define INF 999999999 #define SUR 1000000007 #define pb push_back #define pf push_front #define MP make_pair int dx[] = {0, 0, -1, 1}; int dy[] = {1, -1, 0, 0}; using namespace std; typedef pair<int, int> pii; int main() { string s; while (cin >> s) { bool f = false; REP(i, 3) { int n = i * 3; if (s[n] != 's' && s[n] == s[n + 1] && s[n] == s[n + 2]) { cout << s[n] << endl; f = true; break; } if (s[i] != 's' && s[i] == s[i + 3] && s[i] == s[i + 6]) { cout << s[i] << endl; f = true; break; } } if (s[4] != 's' && !f && ((s[0] == s[4] && s[0] == s[8]) || (s[2] == s[4] && s[2] == s[6]))) { cout << s[4] << endl; f = true; } if (!f) { cout << "d" << endl; } } return 0; }
[["-", 31, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["+", 31, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["-", 31, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 31, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["-", 12, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["-", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
1
386
12
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <set> #include <stack> #include <string> #include <vector> using namespace std; bool win(char *t, char c) { for (int y = 0; y < 3; ++y) { bool ok = true; for (int x = 0; x < 3; ++x) { if (t[y * 3 + x] != c) { ok = false; break; } } if (ok) return true; } for (int x = 0; x < 3; ++x) { bool ok = true; for (int y = 0; y < 3; ++y) { if (t[x * 3 + y] != c) { ok = false; break; } } if (ok) return true; } return t[0] == c && t[4] == c && t[8] == c || t[2] == c && t[4] == c && t[6] == c; } int main() { char buf[10]; while (scanf("%s\n", buf) != EOF) { char c; if (win(buf, 'o')) c = 'o'; else if (win(buf, 'x')) c = 'x'; else c = 'd'; printf("%c\n", c); } return 0; }
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <set> #include <stack> #include <string> #include <vector> using namespace std; bool win(char *t, char c) { for (int y = 0; y < 3; ++y) { bool ok = true; for (int x = 0; x < 3; ++x) { if (t[y * 3 + x] != c) { ok = false; break; } } if (ok) return true; } for (int x = 0; x < 3; ++x) { bool ok = true; for (int y = 0; y < 3; ++y) { if (t[y * 3 + x] != c) { ok = false; break; } } if (ok) return true; } return t[0] == c && t[4] == c && t[8] == c || t[2] == c && t[4] == c && t[6] == c; } int main() { char buf[10]; while (scanf("%s\n", buf) != EOF) { char c; if (win(buf, 'o')) c = 'o'; else if (win(buf, 'x')) c = 'x'; else c = 'd'; printf("%c\n", c); } return 0; }
[["-", 31, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 31, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["-", 51, 16, 31, 69, 341, 342, 0, 16, 12, 22], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 22]]
1
301
4
#include <iostream> int main() { char c[9]; while (std::cin >> c) { if (std::cin.eof()) break; bool f = true; for (int i = 0; i < 3; i++) { if (c[i * 3] == c[i * 3 + 1] && c[i * 3] == c[i * 3 + 2]) { if (c[i * 3] != 's') { std::cout << c[i * 3] << std::endl; f = false; break; } } if (c[i] == c[i + 3] && c[i] == c[i + 6]) { if (c[i] != 's') { std::cout << c[i] << std::endl; f = false; break; } } } if (c[0] == c[4] && c[0] == c[8]) { if (c[0] != 's') { std::cout << c[0] << std::endl; f = false; break; } } if (c[2] == c[4] && c[2] == c[6]) { if (c[0] != 's') { std::cout << c[2] << std::endl; f = false; break; } } if (f) std::cout << 'd' << std::endl; } return 0; }
#include <iostream> int main() { char c[9]; while (std::cin >> c) { if (std::cin.eof()) break; bool f = true; for (int i = 0; i < 3; i++) { if (c[i * 3] == c[i * 3 + 1] && c[i * 3] == c[i * 3 + 2]) { if (c[i * 3] != 's') { std::cout << c[i * 3] << std::endl; f = false; break; } } if (c[i] == c[i + 3] && c[i] == c[i + 6]) { if (c[i] != 's') { std::cout << c[i] << std::endl; f = false; break; } } } if (c[0] == c[4] && c[0] == c[8]) { if (c[0] != 's') { std::cout << c[0] << std::endl; f = false; continue; } } if (c[2] == c[4] && c[2] == c[6]) { if (c[2] != 's') { std::cout << c[2] << std::endl; f = false; continue; } } if (f) std::cout << 'd' << std::endl; } return 0; }
[["-", 64, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 64, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13]]
1
320
6
#include <cstdio> #include <iostream> using namespace std; int main() { char data[9]; int jadge = 0; // 0‚È‚çˆø‚«•ª‚¯//‚P‚È‚ço//2‚È‚çx while (cin >> data) { jadge = 0; for (int i = 0, j = 0; i < 3; i++, j += 2) { //‰¡‚É•À‚Ô‚Æ‚« if (data[0 + j] == 'o' && data[1 + j] == 'o' && data[2 + j] == 'o') jadge = 1; if (data[0 + j] == 'x' && data[1 + j] == 'x' && data[2 + j] == 'x') jadge = 2; // cout << j<< endl; } //c‚ɂȂç‚Ô‚Æ‚« for (int i = 0; i < 3; i++) { if (data[0 + i] == 'o' && data[3 + i] == 'o' && data[6 + i] == 'o') jadge = 1; if (data[0 + i] == 'x' && data[3 + i] == 'x' && data[6 + i] == 'x') jadge = 2; } //ŽÎ‚߂ɂȂç‚Ô‚Æ‚« if (data[0] == 'o' && data[4] == 'o' && data[8] == 'o') jadge = 1; if (data[0] == 'x' && data[4] == 'x' && data[8] == 'x') jadge = 2; if (data[2] == 'o' && data[4] == 'o' && data[6] == 'o') jadge = 1; if (data[2] == 'x' && data[4] == 'x' && data[6] == 'x') jadge = 2; switch (jadge) { case 1: printf("o\n"); break; case 2: printf("x\n"); break; case 0: printf("d\n"); break; } } return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { char data[12]; int jadge = 0; // 0‚È‚çˆø‚«•ª‚¯//‚P‚È‚ço//2‚È‚çx while (cin >> data) { jadge = 0; for (int i = 0, j = 0; i < 3; i++, j += 3) { //‰¡‚É•À‚Ô‚Æ‚« if (data[0 + j] == 'o' && data[1 + j] == 'o' && data[2 + j] == 'o') jadge = 1; if (data[0 + j] == 'x' && data[1 + j] == 'x' && data[2 + j] == 'x') jadge = 2; // cout << j<< endl; } //c‚ɂȂç‚Ô‚Æ‚« for (int i = 0; i < 3; i++) { if (data[0 + i] == 'o' && data[3 + i] == 'o' && data[6 + i] == 'o') jadge = 1; if (data[0 + i] == 'x' && data[3 + i] == 'x' && data[6 + i] == 'x') jadge = 2; } //ŽÎ‚߂ɂȂç‚Ô‚Æ‚« if (data[0] == 'o' && data[4] == 'o' && data[8] == 'o') jadge = 1; if (data[0] == 'x' && data[4] == 'x' && data[8] == 'x') jadge = 2; if (data[2] == 'o' && data[4] == 'o' && data[6] == 'o') jadge = 1; if (data[2] == 'x' && data[4] == 'x' && data[6] == 'x') jadge = 2; switch (jadge) { case 1: printf("o\n"); break; case 2: printf("x\n"); break; case 0: printf("d\n"); break; } } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 7, 26, 34, 12, 11, 12, 13], ["+", 8, 9, 0, 7, 26, 34, 12, 11, 12, 13]]
1
418
4
#include <algorithm> #include <bits/stdc++.h> using namespace std; char sute[1]; char m[8][8]; int w[12][2] = {{-3, 0}, {-2, 0}, {-1, 0}, {3, 0}, {2, 0}, {1, 0}, {0, -3}, {0, -2}, {0, -1}, {0, 1}, {0, 2}, {0, 3}}; void bomb(int i, int j) { int ni, nj; for (int k = 0; k < 12; ++k) { m[i][j] = '0'; ni = i + w[k][0]; nj = j + w[k][1]; if (ni >= 0 && ni < 8 && nj >= 0 && nj < 8) { if (m[ni][nj] == '1') { bomb(ni, nj); } else { m[ni][nj] = '0'; } } } return; } int main() { int n, cnt = 1, x, y; scanf("%d", &n); for (int i = 0; i < n; ++i) { fgets(sute, 1, stdin); for (int j = 0; j < 8; ++j) { scanf("%s", m[j]); } scanf("%d", &x); scanf("%d", &y); bomb(y - 1, x - 1); printf("Data %d:\n", cnt); cnt++; for (int j = 0; j < 8; ++j) { for (int k = 0; k < 8; ++k) { printf("%c", m[j]); } printf("\n"); } } return 0; }
#include <algorithm> #include <bits/stdc++.h> using namespace std; char sute[1]; char m[8][8]; int w[12][2] = {{-3, 0}, {-2, 0}, {-1, 0}, {3, 0}, {2, 0}, {1, 0}, {0, -3}, {0, -2}, {0, -1}, {0, 1}, {0, 2}, {0, 3}}; void bomb(int i, int j) { int ni, nj; for (int k = 0; k < 12; ++k) { m[i][j] = '0'; ni = i + w[k][0]; nj = j + w[k][1]; if (ni >= 0 && ni < 8 && nj >= 0 && nj < 8) { if (m[ni][nj] == '1') { bomb(ni, nj); } else { m[ni][nj] = '0'; } } } return; } int main() { int n, cnt = 1, x, y; scanf("%d", &n); for (int i = 0; i < n; ++i) { fgets(sute, 1, stdin); for (int j = 0; j < 8; ++j) { scanf("%s", m[j]); } scanf("%d", &x); scanf("%d", &y); bomb(y - 1, x - 1); printf("Data %d:\n", cnt); cnt++; for (int j = 0; j < 8; ++j) { for (int k = 0; k < 8; ++k) { printf("%c", m[j][k]); } printf("\n"); } } return 0; }
[["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
1
412
3
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #define ld long double #define EPS 0.0000000001 #define INF 1e9 #define MOD 1000000007 #define rep(i, n) for (i = 0; i < n; i++) #define loop(i, a, n) for (i = a; i < n; i++) #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) typedef vector<int> vi; typedef pair<int, int> pii; int main(void) { int i, j, k; int n; cin >> n; rep(k, n) { cin.ignore(); vector<string> v(10); rep(i, 8) cin >> v[i]; int x, y; cin >> x >> y; x--; y--; queue<pii> q; q.push(pii(x, y)); while (q.size()) { x = q.front().first; y = q.front().second; q.pop(); v[y][x] = '0'; for (i = 1; i < 4; i++) { if (y - i >= 0 && v[y - i][x] == '1') q.push(pii(x, y - i)); if (y + i < 8 && v[y + i][x] == '1') q.push(pii(x, y + i)); if (x - i >= 0 && v[y][x - i] == '1') q.push(pii(x - i, y)); if (x + i < 8 && v[y][x + i] == '1') q.push(pii(x + i, y)); } } cout << "Data " << k + 1 << endl; rep(i, 8) cout << v[i] << endl; } }
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #define ld long double #define EPS 0.0000000001 #define INF 1e9 #define MOD 1000000007 #define rep(i, n) for (i = 0; i < n; i++) #define loop(i, a, n) for (i = a; i < n; i++) #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) typedef vector<int> vi; typedef pair<int, int> pii; int main(void) { int i, j, k; int n; cin >> n; rep(k, n) { cin.ignore(); vector<string> v(10); rep(i, 8) cin >> v[i]; int x, y; cin >> x >> y; x--; y--; queue<pii> q; q.push(pii(x, y)); while (q.size()) { x = q.front().first; y = q.front().second; q.pop(); v[y][x] = '0'; for (i = 1; i < 4; i++) { if (y - i >= 0 && v[y - i][x] == '1') q.push(pii(x, y - i)); if (y + i < 8 && v[y + i][x] == '1') q.push(pii(x, y + i)); if (x - i >= 0 && v[y][x - i] == '1') q.push(pii(x - i, y)); if (x + i < 8 && v[y][x + i] == '1') q.push(pii(x + i, y)); } } cout << "Data " << k + 1 << ':' << endl; rep(i, 8) cout << v[i] << endl; } }
[["+", 0, 1, 0, 16, 31, 16, 12, 103, 0, 104], ["+", 0, 1, 0, 16, 31, 16, 12, 103, 0, 125], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151]]
1
422
4
#include <iostream> #include <string> #define N 8 using namespace std; string m[N]; void bomb(int x, int y) { if (!(0 <= x && x < N && 0 <= y && y < N)) return; if (m[x][y] != '1') return; m[x][y] = '0'; bomb(x + 1, y); bomb(x + 2, y); bomb(x + 3, y); bomb(x - 1, y); bomb(x - 2, y); bomb(x - 3, y); bomb(x, y + 1); bomb(x, y + 2); bomb(x, y + 3); bomb(x, y - 1); bomb(x, y - 2); bomb(x, y - 3); } int main(void) { int n; int x, y; cin >> n; for (int X = 1; X <= n; X++) { int c = 0; for (int i = 0; i < N; i++) cin >> m[i]; cin >> x >> y; bomb(x - 1, y - 1); cout << "Data " << X << ":" << endl; for (int i = 0; i < N; i++) { cout << m[i] << endl; } } }
#include <iostream> #include <string> #define N 8 using namespace std; string m[N]; void bomb(int x, int y) { if (!(0 <= x && x < N && 0 <= y && y < N)) return; if (m[x][y] != '1') return; m[x][y] = '0'; bomb(x + 1, y); bomb(x + 2, y); bomb(x + 3, y); bomb(x - 1, y); bomb(x - 2, y); bomb(x - 3, y); bomb(x, y + 1); bomb(x, y + 2); bomb(x, y + 3); bomb(x, y - 1); bomb(x, y - 2); bomb(x, y - 3); } int main(void) { int n; int x, y; cin >> n; for (int X = 1; X <= n; X++) { int c = 0; for (int i = 0; i < N; i++) cin >> m[i]; cin >> y >> x; bomb(x - 1, y - 1); cout << "Data " << X << ":" << endl; for (int i = 0; i < N; i++) { cout << m[i] << endl; } } }
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22]]
1
304
4
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int dx[] = {1, 2, 3, -1, -2, -3, 0, 0, 0, 0, 0, 0}; int dy[] = {0, 0, 0, 0, 0, 0, 1, 2, 3, -1, -2, -3}; int main() { int n; cin >> n; r(pp, n) { string s[8]; r(i, 8) cin >> s[i]; int x1, y1; cin >> x1 >> y1; x1--; y1--; int a[8][8] = {}; a[y1][x1]++; r(o, 10) r(i, 8) r(j, 8) { if (a[i][j] && s[i][j] == '1') r(k, 12) { int x = j + dx[i], y = i + dy[i]; if (x >= 0 && y >= 0 && y < 8 && x < 8) a[y][x] = 1; } } r(i, 8) r(j, 8) if (a[i][j]) s[i][j] = '0'; cout << "Data " << pp + 1 << ':' << endl; r(i, 8) cout << s[i] << endl; } }
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int dx[] = {1, 2, 3, -1, -2, -3, 0, 0, 0, 0, 0, 0}; int dy[] = {0, 0, 0, 0, 0, 0, 1, 2, 3, -1, -2, -3}; int main() { int n; cin >> n; r(pp, n) { string s[8]; r(i, 8) cin >> s[i]; int x1, y1; cin >> x1 >> y1; x1--; y1--; int a[8][8] = {}; a[y1][x1]++; r(o, 10) r(i, 8) r(j, 8) { if (a[i][j] && s[i][j] == '1') r(k, 12) { int x = j + dx[k], y = i + dy[k]; if (x >= 0 && y >= 0 && y < 8 && x < 8) a[y][x] = 1; } } r(i, 8) r(j, 8) if (a[i][j]) s[i][j] = '0'; cout << "Data " << pp + 1 << ':' << endl; r(i, 8) cout << s[i] << endl; } }
[["-", 49, 50, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 49, 50, 51, 16, 12, 69, 341, 342, 0, 22]]
1
322
4
#include <bits/stdc++.h> #define rep(i, j, k) for (int i = (int)j; i < (int)k; i++) #define itrep(x) for (auto it = (x).begin(); it != (x).end(); it++) #define Sort(x) sort((x).begin(), (x).end()) #define all(x) (x).begin(), (x).end() #define fi first #define se second #define vi vector<int> #define INF (int)1e9 #define INFL 1e18 //#define MOD 1000000007 #define pb push_back #define MP make_pair #define PI 3.1415926535 typedef long long int ll; typedef std::pair<int, int> P; int D = 1; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; using namespace std; string s[8]; void solve(int y, int x) { s[y][x] = '0'; rep(i, 1, 4) { int ny = y + i; if (0 <= ny && ny <= 7 && s[ny][x] == '1') { solve(ny, x); } } rep(i, 1, 4) { int ny = y - i; if (0 <= ny && ny <= 7 && s[ny][x] == '1') { solve(ny, x); } } rep(i, 1, 4) { int nx = x + i; if (0 <= nx && nx <= 7 && s[y][nx] == '1') { solve(y, nx); } } rep(i, 1, 4) { int nx = x - i; if (0 <= nx && nx <= 7 && s[y][nx] == '1') { solve(y, nx); } } } int main() { int n; cin >> n; rep(p, 0, n) { cout << "Date " + to_string(p + 1) + ":" << endl; int x, y; rep(i, 0, 8) cin >> s[i]; cin >> x >> y; solve(y - 1, x - 1); rep(i, 0, 8) { rep(j, 0, 8) { cout << s[i][j]; } cout << endl; } } return 0; }
#include <bits/stdc++.h> #define rep(i, j, k) for (int i = (int)j; i < (int)k; i++) #define itrep(x) for (auto it = (x).begin(); it != (x).end(); it++) #define Sort(x) sort((x).begin(), (x).end()) #define all(x) (x).begin(), (x).end() #define fi first #define se second #define vi vector<int> #define INF (int)1e9 #define INFL 1e18 //#define MOD 1000000007 #define pb push_back #define MP make_pair #define PI 3.1415926535 typedef long long int ll; typedef std::pair<int, int> P; int D = 1; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; using namespace std; string s[8]; void solve(int y, int x) { s[y][x] = '0'; rep(i, 1, 4) { int ny = y + i; if (0 <= ny && ny <= 7 && s[ny][x] == '1') { solve(ny, x); } } rep(i, 1, 4) { int ny = y - i; if (0 <= ny && ny <= 7 && s[ny][x] == '1') { solve(ny, x); } } rep(i, 1, 4) { int nx = x + i; if (0 <= nx && nx <= 7 && s[y][nx] == '1') { solve(y, nx); } } rep(i, 1, 4) { int nx = x - i; if (0 <= nx && nx <= 7 && s[y][nx] == '1') { solve(y, nx); } } } int main() { int n; cin >> n; rep(p, 0, n) { cout << "Data " + to_string(p + 1) + ":" << endl; int x, y; rep(i, 0, 8) cin >> s[i]; cin >> x >> y; solve(y - 1, x - 1); rep(i, 0, 8) { rep(j, 0, 8) { cout << s[i][j]; } cout << endl; } } return 0; }
[["-", 31, 16, 12, 16, 31, 16, 31, 5, 0, 6], ["+", 31, 16, 12, 16, 31, 16, 31, 5, 0, 6]]
1
457
2
#include <algorithm> #include <cstdio> #include <iostream> #include <math.h> #include <vector> using namespace std; int n, t[8][8]; string str; int ch(int y, int x) { if (0 <= y && y <= 7 && 0 <= x && x <= 7) return t[y][x]; return 0; } void bomb(int y, int x) { t[y][x] = 0; for (int i = 0; i <= 3; i++) { if (ch(y + i, x) == 1) bomb(y + i, x); if (ch(y - i, x) == 1) bomb(y - i, x); if (ch(y, x + i) == 1) bomb(y, x + i); if (ch(y, x - i) == 1) bomb(y, x - i); } } int main() { int x, y; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < 8; j++) { cin >> str; for (int k = 0; k < 8; k++) t[j][k] = str[k] - '0'; } cin >> x >> y; bomb(y - 1, x - 1); cout << "Data " << i << ':' << endl; for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { cout << t[j][k]; } cout << endl; } } return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <math.h> #include <vector> using namespace std; int n, t[8][8]; string str; int ch(int y, int x) { if (0 <= y && y <= 7 && 0 <= x && x <= 7) return t[y][x]; return 0; } void bomb(int y, int x) { t[y][x] = 0; for (int i = 0; i <= 3; i++) { if (ch(y + i, x) == 1) bomb(y + i, x); if (ch(y - i, x) == 1) bomb(y - i, x); if (ch(y, x + i) == 1) bomb(y, x + i); if (ch(y, x - i) == 1) bomb(y, x - i); } } int main() { int x, y; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < 8; j++) { cin >> str; for (int k = 0; k < 8; k++) t[j][k] = str[k] - '0'; } cin >> x >> y; bomb(y - 1, x - 1); cout << "Data " << i + 1 << ':' << endl; for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { cout << t[j][k]; } cout << endl; } } return 0; }
[["+", 0, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 12, 13]]
1
356
2
#include <bits/stdc++.h> using namespace std; int main() { int times; cin >> times; for (int i = 0; i < times; ++i) { cout << endl; int place[8][8]; bitset<8> bomb; for (int j = 0; j < 8; ++j) { cin >> bomb; for (int k = 0; k < 8; ++k) { place[j][k] = bomb[7 - k]; } } int x_hit, y_hit; cin >> x_hit; cin >> y_hit; vector<pair<int, int>> bplace; bplace.push_back(make_pair(x_hit - 1, y_hit - 1)); place[y_hit - 1][x_hit - 1] = 0; while (1) { bool con = false; for (pair<int, int> e : bplace) { int x = e.first; int y = e.second; // for (int j = x - 1; j > x - 4 && j >= 0; --j) { if (place[y][j] == 1) { bplace.push_back(make_pair(j, y)); place[y][j] = 0; con = true; } } // for (int j = x + 1; j < x + 4 && j <= 7; ++j) { if (place[y][j] == 1) { bplace.push_back(make_pair(j, y)); place[y][j] = 0; con = true; } } // for (int j = y - 1; j > y - 4 && j >= 0; --j) { if (place[j][x] == 1) { bplace.push_back(make_pair(x, j)); place[j][x] = 0; con = true; } } // for (int j = y + 1; j < y + 4 && j <= 7; ++j) { if (place[j][x] == 1) { bplace.push_back(make_pair(x, j)); place[j][x] = 0; con = true; } } } if (con == false) { break; } } cout << "Data " << i + 1 << ":" << endl; for (int j = 0; j < 8; ++j) { for (int k = 0; k < 8; ++k) { cout << place[j][k]; } cout << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int times; cin >> times; for (int i = 0; i < times; ++i) { // cout<<endl; int place[8][8]; bitset<8> bomb; for (int j = 0; j < 8; ++j) { cin >> bomb; for (int k = 0; k < 8; ++k) { place[j][k] = bomb[7 - k]; } } int x_hit, y_hit; cin >> x_hit; cin >> y_hit; vector<pair<int, int>> bplace; bplace.push_back(make_pair(x_hit - 1, y_hit - 1)); place[y_hit - 1][x_hit - 1] = 0; while (1) { bool con = false; for (pair<int, int> e : bplace) { int x = e.first; int y = e.second; // for (int j = x - 1; j > x - 4 && j >= 0; --j) { if (place[y][j] == 1) { bplace.push_back(make_pair(j, y)); place[y][j] = 0; con = true; } } // for (int j = x + 1; j < x + 4 && j <= 7; ++j) { if (place[y][j] == 1) { bplace.push_back(make_pair(j, y)); place[y][j] = 0; con = true; } } // for (int j = y - 1; j > y - 4 && j >= 0; --j) { if (place[j][x] == 1) { bplace.push_back(make_pair(x, j)); place[j][x] = 0; con = true; } } // for (int j = y + 1; j < y + 4 && j <= 7; ++j) { if (place[j][x] == 1) { bplace.push_back(make_pair(x, j)); place[j][x] = 0; con = true; } } } if (con == false) { break; } } cout << "Data " << i + 1 << ":" << endl; for (int j = 0; j < 8; ++j) { for (int k = 0; k < 8; ++k) { cout << place[j][k]; } cout << endl; } } return 0; }
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
533
4
#include <iostream> #include <string> #define COLS 8 #define ROWS 8 using namespace std; void ExplodeBomb(int map[][COLS + 6], int x, int y) { int dij[] = {1, 2, 3, -1, -2, -3}; if (map[y + 3][x + 3] == 0) return; map[y + 3][x + 3] = 0; for (int i = 0; i < sizeof(dij) / sizeof(*dij); i++) { ExplodeBomb(map, x, y + dij[i]); } for (int j = 0; j < sizeof(dij) / sizeof(*dij); j++) { ExplodeBomb(map, x + dij[j], y); } } int main(void) { int n; cin >> n; for (int i = 0; i < n; i++) { int x, y; int map[ROWS + 6][COLS + 6] = { { 0, }, }; char buf[32]; string s; cin.getline(buf, sizeof(buf) / sizeof(*buf)); for (int j = 0; j < ROWS; j++) { cin >> s; for (unsigned int k = 0; k < s.length(); k++) { if (s[k] == '1') map[j + 3][k + 3] = 1; } } cin >> x >> y; cin.ignore(); ExplodeBomb(map, x - 1, y - 1); cout << "Data " << i << ":\n"; for (int j = 0; j < ROWS; j++) { for (int k = 0; k < COLS; k++) { cout << map[j + 3][k + 3]; } cout << '\n'; } } return 0; }
#include <iostream> #include <string> #define COLS 8 #define ROWS 8 using namespace std; void ExplodeBomb(int map[][COLS + 6], int x, int y) { int dij[] = {1, 2, 3, -1, -2, -3}; if (map[y + 3][x + 3] == 0) return; map[y + 3][x + 3] = 0; for (int i = 0; i < sizeof(dij) / sizeof(*dij); i++) { ExplodeBomb(map, x, y + dij[i]); } for (int j = 0; j < sizeof(dij) / sizeof(*dij); j++) { ExplodeBomb(map, x + dij[j], y); } } int main(void) { int n; cin >> n; for (int i = 0; i < n; i++) { int x, y; int map[ROWS + 6][COLS + 6] = { { 0, }, }; char buf[32]; string s; cin.getline(buf, sizeof(buf) / sizeof(*buf)); for (int j = 0; j < ROWS; j++) { cin >> s; for (unsigned int k = 0; k < s.length(); k++) { if (s[k] == '1') map[j + 3][k + 3] = 1; } } cin >> x >> y; cin.ignore(); ExplodeBomb(map, x - 1, y - 1); cout << "Data " << i + 1 << ":\n"; for (int j = 0; j < ROWS; j++) { for (int k = 0; k < COLS; k++) { cout << map[j + 3][k + 3]; } cout << '\n'; } } return 0; }
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
406
2
#include <stdio.h> int ma[8][8]; int main() { int n, data = 0, i, j, x, y, a, b; scanf("%d", &n); for (; n > 0; --n) { ++data; for (i = 0; i < 8; ++i) { for (j = 0; j < 8; j++) { scanf("%1d", &ma[i][j]); } } scanf("%d%d", &x, &y); --x; --y; ma[y][x] = 0; for (i = x - 3; i <= x + 3; i++) { if (0 <= i && i < 8) { if (ma[y][i] == 1) { ma[y][i] = 2; } else { ma[y][i] = 0; } } } for (i = y - 3; i <= y + 3; ++i) { if (0 <= i && i < 8) { if (ma[i][x] == 1) { ma[i][x] = 2; } else { ma[i][x] = 0; } } } int flag = 1; while (flag) { flag = 0; for (a = 0; a < 8; a++) { for (b = 0; b < 8; b++) { if (ma[a][b] == 2) { y = a; x = b; ma[y][x] = 0; for (i = x - 3; i <= x + 3; i++) { if (0 <= i && i < 8) { if (ma[y][i] == 1) { ma[y][i] = 2; flag = 1; } else { ma[y][i] = 0; } } } for (i = y - 3; i <= y + 3; ++i) { if (0 <= i && i < 8) { if (ma[i][x] == 1) { ma[i][x] = 2; flag = 1; } else { ma[i][x] = 0; } } } } } } } printf("Data %d:\n", data); for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { printf("%d", ma[i][j]); } printf("\n"); } } return 0; }
#include <stdio.h> int ma[8][8]; int main() { int n, data = 0, i, j, x, y, a, b; scanf("%d", &n); for (; n > 0; --n) { ++data; for (i = 0; i < 8; ++i) { for (j = 0; j < 8; j++) { scanf("%1d", &ma[i][j]); } } scanf("%d%d", &x, &y); --x; --y; ma[y][x] = 0; for (i = x - 3; i <= x + 3; i++) { if (0 <= i && i < 8) { if (ma[y][i] == 1) { ma[y][i] = 2; } else { ma[y][i] = 0; } } } for (i = y - 3; i <= y + 3; ++i) { if (0 <= i && i < 8) { if (ma[i][x] == 1) { ma[i][x] = 2; } else { ma[i][x] = 0; } } } int flag = 1; while (flag) { flag = 0; for (a = 0; a < 8; a++) { for (b = 0; b < 8; b++) { if (ma[a][b] == 2) { y = a; x = b; ma[y][x] = 0; for (i = x - 3; i <= x + 3; i++) { if (0 <= i && i < 8) { if (ma[y][i] > 0) { ma[y][i] = 2; flag = 1; } else { ma[y][i] = 0; } } } for (i = y - 3; i <= y + 3; ++i) { if (0 <= i && i < 8) { if (ma[i][x] > 0) { ma[i][x] = 2; flag = 1; } else { ma[i][x] = 0; } } } } } } } printf("Data %d:\n", data); for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { printf("%d", ma[i][j]); } printf("\n"); } } return 0; }
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
558
8
#include <iostream> #include <string> using namespace std; void bomb(string s[], int a, int b) { s[a][b] = '0'; for (int i = 1; i <= 3; i++) { if (b + i < 8 && s[a][b + i] == '1') bomb(s, a, b + i); if (b - i >= 0 && s[a][b - i] == '1') bomb(s, a, b - i); if (a + i < 8 && s[a + i][b] == '1') bomb(s, a + i, b); if (a - i >= 0 && s[a - i][b] == '1') bomb(s, a - i, b); } } int main() { int n; string area[8]; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 0; j < 8; j++) { cin >> area[j]; } int a, b; cin >> a >> b; bomb(area, a - 1, b - 1); cout << "Data " << i << ":" << endl; for (int j = 0; j < 8; j++) { cout << area[j] << endl; } } return 0; }
#include <iostream> #include <string> using namespace std; void bomb(string s[], int a, int b) { s[a][b] = '0'; for (int i = 1; i <= 3; i++) { if (b + i < 8 && s[a][b + i] == '1') bomb(s, a, b + i); if (b - i >= 0 && s[a][b - i] == '1') bomb(s, a, b - i); if (a + i < 8 && s[a + i][b] == '1') bomb(s, a + i, b); if (a - i >= 0 && s[a - i][b] == '1') bomb(s, a - i, b); } } int main() { int n; string area[8]; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 0; j < 8; j++) { cin >> area[j]; } int a, b; cin >> a >> b; bomb(area, b - 1, a - 1); cout << "Data " << i << ":" << endl; for (int j = 0; j < 8; j++) { cout << area[j] << endl; } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22]]
1
308
4
#include <algorithm> #include <cassert> #include <cctype> #include <cstdio> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string> using namespace std; int N, sx, sy, field[8][9], dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; char c; void bomb(int x, int y) { field[y][x] = 0; for (int i = 0; i < 4; i++) { for (int j = 1; j < 4; j++) { int nx = x + dx[i] * j, ny = y + dy[i] * j; if (nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && field[ny][nx] == 1) bomb(nx, ny); } } } int main() { cin >> N; for (int h = 0; h < N; h++) { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> c; field[i][j] = c - '0'; } } cin >> sx >> sy; bomb(sx - 1, sy - 1); cout << "Data " << h + 1 << ":" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << field[i][j] << " "; } cout << endl; } } }
#include <algorithm> #include <cassert> #include <cctype> #include <cstdio> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string> using namespace std; int N, sx, sy, field[8][9], dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; char c; void bomb(int x, int y) { field[y][x] = 0; for (int i = 0; i < 4; i++) { for (int j = 1; j < 4; j++) { int nx = x + dx[i] * j, ny = y + dy[i] * j; if (nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && field[ny][nx] == 1) bomb(nx, ny); } } } int main() { cin >> N; for (int h = 0; h < N; h++) { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> c; field[i][j] = c - '0'; } } cin >> sx >> sy; bomb(sx - 1, sy - 1); cout << "Data " << h + 1 << ":" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << field[i][j]; } cout << endl; } } }
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
340
4
#include <cstring> #include <iostream> using namespace std; void bomb(int map[14][14], int x, int y) { map[x][y] = 0; for (int i = -3; i <= 3; i++) { if (map[x + i][y]) { bomb(map, x + i, y); } if (map[x][y + i]) { bomb(map, x, y + i); } } } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int map[14][14]; memset(map, 0, sizeof(map)); int in; for (int j = 3; j <= 10; j++) { cin >> in; for (int k = 10; k > 2; k--) { map[j][k] = in % 10; in /= 10; } } int x, y; cin >> x >> y; bomb(map, y + 2, x + 2); cout << "Data " << i << endl; for (int j = 3; j <= 10; j++) { for (int k = 3; k <= 10; k++) { cout << map[j][k]; } cout << endl; } } }
#include <cstring> #include <iostream> using namespace std; void bomb(int map[14][14], int x, int y) { map[x][y] = 0; for (int i = -3; i <= 3; i++) { if (map[x + i][y]) { bomb(map, x + i, y); } if (map[x][y + i]) { bomb(map, x, y + i); } } } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int map[14][14]; memset(map, 0, sizeof(map)); int in; for (int j = 3; j <= 10; j++) { cin >> in; for (int k = 10; k > 2; k--) { map[j][k] = in % 10; in /= 10; } } int x, y; cin >> x >> y; bomb(map, y + 2, x + 2); cout << "Data " << i << ":" << endl; for (int j = 3; j <= 10; j++) { for (int k = 3; k <= 10; k++) { cout << map[j][k]; } cout << endl; } } }
[["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151]]
1
289
4
#include <cstdio> #include <iostream> #include <string> using namespace std; string s[8]; void bomb(int x, int y) { s[x][y] = '0'; for (int i = -3; i <= 3; i++) { if (x + i >= 0 && x + i < 8 && s[x + i][y] == '1') { s[x + i][y] = '0'; bomb(x + i, y); } if (y + i >= 0 && y + i < 8 && s[x][y + i] == '1') { s[x][y + i] = '0'; bomb(x, y + i); } } } int main() { int n; cin >> n; cin.ignore(); for (int i = 0; i < n; i++) { for (int j = 0; j < 8; j++) cin >> s[j]; cin.ignore(); int x, y; cin >> x >> y; bomb(y - 1, x - 1); printf("Date %d:\n", i + 1); for (int j = 0; j < 8; j++) cout << s[j] << endl; } }
#include <cstdio> #include <iostream> #include <string> using namespace std; string s[8]; void bomb(int x, int y) { s[x][y] = '0'; for (int i = -3; i <= 3; i++) { if (x + i >= 0 && x + i < 8 && s[x + i][y] == '1') { s[x + i][y] = '0'; bomb(x + i, y); } if (y + i >= 0 && y + i < 8 && s[x][y + i] == '1') { s[x][y + i] = '0'; bomb(x, y + i); } } } int main() { int n; cin >> n; cin.ignore(); for (int i = 0; i < n; i++) { for (int j = 0; j < 8; j++) cin >> s[j]; cin.ignore(); int x, y; cin >> x >> y; bomb(y - 1, x - 1); printf("Data %d:\n", i + 1); for (int j = 0; j < 8; j++) cout << s[j] << endl; } }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
280
2