buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <algorithm> #include <math.h> #include <queue> #include <stdio.h> #include <utility> bool CheckMSPrime(int _n) { for (int i = 2; (i * i) <= _n; i++) { if (_n % i == 0) { if (i % 7 == 1 || i % 7 == 6) { return false; } } } return true; } void PrintPrime(int _n) { printf("%d...
#include <algorithm> #include <math.h> #include <queue> #include <stdio.h> #include <utility> bool CheckMSPrime(int _n) { for (int i = 2; (i * i) <= _n; i++) { if (_n % i == 0) { if (i % 7 == 1 || i % 7 == 6) { return false; } } } return true; } void PrintPrime(int _n) { printf("%d...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
239
2
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, init, n) for (int i = init; i < (n); i++) using namespace std; using ll = long long int; using P = pair<int, int>; using T = tuple<int, int, int>; using edge = struct { int to, cost; }; const int MOD = 1e9 + 7; const int iINF = 1...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, init, n) for (int i = init; i < (n); i++) using namespace std; using ll = long long int; using P = pair<int, int>; using T = tuple<int, int, int>; using edge = struct { int to, cost; }; const int MOD = 1e9 + 7; const int iINF = 1...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
389
4
#include <algorithm> #include <cstdio> using namespace std; #define MAX 300000 int n; bool prime[MAX]; int main() { for (int i = 0; i < MAX; i++) prime[i] = true; for (int i = 6; i * i < MAX; i++) if (i % 7 == 1 || i % 7 == 6) if (prime[i]) for (int j = i; i * j < MAX; j++) if (j...
#include <algorithm> #include <cstdio> using namespace std; #define MAX 300000 int n; bool prime[MAX]; int main() { for (int i = 0; i < MAX; i++) prime[i] = true; for (int i = 6; i * i < MAX; i++) if (i % 7 == 1 || i % 7 == 6) if (prime[i]) for (int j = i; i * j < MAX; j++) if (j...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
232
2
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c).begin()) i =...
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c).begin()) i =...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
263
4
#include <iostream> #include <vector> using namespace std; int main() { bool num[300001] = {true, true, false}; for (int i = 0; i < 300001; i++) { if (i % 7 != 1 && i % 7 != 6) { num[i] = true; } if (num[i] == false) { for (int j = i * 2; j < 300001; j += i) { num[j] = true; } ...
#include <iostream> #include <vector> using namespace std; int main() { bool num[300001] = {true, true, false}; for (int i = 0; i < 300001; i++) { if (i % 7 != 1 && i % 7 != 6) { num[i] = true; } if (num[i] == false) { for (int j = i * 2; j < 300001; j += i) { num[j] = true; } ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
221
2
#include <iostream> using namespace std; #define MAX_N 300000 int pl[MAX_N]; char ip[MAX_N]; int p = 0; main() { int i, n = 300000; for (i = 0; i <= n; i++) ip[i] = 1; ip[0] = ip[1] = 0; for (i = 2; i <= n; i++) { if (i % 7 != 1 && i % 7 != 6) ip[i] = 0; if (ip[i]) { for (int j = 2 * i;...
#include <iostream> using namespace std; #define MAX_N 300000 int pl[MAX_N + 2]; char ip[MAX_N + 2]; int p = 0; main() { int i, n = 300000; for (i = 0; i <= n; i++) ip[i] = 1; ip[0] = ip[1] = 0; for (i = 2; i <= n; i++) { if (i % 7 != 1 && i % 7 != 6) ip[i] = 0; if (ip[i]) { for (int j ...
[["+", 0, 30, 0, 43, 49, 80, 81, 16, 17, 72], ["+", 0, 30, 0, 43, 49, 80, 81, 16, 12, 13]]
1
211
4
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; #define MAX 300001 typedef long long ll; int main() { bool p[MAX]; vector<ll> ms; int n; memset(p, true, sizeof(p)); for (int i = 1; i < MAX; i++) { if (i % 7 == 1 || i % 7 == 6) ...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; #define MAX 300001 typedef long long ll; int main() { bool p[MAX]; vector<ll> ms; int n; memset(p, true, sizeof(p)); for (int i = 1; i < MAX; i++) { if (i % 7 == 1 || i % 7 == 6) ...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 147], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
283
4
#include <iostream> #include <vector> using namespace std; #define MAX 300001 bool check[MAX]; void print(int n) { cout << n << ':'; } void init() { fill(check, check + MAX, false); } int main() { int n; while (cin >> n, n != 1) { vector<int> v; init(); print(n); for (int i = 2; i <= n; i++) {...
#include <iostream> #include <vector> using namespace std; #define MAX 300001 bool check[MAX]; void print(int n) { cout << n << ": "; } void init() { fill(check, check + MAX, false); } int main() { int n; while (cin >> n, n != 1) { vector<int> v; init(); print(n); for (int i = 2; i <= n; i++) ...
[["-", 8, 9, 0, 1, 0, 16, 12, 103, 0, 104], ["-", 8, 9, 0, 1, 0, 16, 12, 103, 0, 125], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
216
6
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef vector<int> VI; typedef vector<bool> VB; VI ms_prime_factor(void) { const int SIZE = 300010; VB is_ms_prime_number(SIZE, false); VI res; for (int i = 1; 7 * i + 10 < SIZE; ++i) { is_ms_prime_number[7 * i + 1] = true; ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef vector<int> VI; typedef vector<bool> VB; VI ms_prime_factor(void) { const int SIZE = 300010; VB is_ms_prime_number(SIZE, false); VI res; for (int i = 0; 7 * i + 10 < SIZE; ++i) { is_ms_prime_number[7 * i + 1] = true; ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
242
4
#include <algorithm> #include <iostream> using namespace std; #define H 60 #define W 30 #define INF 10000 #define R 1 #define L 0 int w, h; char maps[H][W]; struct point { int x, y; }; bool invalid(int x, int y) { return (x < 0 || x >= w || y < 0 || y >= h); } int dijkstra() { int d[H][W][2]; bool used[H][W][2...
#include <algorithm> #include <iostream> using namespace std; #define H 60 #define W 30 #define INF 10000 #define R 1 #define L 0 int w, h; char maps[H][W]; struct point { int x, y; }; bool invalid(int x, int y) { return (x < 0 || x >= w || y < 0 || y >= h); } int dijkstra() { int d[H][W][2]; bool used[H][W][2...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
1,104
4
#include <algorithm> #include <iostream> #include <queue> #define INF (1e9) #define H 60 #define W 30 using namespace std; typedef pair<int, int> P; typedef pair<char, P> P1; typedef pair<int, P1> P2; int dijkstra(int, int, char); int w, h, dl[H][W], dr[H][W], ans; char s[H][W]; int main() { while (1) { cin >> w...
#include <algorithm> #include <iostream> #include <queue> #define INF (1e9) #define H 60 #define W 30 using namespace std; typedef pair<int, int> P; typedef pair<char, P> P1; typedef pair<int, P1> P2; int dijkstra(int, int, char); int w, h, dl[H][W], dr[H][W], ans; char s[H][W]; int main() { while (1) { cin >> w...
[["+", 8, 9, 0, 43, 49, 50, 51, 91, 17, 33], ["-", 51, 16, 12, 16, 31, 69, 28, 69, 28, 22], ["+", 51, 16, 12, 16, 31, 69, 28, 69, 28, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 91, 17, 33]]
1
916
7
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stri...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stri...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 12, 22]]
1
898
4
#include <algorithm> #include <iostream> #include <iterator> #include <set> #include <string> #include <vector> using namespace std; typedef basic_string<bool> BS; const BS T = BS(1, true); const BS F = BS(1, false); char str[999]; char *p; struct Cell { Cell *l, *r; BS bs; set<BS> sbs; int num, den; Cell...
#include <algorithm> #include <iostream> #include <iterator> #include <set> #include <string> #include <vector> using namespace std; typedef basic_string<bool> BS; const BS T = BS(1, true); const BS F = BS(1, false); char str[999]; char *p; struct Cell { Cell *l, *r; BS bs; set<BS> sbs; int num, den; Cell...
[["+", 75, 76, 0, 9, 0, 1, 0, 16, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 9, 0, 1, 0, 16, 12, 103, 0, 104], ["+", 0, 9, 0, 1, 0, 16, 12, 103, 0, 125], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
1
536
6
var n, m; var a = [], b = []; function search(x) { var l = 0, r = m; while (r - l > 1) { var c = (l + r) >> 1; if (b[c] <= x) { l = c; } else { r = c; } } return b[l] === x; } function main() { while (n = scan()) { m = scan(); rep(n, function(i) { a[i] = scan(); }); r...
var n, m; var a = [], b = []; function search(x) { var l = 0, r = m; while (r - l > 1) { var c = (l + r) >> 1; if (b[c] <= x) { l = c; } else { r = c; } } return b[l] === x; } function main() { while (n = scan()) { m = scan(); rep(n, function(i) { a[i] = scan(); }); r...
[["-", 8, 556, 0, 57, 64, 556, 0, 116, 0, 117], ["-", 8, 556, 0, 57, 64, 556, 0, 116, 0, 35]]
2
542
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { int n = scanner.nextInt(); int m = scanner.nextInt(); if ((n + m) == 0) break; int[] t = new int[1000]; int[] h = new int[1...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { int n = scanner.nextInt(); int m = scanner.nextInt(); if ((n + m) == 0) break; int[] t = new int[1000]; int[] h = new int[1...
[["-", 64, 196, 0, 1, 0, 11, 12, 504, 71, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 504, 71, 22]]
3
314
2
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #includ...
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #includ...
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
830
8
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <memory.h> #include <memory> #include <numeric> #include <queue> #include <string> #include <vector> using namespace std; typedef pair<int, pair<int, int>> pip; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int w, h; int are...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <memory.h> #include <memory> #include <numeric> #include <queue> #include <string> #include <vector> using namespace std; typedef pair<int, pair<int, int>> pip; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int w, h; int are...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
558
2
#include <iostream> #include <map> #include <queue> using namespace std; int c[4]; struct State { int x, y, d, cost; }; bool operator<(const State a, State b) { return a.cost > b.cost; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; void calc(int w, int h) { int direction[30][30]; for (int i = 0; i <...
#include <iostream> #include <map> #include <queue> using namespace std; int c[4]; struct State { int x, y, d, cost; }; bool operator<(const State a, State b) { return a.cost > b.cost; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; void calc(int w, int h) { int direction[30][30]; for (int i = 0; i <...
[["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 47], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20]]
1
557
4
#include <algorithm> #include <bitset> #include <cctype> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using n...
#include <algorithm> #include <bitset> #include <cctype> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using n...
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 21], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 21], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
1
820
4
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = (a); i < (b); i++) #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define sort(v, n) sort(v, v + n); #define vsort(v) sort(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define fi first #define se second #d...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = (a); i < (b); i++) #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define sort(v, n) sort(v, v + n); #define vsort(v) sort(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define fi first #define se second #d...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
282
2
#include <iostream> using namespace std; int main() { int P, N, ndata[55], wan, lop; while (1) { cin >> N; cin >> P; if (N == 0 && P == 0) { break; } for (lop = 0; lop < N; lop++) { ndata[lop] = 0; } lop = 0; wan = P; while (1) { if (N == 3 && P == 3) { ...
#include <iostream> using namespace std; int main() { int P, N, ndata[55], wan, lop; while (1) { cin >> N; cin >> P; if (N == 0 && P == 0) { break; } for (lop = 0; lop < N; lop++) { ndata[lop] = 0; } lop = 0; wan = P; while (1) { if (N == 3 && P == 3) { ...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
207
8
#include <iostream> using namespace std; int myMap[50][50]; int w, h; int ans; bool safe(int x, int y) { return (0 <= x && 0 <= y) && (x < w && y < h); } void del(int x, int y) { myMap[x][y] = 0; if (safe(x + 1, y) && myMap[x + 1][y]) del(x + 1, y); if (safe(x + 1, y + 1) && myMap[x + 1][y + 1]) del(x ...
#include <iostream> using namespace std; int myMap[51][51]; int w, h; int ans; bool safe(int x, int y) { return (0 <= x && 0 <= y) && (x < h && y < w); } void del(int x, int y) { myMap[x][y] = 0; if (safe(x + 1, y) && myMap[x + 1][y]) del(x + 1, y); if (safe(x + 1, y + 1) && myMap[x + 1][y + 1]) del(x ...
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 16, 12, 23, 0, 16, 12, 16, 12, 22], ["+"...
1
480
12
#include <iostream> using namespace std; int w, h; int m[50][50]; void solve(int x, int y) { if (m[y][x] == 1) { m[y][x] = 0; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) { continue; } if (y + i >= 0 && y + i < h && x + i >= 0 &&...
#include <iostream> using namespace std; int w, h; int m[50][50]; void solve(int x, int y) { if (m[y][x] == 1) { m[y][x] = 0; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) { continue; } if (y + i >= 0 && y + i < h && x + j >= 0 &&...
[["-", 51, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 51, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["-", 15, 339, 51, 16, 12, 16, 31, 16, 12, 22], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 12, 22]]
1
281
4
#include <cstdio> using namespace std; int w, h; int field[50][51]; void dfs(int x, int y) { field[x][y] = 0; for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { int nx = x + dx; int ny = y + dy; if (0 <= nx && nx < w && 0 <= ny && ny < h && field[nx][ny] == 1) d...
#include <cstdio> using namespace std; int w, h; int field[50][51]; void dfs(int x, int y) { field[x][y] = 0; for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { int nx = x + dx; int ny = y + dy; if (0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == 1) d...
[["-", 31, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22]]
1
297
4
#include <iostream> using namespace std; int ans; int map[100][100]; void dfs(int x, int y, int w, int h); int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; int main() { int w, h; while (cin >> w >> h) { ans = 0; if (w == 0 && h == 0) break; for (int i = 0; i < h; i++)...
#include <iostream> using namespace std; int ans; int map[100][100]; void dfs(int x, int y, int w, int h); int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; int main() { int w, h; while (cin >> w >> h) { ans = 0; if (w == 0 && h == 0) break; for (int i = 0; i < h; i++)...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
347
4
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF...
[["-", 3, 4, 0, 652, 63, 319, 500, 557, 0, 6], ["+", 3, 4, 0, 652, 63, 319, 500, 557, 0, 6]]
5
466
2
import java.util.Arrays; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static interface Fomula { int eval(int[] input); } public static class Minus implements Fomula { Fomula inner; public Minus(Fomula in) { inner = in; } @Override...
import java.util.Arrays; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static interface Fomula { int eval(int[] input); } public static class Minus implements Fomula { Fomula inner; public Minus(Fomula in) { inner = in; } @Override...
[["+", 75, 57, 75, 57, 64, 196, 0, 93, 0, 94], ["+", 75, 57, 75, 57, 64, 196, 0, 93, 0, 35]]
3
948
2
#include <stdio.h> #include <string.h> static const char *e; static int p, q, r; static int expr(void); static int term(void) { int res; switch (*(e++)) { case '-': res = expr(); switch (res) { case 0: res = 2; break; case 2: res = 0; break; } break; case 'P':...
#include <stdio.h> #include <string.h> static const char *e; static int p, q, r; static int expr(void); static int term(void) { int res; switch (*(e++)) { case '-': res = expr(); switch (res) { case 0: res = 2; break; case 2: res = 0; break; } break; case 'P':...
[["-", 0, 100, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 100, 0, 57, 64, 1, 0, 11, 12, 13]]
0
466
2
#include <bits/stdc++.h> using namespace std; string str; int pos, P, Q, R; int formula() { pos = -1; if (str[pos] == '(') { int f = formula(); pos++; if (str[pos] == '*') f = min(f, formula()); if (str[pos] == '+') f = max(f, formula()); pos++; return f; } if (str[pos] ==...
#include <bits/stdc++.h> using namespace std; string str; int pos, P, Q, R; int formula() { pos++; if (str[pos] == '(') { int f = formula(); pos++; if (str[pos] == '*') f = min(f, formula()); if (str[pos] == '+') f = max(f, formula()); pos++; return f; } if (str[pos] == '-...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29]]
1
273
3
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define INF 100000000 using namespace std; string s, t; int a, p; int A(int x) { return x == 2 ? 0 : x == 1 ? 1 : 2; } int B(int x, int y) { return x == 0 || y == 0 ? 0 : x == 1 || y == 1 ? 1 : 2; } int C(int x, int y) { return x == 2 || y == 2 ? ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define INF 100000000 using namespace std; string s, t; int a, p; int A(int x) { return x == 2 ? 0 : x == 1 ? 1 : 2; } int B(int x, int y) { return x == 0 || y == 0 ? 0 : x == 1 || y == 1 ? 1 : 2; } int C(int x, int y) { return x == 2 || y == 2 ? ...
[["+", 0, 57, 64, 9, 0, 57, 64, 37, 0, 38]]
1
426
1
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namesp...
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namesp...
[["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22]]
1
721
2
#include <algorithm> #include <iostream> #include <string> using namespace std; string S, T; int pos; int solve() { if (T[pos] == '0') { pos++; return 0; } if (T[pos] == '1') { pos++; return 1; } if (T[pos] == '2') { pos++; return 2; } if (T[pos] == '-') { pos++; return 2 -...
#include <algorithm> #include <iostream> #include <string> using namespace std; string S, T; int pos; int solve() { if (T[pos] == '0') { pos++; return 0; } if (T[pos] == '1') { pos++; return 1; } if (T[pos] == '2') { pos++; return 2; } if (T[pos] == '-') { pos++; return 2 -...
[["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
373
3
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i, a, b) for (i = a; i < b; ++i) #define rep(i, n) REP(i, 0, n) #define ll long long #define ull unsigned ll typedef long double ld; #define ALL(a) (a).begin(), (a).end() #define ifnot(a) if (not a) #define dump(x) cerr << #...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i, a, b) for (i = a; i < b; ++i) #define rep(i, n) REP(i, 0, n) #define ll long long #define ull unsigned ll typedef long double ld; #define ALL(a) (a).begin(), (a).end() #define ifnot(a) if (not a) #define dump(x) cerr << #...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
1
1,440
2
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; string s; int p, q, r, i; int dfs() { int t[2] = {}, c = 0, m = 0, w = 0, k = 0, a = 0, pp = 0; t[0] = t[1] = -100; if (s[i] == '(') i++; for (; i < s.size(); i++) { pp = 0; if (s[i] == '(') t[c++] = dfs(...
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; string s; int p, q, r, i; int dfs() { int t[2] = {}, c = 0, m = 0, w = 0, k = 0, a = 0, pp = 0; t[0] = t[1] = -100; if (s[i] == '(') i++; for (; i < s.size(); i++) { pp = 0; if (s[i] == '(') t[c++] = dfs(...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 57, 15, 339, 51, 16, 12, 91, 17, 111], ["-", 0, 57, 15, 339, 51, 16, 12, 91, 28, 22]]
1
488
3
#include <bits/stdc++.h> using namespace std; #define State string::const_iterator class ParseError {}; int expression(State &begin); // int term(State &begin); int number(State &begin); int factor(State &begin); int denial(State &begin); void consume(State &begin, char expected); int p, q, r; string input; // 四則演算の...
#include <bits/stdc++.h> using namespace std; #define State string::const_iterator class ParseError {}; int expression(State &begin); // int term(State &begin); int number(State &begin); int factor(State &begin); int denial(State &begin); void consume(State &begin, char expected); int p, q, r; string input; // 四則演算の...
[["-", 64, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 2, 63, 22]]
1
728
2
#include <iostream> #include <string> using namespace std; #define N_MAX 80 string s, s_copy; int ans = 0; int point = 0; char ch(int i) { if (i == 0) return '0'; else if (i == 1) return '1'; else return '2'; } void set(int i, int j, int z) { s_copy = s; int c = s.size(); for (int k = 0; k < c...
#include <iostream> #include <string> using namespace std; #define N_MAX 80 string s, s_copy; int ans = 0; int point = 0; char ch(int i) { if (i == 0) return '0'; else if (i == 1) return '1'; else return '2'; } void set(int i, int j, int z) { s_copy = s; int c = s.size(); for (int k = 0; k < c...
[["+", 8, 9, 0, 100, 0, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 100, 0, 1, 0, 27, 17, 29], ["+", 0, 99, 8, 9, 0, 100, 0, 1, 0, 35]]
1
456
3
#include <cassert> #include <cstdio> #include <iostream> #include <set> using namespace std; string str; int P, Q, R; int Minus(int a) { return 2 - a; } int Prod(int a, int b) { if (a == 0) { return 0; } if (b == 0) { return 0; } if (a == 1) { return 1; } if (b == 1) { return 1; } ...
#include <cassert> #include <cstdio> #include <iostream> #include <set> using namespace std; string str; int P, Q, R; int Minus(int a) { return 2 - a; } int Prod(int a, int b) { if (a == 0) { return 0; } if (b == 0) { return 0; } if (a == 1) { return 1; } if (b == 1) { return 1; } ...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
601
2
#include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cctype> // require tolower, toupper #include <cfloat> #include <climits> #include <cmath> // require fabs #include <cstdio> // require scanf printf #include <cstdlib> // require abs exit atof atoi #include <cstring> // requir...
#include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cctype> // require tolower, toupper #include <cfloat> #include <climits> #include <cmath> // require fabs #include <cstdio> // require scanf printf #include <cstdlib> // require abs exit atof atoi #include <cstring> // requir...
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
1
631
2
#include <bits/stdc++.h> using namespace std; #define EPS (1e-10) typedef complex<double> P; //実数同士の比較 bool EQ(double a, double b) { return (abs(a - b) < EPS); } //二つのベクトルが等しいかどうか bool EQV(P a, P b) { return (EQ(a.real(), b.real()) && EQ(a.imag(), b.imag())); } //内積 double dot(P a, P b) { return (a.real() * b.real...
#include <bits/stdc++.h> using namespace std; #define EPS (1e-10) typedef complex<double> P; //実数同士の比較 bool EQ(double a, double b) { return (abs(a - b) < EPS); } //二つのベクトルが等しいかどうか bool EQV(P a, P b) { return (EQ(a.real(), b.real()) && EQ(a.imag(), b.imag())); } //内積 double dot(P a, P b) { return (a.real() * b.real...
[["-", 51, 16, 12, 16, 12, 2, 63, 118, 119, 120], ["+", 51, 16, 12, 16, 12, 2, 63, 118, 119, 120], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
1,081
4
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <st...
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <st...
[["-", 0, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 9, 0, 43, 49, 50, 51, 2, 63, 22]]
1
1,352
4
#include <stdio.h> int cnt_koisi[50]; int cheak_isi(int nin, int hito) { int h; for (h = 0; h < nin; h++) { if (h != hito) { if (cnt_koisi[h] > 0) return 0; } } return 1; } int main(void) { int n, p, i; int turn = 0; while (1) { scanf("%d %d", &n, &p); if (n == 0 && p == 0...
#include <stdio.h> int cnt_koisi[50]; int cheak_isi(int nin, int hito) { int h; for (h = 0; h < nin; h++) { if (h != hito) { if (cnt_koisi[h] > 0) return 0; } } return 1; } int main(void) { int n, p, i; int turn = 0; while (1) { scanf("%d %d", &n, &p); if (n == 0 && p == 0...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
227
1
answers = [] def get_answer(n, p, answers) owan = p index = 0 temoto = [] n.times do temoto << 0 end while true if owan == 0 owan += temoto[index] temoto[index] = 0 else if owan == 1 && temoto[index] == p -1 answers << index return answers end owan ...
answers = [] def get_answer(n, p, answers) owan = p index = 0 temoto = [] n.times do temoto << 0 end while true if owan == 0 owan += temoto[index] temoto[index] = 0 else if owan == 1 && temoto[index] == p -1 answers << index return answers end owan ...
[["-", 0, 493, 0, 89, 8, 170, 0, 751, 8, 22], ["+", 0, 89, 8, 170, 0, 751, 8, 94, 0, 94]]
4
157
2
import java.io.IOException; import java.util.ArrayDeque; import java.util.Deque; public class Main { public static void main(String[] args) { while (true) { int w = nextInt(); if (w == 0) { break; } int h = nextInt(); int[][] map = new int[h][w]; for (int i = 0; i < ...
import java.io.IOException; import java.util.ArrayDeque; import java.util.Deque; public class Main { public static void main(String[] args) { while (true) { int w = nextInt(); if (w == 0) { break; } int h = nextInt(); int[][] map = new int[h][w]; for (int i = 0; i < ...
[["+", 0, 7, 15, 16, 12, 509, 500, 504, 0, 70], ["+", 0, 7, 15, 16, 12, 509, 500, 504, 71, 22], ["+", 0, 7, 15, 16, 12, 509, 500, 504, 0, 73]]
3
538
3
import java.util.ArrayDeque; import java.util.Scanner; import java.util.Stack; public class Main { public static void main(String[] aaa) { Scanner s = new Scanner(System.in); Stack<Integer> x = new Stack<Integer>(); Stack<Integer> y = new Stack<Integer>(); int h, w, i, j, k, l, count = 0, xx, yy, nx,...
import java.util.ArrayDeque; import java.util.Scanner; import java.util.Stack; public class Main { public static void main(String[] aaa) { Scanner s = new Scanner(System.in); Stack<Integer> x = new Stack<Integer>(); Stack<Integer> y = new Stack<Integer>(); int h, w, i, j, k, l, count = 0, xx, yy, nx,...
[["-", 0, 52, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94], ["-", 0, 52, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["+", 31, ...
3
472
10
import java.util.*; public class Main { static int w; static int h; static int[][] fi; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { w = sc.nextInt(); h = sc.nextInt(); if (w == 0 && h == 0) break; fi = new int[h][w]; ...
import java.util.*; public class Main { static int w; static int h; static int[][] fi; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { w = sc.nextInt(); h = sc.nextInt(); if (w == 0 && h == 0) break; fi = new int[h][w]; ...
[["-", 0, 1, 0, 11, 31, 504, 516, 504, 71, 22], ["+", 0, 1, 0, 11, 31, 504, 516, 504, 71, 22], ["-", 8, 196, 0, 1, 0, 11, 31, 504, 71, 22], ["+", 8, 196, 0, 1, 0, 11, 31, 504, 71, 22], ["-", 0, 16, 31, 16, 31, 16, 12, 16, 17, 19], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 17, 18], ["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 19]...
3
360
12
#include <stdio.h> int h, w; int G[50][50]; void visit(int i, int j) { int di[8] = {0, -1, -1, -1, 0, 1, 1, 1}; int dj[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int r; int ni, nj; G[i][j] = 0; for (r = 0; r < 8; r++) { ni = i + di[r]; nj = j + dj[r]; if (-1 < ni && ni < w && -1 < nj && nj < h && G[...
#include <stdio.h> int h, w; int G[50][50]; void visit(int i, int j) { int di[8] = {0, -1, -1, -1, 0, 1, 1, 1}; int dj[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int r; int ni, nj; G[i][j] = 0; for (r = 0; r < 8; r++) { ni = i + di[r]; nj = j + dj[r]; if (-1 < ni && ni < h && -1 < nj && nj < w && G[...
[["-", 31, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["-", 15, 23, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 15, 23, 0, 16, 31, 16, 12, 16, 12, 22], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0,...
0
325
12
#include <stdio.h> int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1}; int map[52][52]; void foo(int y, int x, int n) { int i; if (map[y][x] == -1) { map[y][x] = n; for (i = 0; i < 8; i++) { foo(x + dx[i], y + dy[i], n); } } } int main() { int w, h, i, j, ans;...
#include <stdio.h> int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1}; int map[52][52]; void foo(int y, int x, int n) { int i; if (map[y][x] == -1) { map[y][x] = n; for (i = 0; i < 8; i++) { foo(y + dy[i], x + dx[i], n); } } } int main() { int w, h, i, j, ans;...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 2, 3, 4, 0, 16, 12, 69, 28, 22], ["+", 0, 2, 3, 4, 0, 16, 12, 69, 28, 22]]
0
387
8
import queue def proceess(start_x,start_y): #insland = [] #insland.append([start_x,start_y]) new_island = queue.Queue() map[start_x][start_y] = 0 new_island.put([start_x,start_y]) while True: ob = new_island.get() x = ob[0] y = ob[1] #print("x : " + str(x) + ", y...
import queue def proceess(start_x,start_y): #print("start_x : " + str(start_x) + ", start_y : " + str(start_y)) #insland = [] #insland.append([start_x,start_y]) new_island = queue.Queue() map[start_x][start_y] = 0 new_island.put([start_x,start_y]) while True: ob = new_island.get() ...
[["-", 0, 57, 15, 679, 31, 679, 12, 666, 0, 22], ["+", 0, 57, 15, 679, 31, 679, 12, 666, 0, 22], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["-", 8, 196, 0, 57, 15, 679, 31, 666, 0, 612], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 612], ["-", 8, 196, 0, 57, 15, 679, 12,...
5
290
12
import sys def dfs(tiles, W, H, x, y): tiles[y][x] = '0' for dx,dy in ((-1,-1), (-1,0), (-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)): if 0<=x+dx<W and 0<=y+dy<H and tiles[y+dy][x+dx]=='1': dfs(tiles, W, H, x+dx, y+dy) return def main(): while True: W,H = [int(x) for x in inp...
import sys def dfs(tiles, W, H, x, y): tiles[y][x] = '0' for dx,dy in ((-1,-1), (-1,0), (-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)): if 0<=x+dx<W and 0<=y+dy<H and tiles[y+dy][x+dx]=='1': dfs(tiles, W, H, x+dx, y+dy) return def main(): while True: W,H = [int(x) for x in inp...
[["-", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
269
4
import sys sys.setrecursionlimit(1<<32) def f(x,y): a[y][x]='0' for dx,dy in[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[1,-1],[-1,1],[1,1]]: dx+=x;dy+=y if 0<=dx<w and 0<=dy<h and a[dy][dx]=='1':f(dx,dy) while 1: w,h=map(int,input().split()) if w==0:break a=[list(input().split()) for _ in[0]...
import sys sys.setrecursionlimit(10000) def f(x,y): a[y][x]='0' for dx,dy in[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[1,-1],[-1,1],[1,1]]: dx+=x;dy+=y if 0<=dx<w and 0<=dy<h and a[dy][dx]=='1':f(dx,dy) while 1: w,h=map(int,input().split()) if w==0:break a=[list(input().split()) for _ in[0]...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 151], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612]]
5
222
4
if __name__ == '__main__': while 1: w,h = list(map(int,input().strip().split())) if w == h ==0:break imap = [list(map(int,input().strip().split())) for _ in range(h)] visited = [] count = 0 for j in range(h): for i in range(w): stack =[] ...
if __name__ == '__main__': while 1: w,h = list(map(int,input().strip().split())) if w == h ==0:break imap = [list(map(int,input().strip().split())) for _ in range(h)] visited = [] count = 0 for j in range(h): for i in range(w): stack =[] ...
[["+", 0, 652, 3, 4, 0, 660, 0, 657, 17, 33], ["+", 0, 652, 3, 4, 0, 660, 0, 657, 12, 612]]
5
640
2
import sys sys.setrecursionlimit(10000) def fill(y,x): global w,h,l if 0<=y<h and 0<=x+1<w and l[y][x+1]==1: l[y][x+1]=0 fill(y,x+1) if 0<=y<h and 0<=x-1<w and l[y][x-1]==1: l[y][x-1]=0 fill(y,x-1) if 0<=y+1<h and 0<=x<w and l[y+1][x]==1: l[y+1][x]=0 fill(...
import sys sys.setrecursionlimit(10000) def fill(y,x): global w,h,l if 0<=y<h and 0<=x+1<w and l[y][x+1]==1: l[y][x+1]=0 fill(y,x+1) if 0<=y<h and 0<=x-1<w and l[y][x-1]==1: l[y][x-1]=0 fill(y,x-1) if 0<=y+1<h and 0<=x<w and l[y+1][x]==1: l[y+1][x]=0 fill(...
[["+", 0, 1, 0, 662, 12, 658, 8, 652, 63, 22], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
544
3
#include <iostream> using namespace std; /*bool check(const int x, const int y, const int LandNum, const int aNodeCol[50][50], const int aXMax, const int aYMax){ if ((x<0 || x >= aXMax) || (y<0 || y >= aYMax) || (aNodeCol[x][y] != 1)){ return false; } return true; }*/ bool LandConfirmedAndMawariCheck(...
#include <iostream> using namespace std; /*bool check(const int x, const int y, const int LandNum, const int aNodeCol[50][50], const int aXMax, const int aYMax){ if ((x<0 || x >= aXMax) || (y<0 || y >= aYMax) || (aNodeCol[x][y] != 1)){ return false; } return true; }*/ bool LandConfirmedAndMawariCheck(...
[["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 69, 2...
1
772
10
#include <algorithm> #include <iostream> using namespace std; int c[50][50]; int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; int ret; int w, h; void dfs(int x, int y) { if (c[x][y] == 0) return; c[x][y] = 0; for (int i = 0; i < 8; i++) { if (x + dx[i] < 0 || x + dx[...
#include <algorithm> #include <iostream> using namespace std; int c[50][50]; int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; int ret; int w, h; void dfs(int x, int y) { if (c[x][y] == 0) return; c[x][y] = 0; for (int i = 0; i < 8; i++) { if (x + dx[i] < 0 || x + dx[...
[["-", 51, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22]]
1
314
4
#define _USE_MATH_DEFINES #include <algorithm> #include <cfloat> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int x, y; int o[52][52]; queue<int> q; void tansaku(int ...
#define _USE_MATH_DEFINES #include <algorithm> #include <cfloat> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int x, y; int o[52][52]; queue<int> q; void tansaku(int ...
[["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
363
2
#include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int area[50][50], cnt = 0; int w, h; void dfs(int x, int y) { area[x][y] = 0; for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { int nx = x + dx, ny = y + dy; if (0 <= nx && nx < w && 0 <=...
#include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int area[50][50], cnt = 0; int w, h; void dfs(int x, int y) { area[x][y] = 0; for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { int nx = x + dx, ny = y + dy; if (0 <= nx && nx < w && 0 <=...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
243
4
#include <iostream> #include <queue> #include <stack> #include <utility> #include <vector> using namespace std; bool find1(vector<vector<int>> &C, vector<vector<int>> &check, int *findh, int *findw) { for (int i = 0; i < C.size(); ++i) for (int j = 0; j < C[0].size(); ++j) if (C[i][j] == 1 && che...
#include <iostream> #include <queue> #include <stack> #include <utility> #include <vector> using namespace std; bool find1(vector<vector<int>> &C, vector<vector<int>> &check, int *findh, int *findw) { for (int i = 0; i < C.size(); ++i) for (int j = 0; j < C[0].size(); ++j) if (C[i][j] == 1 && che...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 152], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 152], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22]]
1
816
6
#include <bits/stdc++.h> using namespace std; const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; int field[51][51]; int h, w; void sol(int x, int y) { field[x][y] = 0; for (int i = 0; i < 8; i++) { if ((0 <= x + dx[i] && x + dx[i] < h) || (0 <= y + dy[i] && y + dy[i] <...
#include <bits/stdc++.h> using namespace std; const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; int field[51][51]; int h, w; void sol(int x, int y) { field[x][y] = 0; for (int i = 0; i < 8; i++) { if ((0 <= x + dx[i] && x + dx[i] < h) || (0 <= y + dy[i] && y + dy[i] <...
[["-", 15, 339, 51, 34, 31, 16, 31, 16, 12, 22], ["-", 0, 52, 15, 339, 51, 34, 31, 16, 17, 152], ["+", 0, 52, 15, 339, 51, 34, 31, 16, 17, 152], ["+", 0, 52, 15, 339, 51, 34, 31, 16, 12, 22]]
1
313
4
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, b) FOR(i, 0, b) int read() { int i; scanf("%lld", &i); return i; } int land[100][100] = {0}; int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dx[] = {-1, 0, 1...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, b) FOR(i, 0, b) int read() { int i; scanf("%lld", &i); return i; } int land[100][100] = {0}; int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dx[] = {-1, 0, 1...
[["-", 64, 9, 0, 9, 0, 43, 49, 50, 49, 22], ["+", 64, 9, 0, 9, 0, 43, 49, 50, 49, 22]]
1
347
4
#include <iostream> #include <vector> using namespace std; int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1}; bool dfs(int sx, int sy, vector<vector<bool>> &c) { if (c[sx][sy] == false) return false; c[sx][sy] = false; for (int i = 0; i < 8; i++) { int nx = sx + dx[i]; ...
#include <iostream> #include <vector> using namespace std; int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1}; bool dfs(int sx, int sy, vector<vector<bool>> &c) { if (c[sx][sy] == false) return false; c[sx][sy] = false; for (int i = 0; i < 8; i++) { int nx = sx + dx[i]; ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["-", 51, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 51, 4, 0, 2, 3, 4, 0, 16, 31, 22]]
1
330
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef vector<int> VI; typedef vector<vector<in...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef vector<int> VI; typedef vector<vector<in...
[["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13]]
1
378
2
#include <iostream> #include <vector> using namespace std; const int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; void dfs(int x, int y, vector<vector<bool>> &canGo) { canGo[x][y] = false; for (int i = 0; i < 9; i++) if (canGo[x + dx[i]][y + dy[i]]) dfs(x + dx[i], y ...
#include <iostream> #include <vector> using namespace std; const int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; void dfs(int x, int y, vector<vector<bool>> &canGo) { canGo[x][y] = false; for (int i = 0; i < 8; i++) if (canGo[x + dx[i]][y + dy[i]]) dfs(x + dx[i], y ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
333
2
#include <bits/stdc++.h> using namespace std; char a[50][50]; void calc(int i, int j) { if (a[i][j] == '1') { a[i][j] = 2; calc(i + 1, j); calc(i, j + 1); calc(i + 1, j + 1); calc(i + 1, j - 1); calc(i - 1, j); calc(i, j - 1); calc(i - 1, j - 1); calc(i - 1, j + 1); } else re...
#include <bits/stdc++.h> using namespace std; int a[500][500]; void calc(int i, int j) { if (a[i][j] == 1) { a[i][j] = 2; calc(i + 1, j); calc(i, j + 1); calc(i + 1, j + 1); calc(i + 1, j - 1); calc(i - 1, j); calc(i, j - 1); calc(i - 1, j - 1); calc(i - 1, j + 1); } else ret...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 104]]
1
284
10
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) using namespace std; typedef long long ll; int INF = (1LL << 30) - 1; int MOD = 1e9 + 7; int H, W; void dfs(int h, int w, vector<vector<int>> &table) { // cout << h << " " << w << endl; table[h][w] = 0; int dx[] = {-1, -1, -1, 0, ...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) using namespace std; typedef long long ll; int INF = (1LL << 30) - 1; int MOD = 1e9 + 7; int H, W; void dfs(int h, int w, vector<vector<int>> &table) { // cout << h << " " << w << endl; table[h][w] = 0; int dx[] = {-1, -1, -1, 0, ...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
331
4
// Tue Dec 22 22:01:34 JST 2009 #include <iostream> #include <queue> #include <set> using namespace std; #define REP(i, b, n) for (int i = b; i < n; i++) #define rep(i, n) REP(i, 0, n) #define mp make_pair int dx[] = {0, 1, 1, 0, -1, -1}; int dy[] = {-1, -1, 0, 1, 1, 0}; #define CONNECT true #define UNCONNECT false #de...
// Tue Dec 22 22:01:34 JST 2009 #include <iostream> #include <queue> #include <set> using namespace std; #define REP(i, b, n) for (int i = b; i < n; i++) #define rep(i, n) REP(i, 0, n) #define mp make_pair int dx[] = {0, 1, 1, 0, -1, -1}; int dy[] = {-1, -1, 0, 1, 1, 0}; #define CONNECT true #define UNCONNECT false #de...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 13], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 17, 85], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 12, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13]]
1
952
6
import java.util.Scanner; public class Main { public static final long mod7 = 1000000007L; static int[][] map; static int sx, sy, ex, ey, h, w; static int[][] dir = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (run(sc)) { ...
import java.util.Scanner; public class Main { public static final long mod7 = 1000000007L; static int[][] map; static int sx, sy, ex, ey, h, w; static int[][] dir = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (run(sc)) { ...
[["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 146], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
3
586
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int w, h; int sx, sy; int res; int table[30]...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int w, h; int sx, sy; int res; int table[30]...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
1
430
2
using namespace std; #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #incl...
using namespace std; #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #incl...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
1,299
1
#include <algorithm> #include <iostream> using namespace std; int w, h; int G[100][100]; int sx, sy; int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, -1, 1}; int ans; void dfs(int px, int py, int cnt) { if (cnt > 10) return; for (int i = 0; i < 4; i++) { int nx = px + dx[i], ny = py + dy[i]; if (!(0 <= nx && ...
#include <algorithm> #include <iostream> using namespace std; int w, h; int G[100][100]; int sx, sy; int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, -1, 1}; int ans; void dfs(int px, int py, int cnt) { if (cnt > 10) return; for (int i = 0; i < 4; i++) { int nx = px + dx[i], ny = py + dy[i]; if (!(0 <= nx && ...
[["+", 64, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
378
5
#include <math.h> #include <stdio.h> void main() { int x[200], y[200]; int i, N, ni, di; int xMax, yMax, xMin, yMin; x[0] = y[0] = 0; while (1) { xMax = yMax = xMin = xMax = 0; scanf("%d", &N); if (N == 0) break; for (i = 1; i < N; i++) { scanf("%d%d", &ni, &di); x[i] =...
#include <math.h> #include <stdio.h> void main() { int x[200], y[200]; int i, N, ni, di; int xMax, yMax, xMin, yMin; x[0] = y[0] = 0; while (1) { xMax = yMax = xMin = yMin = 0; scanf("%d", &N); if (N == 0) break; for (i = 1; i < N; i++) { scanf("%d%d", &ni, &di); x[i] =...
[["-", 0, 11, 12, 11, 12, 11, 12, 11, 31, 22], ["+", 0, 11, 12, 11, 12, 11, 12, 11, 31, 22]]
0
278
2
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; class rectangle { private: int name, x, y; public: rectangle(int name, int x, int y) : name(name), x(x), y(y) {} int getX() { return x; } int getY() { return y; } }; int main() { int N; int n, d; int x, y; ...
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; class rectangle { private: int name, x, y; public: rectangle(int name, int x, int y) : name(name), x(x), y(y) {} int getX() { return x; } int getY() { return y; } }; int main() { int N; int n, d; int x, y; ...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
415
5
#include <algorithm> #include <iostream> #include <utility> using namespace std; typedef pair<int, int> P; int main() { int n; while (cin >> n) { P a[300]; a[0] = P(0, 0); for (int i = 1; i < n; i++) { int m, d; cin >> m >> d; if (d == 0) { a[i] = P(a[m].first - 1, a[m].second...
#include <algorithm> #include <iostream> #include <utility> using namespace std; typedef pair<int, int> P; int main() { int n; while (cin >> n, n) { P a[300]; a[0] = P(0, 0); for (int i = 1; i < n; i++) { int m, d; cin >> m >> d; if (d == 0) { a[i] = P(a[m].first - 1, a[m].sec...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
318
2
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <stack> #include <string> #include <vector> using namespace std; int N; int main() { while (cin >> N, N) { vector<pair<int, int>> vp; vp.push_back({0, 0}); for (int i = 1; i < N; ++i) { int n, d; ...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <stack> #include <string> #include <vector> using namespace std; int N; int main() { while (cin >> N, N) { vector<pair<int, int>> vp; vp.push_back({0, 0}); for (int i = 1; i < N; ++i) { int n, d; ...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
363
2
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int n; struct PLACE { int r; int l; int u; int d; }; void solve() { PLACE place[n + 1]; int target, cmd; // 0を基準としそれよりもどのくらい離れているか int maxR = 0; int maxL = 0; int maxU = 0; int maxD = 0; place[0]....
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int n; struct PLACE { int r; int l; int u; int d; }; void solve() { PLACE place[n + 1]; int target, cmd; // 0を基準としそれよりもどのくらい離れているか int maxR = 0; int maxL = 0; int maxU = 0; int maxD = 0; place[0]....
[["-", 0, 100, 0, 1, 0, 11, 12, 11, 17, 32], ["+", 0, 100, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 100, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 100, 0, 1, 0, 11, 12, 16, 12, 13]]
1
515
4
#include <iostream> #include <vector> using namespace std; struct pos { int x; int y; }; int main() { int n, n1, d1; int left, right, up, down; pos setpos; vector<pos> position; vector<pos>::iterator posit; while (1) { cin >> n; if (n == 0) break; //初期化 left = 0; right = 0;...
#include <iostream> #include <vector> using namespace std; struct pos { int x; int y; }; int main() { int n, n1, d1; int left, right, up, down; pos setpos; vector<pos> position; vector<pos>::iterator posit; while (1) { cin >> n; if (n == 0) break; //初期化 left = 0; right = 0;...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131]]
1
399
6
dx,dy = [-1,0,1,0],[0,-1,0,1] while True: N = eval(input()) if N == 0: break x,y = [0]*N,[0]*N for i in range(N-1): n,d = list(map(int,input().split())) x[i] = x[n] + dx[d] y[i] = y[n] + dy[d] print(max(x) - min(x) + 1, max(y) - min(y) + 1)
dx,dy = [-1,0,1,0],[0,-1,0,1] while True: N = eval(input()) if N == 0: break x,y = [0]*N,[0]*N for i in range(1,N): n,d = list(map(int,input().split())) x[i] = x[n] + dx[d] y[i] = y[n] + dy[d] print(max(x) - min(x) + 1, max(y) - min(y) + 1)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
140
4
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter ...
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter ...
[["+", 0, 492, 3, 4, 0, 510, 75, 16, 17, 72], ["+", 0, 492, 3, 4, 0, 510, 75, 16, 12, 499]]
3
2,066
2
from copy import deepcopy while True: w, h = map(int, input().split()) if w == 0: break wwal = [] # | hwal = [] # ー a = [0] * w b = [] for i in range(2 * h - 1): if i % 2 == 0: wwal.append(list(map(int, input().split()))) c = deepcopy(a) ...
from copy import deepcopy while True: w, h = map(int, input().split()) if w == 0: break wwal = [] # | hwal = [] # ー a = [0] * w b = [] for i in range(2 * h - 1): if i % 2 == 0: wwal.append(list(map(int, input().split()))) c = deepcopy(a) ...
[["-", 0, 52, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
668
4
def bfs(maze): d = [[0] * 70 for i in range(70)] d[1][1] = 1 que = [(1, 1)] while 0 < len(que): new_que = [] for x, y in que: if x == 2 * w - 1 and y == 2 * h - 1: return d[y][x] for dx, dy in ((0, 1), (-1, 0), (0, -1), (1, 0)): mx,...
def bfs(maze): d = [[0] * 70 for i in range(70)] d[1][1] = 1 que = [(1, 1)] while 0 < len(que): new_que = [] for x, y in que: if x == 2 * w - 1 and y == 2 * h - 1: return d[y][x] for dx, dy in ((0, 1), (-1, 0), (0, -1), (1, 0)): mx,...
[["+", 12, 658, 8, 657, 12, 23, 0, 657, 17, 72], ["+", 12, 658, 8, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
417
4
from collections import deque while True: W,H = map(int, input().split()) if W == 0: break es = [[] for i in range(W*H)] for y in range(H): walls_h = map(int, input().split()) for x in range(W-1): if walls_h[x]: continue es[y*W + x].append(y*W + x+1) e...
from collections import deque while True: W,H = map(int, input().split()) if W == 0: break es = [[] for i in range(W*H)] for y in range(H): walls_h = list(map(int, input().split())) for x in range(W-1): if walls_h[x]: continue es[y*W + x].append(y*W + x+1) ...
[["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
276
6
#include <stdio.h> #include <stdlib.h> #define MAX 1000000 - 1 int main() { int n, i, input; int tn, tmp; int tetra_n[181]; int *tetra_sum, *tetra_sum_odd; char a[10]; for (n = 0; n <= 180; n++) tetra_n[n] = n * (n + 1) * (n + 2) / 6; tetra_sum = (int *)malloc(sizeof(int) * (MAX + 1)); tetra_sum_odd...
#include <stdio.h> #include <stdlib.h> #define MAX 1000000 - 1 int main() { int n, i, input; int tn, tmp; int tetra_n[181]; int *tetra_sum, *tetra_sum_odd; char a[10]; for (n = 0; n <= 180; n++) tetra_n[n] = n * (n + 1) * (n + 2) / 6; tetra_sum = (int *)malloc(sizeof(int) * (MAX + 1)); tetra_sum_odd...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
377
2
#include <stdio.h> #define min(a, b) a < b ? a : b int main() { int n; int i, j; int c; int a[1000001]; int b[1000001]; for (i = 0; i < 1000001; i++) { a[i] = i; b[i] = i; } for (i = 3, c = 4; i < 1000001; i++) { for (j = c; j < 1000001; j++) { a[j] = min(a[j], a[j - c] + 1); } ...
#include <stdio.h> #define min(a, b) a < b ? a : b int main() { int n; int i, j; int c; int a[1000001]; int b[1000001]; for (i = 0; i < 1000001; i++) { a[i] = i; b[i] = i; } for (i = 3, c = 4; c < 1000001; i++) { for (j = c; j < 1000001; j++) { a[j] = min(a[j], a[j - c] + 1); } ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 57, 64, 9, 0, 7, 10, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 10, 11, 12, 22]]
0
224
4
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int INF = (1LL << 30) - 1; int MOD = 1e9 + 7; int MAX_NUM = 1000000; main() { vector<int> V, W; for (int i = 1; i * (i + 1) * (i + 2) / 6 <= MAX_NUM; i++) { in...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int INF = (1LL << 30) - 1; int MOD = 1e9 + 7; int MAX_NUM = 1000000; main() { vector<int> V, W; for (int i = 1; i * (i + 1) * (i + 2) / 6 <= MAX_NUM; i++) { in...
[["-", 0, 69, 341, 342, 0, 16, 12, 69, 28, 22], ["+", 0, 69, 341, 342, 0, 16, 12, 69, 28, 22]]
1
340
2
#include <bits/stdc++.h> using namespace std; int all[1000001]; int odd[1000001]; int const INF = 1 << 29; int main() { fill(all, all + 1000001, INF); fill(odd, odd + 1000001, INF); all[0] = odd[0] = 0; for (int i = 1;; i++) { int n = i * (i + 1) * (i + 2); if (n > 1000000) break; for (...
#include <bits/stdc++.h> using namespace std; int all[1000001]; int odd[1000001]; int const INF = 1 << 29; int main() { fill(all, all + 1000001, INF); fill(odd, odd + 1000001, INF); all[0] = odd[0] = 0; for (int i = 1;; i++) { int n = i * (i + 1) * (i + 2) / 6; if (n > 1000000) break; f...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 85], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
206
2
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define INF 1000000 using namespace std; typedef list<int> L; typedef pair<int, int> P; typedef vector<int> V; typedef queue<int> Q; type...
#include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define INF 1000000 using namespace std; typedef list<int> L; typedef pair<int, int> P; typedef vector<int> V; typedef queue<int> Q; type...
[["-", 0, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]]
1
407
4
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #defin...
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #defin...
[["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13]]
1
429
2
#include <algorithm> #include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; const int INF = 1 << 29; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int main() { for (int h, w; scanf("%d%d", &h, &w), h;) { int hor[50][50], ver[50][50]; rep(i, h) { rep(j, w - 1) ...
#include <algorithm> #include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; const int INF = 1 << 29; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int main() { for (int h, w; scanf("%d%d", &w, &h), h;) { int hor[50][50], ver[50][50]; rep(i, h) { rep(j, w - 1) ...
[["-", 15, 34, 31, 2, 3, 4, 0, 66, 28, 22], ["+", 15, 34, 31, 2, 3, 4, 0, 66, 28, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33]]
1
384
8
#include <cstdio> #include <cstdlib> #include <iostream> #define BUFFER_SIZE 1024 int bfs(int sx, int sy); const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; struct queue { int buffer[BUFFER_SIZE]; int head; int tail; }; void init(struct queue *q) { q->head = 0; q->tail = -1; } void enqueue(struct queu...
#include <cstdio> #include <cstdlib> #include <iostream> #define BUFFER_SIZE 1024 int bfs(int sx, int sy); const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; struct queue { int buffer[BUFFER_SIZE]; int head; int tail; }; void init(struct queue *q) { q->head = 0; q->tail = -1; } void enqueue(struct queu...
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
877
2
#include <iostream> #include <queue> #include <vector> #define INF (1 << 29) using namespace std; const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {-1, 0, 1, 0}; int main() { int H, W, T; vector<vector<vector<bool>>> M; while (true) { cin >> W >> H; if (W == 0 && H == 0) { break; } ...
#include <iostream> #include <queue> #include <vector> #define INF (1 << 29) using namespace std; const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {-1, 0, 1, 0}; int main() { int H, W, T; vector<vector<vector<bool>>> M; while (true) { cin >> W >> H; if (W == 0 && H == 0) { break; } ...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
1
645
2
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main() { while (true) { int w, h; cin >> w >> h; if (w == 0 && h == 0) { break; } vector<vector<int>> tatekabe(h, vector...
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main() { while (true) { int w, h; cin >> w >> h; if (w == 0 && h == 0) { break; } vector<vector<int>> tatekabe(h, vector...
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 126, 0, 127], ["+", 8, 9, 0, 57, 64, 9, 0, 126, 128, 129], ["+", 8, 9, 0, 52, 8, 9, 0, 97, 128, 129], ["+", 8, 9, 0, 52, 8, 9, 0, 97, 0, 102], ["+", 0, 52, 8, 9, 0, 97, 0, 1, 0, 35]]
1
604
6
#include <iostream> #include <queue> using namespace std; int main() { int w, h; int map [30] [30]; //?£???????,???,???,??????????????????????????????1,2,4,8???????????? while (cin >> w >> h && w > 0 && h > 0) { for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) map[i][j] = 0;...
#include <iostream> #include <queue> using namespace std; int main() { int w, h; int map [30] [30]; //?£???????,???,???,??????????????????????????????1,2,4,8???????????? while (cin >> w >> h && w > 0 && h > 0) { for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) map[i][j] = 0;...
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
551
2
#include <iostream> #include <queue> using namespace std; int w, h, a, ans, tx, ty; bool map[62][62]; int lap[62][62]; struct Node { int x, y, d; Node(int a, int b, int c) { x = a; y = b; d = c; } }; typedef struct Node node; int main() { //??\????????????????????§??????????????????????????¨????...
#include <iostream> #include <queue> using namespace std; int w, h, a, ans, tx, ty; bool map[62][62]; int lap[62][62]; struct Node { int x, y, d; Node(int a, int b, int c) { x = a; y = b; d = c; } }; typedef struct Node node; int main() { //??\????????????????????§??????????????????????????¨????...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 85], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
874
2
#include <bits/stdc++.h> using namespace std; #define INF 1000000 // aizu 200??? //??±???????????¢?´¢??§?????????????????? //???????????????????????¢?´¢??§???????????? int h, w; int di[4] = {0, 1, 0, -1}; int dj[4] = {1, 0, -1, 0}; int main() { while (1) { cin >> w >> h; if (w == 0) break; vector<...
#include <bits/stdc++.h> using namespace std; #define INF 1000000 // aizu 200??? //??±???????????¢?´¢??§?????????????????? //???????????????????????¢?´¢??§???????????? int h, w; int di[4] = {0, 1, 0, -1}; int dj[4] = {1, 0, -1, 0}; int main() { while (1) { cin >> w >> h; if (w == 0) break; vector<...
[["+", 8, 9, 0, 57, 64, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 57, 64, 1, 0, 16, 12, 22]]
1
529
2
#include <iostream> #include <queue> #include <string.h> using namespace std; typedef pair<int, int> P; bool wall[30][30][4]; int dis[30][30]; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1}; int main() { while (true) { int n, m; cin >> n >> m; if (n == 0 && m == 0) break; memset(wall, 0,...
#include <iostream> #include <queue> #include <string.h> using namespace std; typedef pair<int, int> P; bool wall[30][30][4]; int dis[30][30]; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1}; int main() { while (true) { int n, m; cin >> n >> m; if (n == 0 && m == 0) break; memset(wall, 0,...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
538
2
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <ut...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <ut...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
994
2
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int, int> pii; class...
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int, int> pii; class...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
521
2
#include <bits/stdc++.h> #include <cxxabi.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; #define rep(i, n) range(i, 0, n) #define range(i, a, n) for (int i = a; i < n; i++) #define all(a) a.begin(), a.end() #define LINF ((ll)1ll < 60) #define IN...
#include <bits/stdc++.h> #include <cxxabi.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; #define rep(i, n) range(i, 0, n) #define range(i, a, n) for (int i = a; i < n; i++) #define all(a) a.begin(), a.end() #define LINF ((ll)1ll < 60) #define IN...
[["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
1,076
2
#include <algorithm> #include <queue> #include <stdio.h> using namespace std; char str[60][11]; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int S[60][11]; int e[200][200]; int L[200]; int R[200]; int Z[200]; int p; bool ret; struct wolf { int v[10]; wolf() { for (int i = 0; i < 10; i++) v[i] = 0; ...
#include <algorithm> #include <queue> #include <stdio.h> using namespace std; char str[60][11]; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int S[60][11]; int e[200][200]; int L[200]; int R[200]; int Z[200]; int p; bool ret; struct wolf { int v[10]; wolf() { for (int i = 0; i < 10; i++) v[i] = 0; ...
[["-", 0, 7, 8, 7, 8, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 7, 8, 7, 15, 16, 12, 13]]
1
1,150
2
#include <algorithm> #include <array> #include <iostream> #include <numeric> using namespace std; #define all(c) (c).begin(), (c).end() template <class ForwardIt> pair<ForwardIt, ForwardIt> sieve(ForwardIt begin, ForwardIt end) { return make_pair( begin, (*begin) * (*begin) <= *end ? sieve(be...
#include <algorithm> #include <array> #include <iostream> #include <numeric> using namespace std; #define all(c) (c).begin(), (c).end() template <class ForwardIt> pair<ForwardIt, ForwardIt> sieve(ForwardIt begin, ForwardIt end) { return make_pair( begin, (*begin) * (*begin) <= *(end - 1) ? si...
[["+", 0, 41, 15, 16, 12, 66, 28, 23, 0, 24], ["+", 15, 16, 12, 66, 28, 23, 0, 16, 17, 33], ["+", 15, 16, 12, 66, 28, 23, 0, 16, 12, 13], ["+", 0, 41, 15, 16, 12, 66, 28, 23, 0, 25]]
1
187
29
#include <bits/stdc++.h> using namespace std; #define for_(i, a, b) for (int i = (a); i < (b); ++i) int isp[300000], cnt[300000]; int main() { memset(cnt, 0, sizeof(cnt)); memset(isp, 0, sizeof(isp)); for_(i, 2, 300000) { if (isp[i] == 0) { ++cnt[i]; for (int j = 2 * i; j < 300000; j += i) ...
#include <bits/stdc++.h> using namespace std; #define for_(i, a, b) for (int i = (a); i < (b); ++i) int isp[300000], cnt[300000]; int main() { memset(cnt, 0, sizeof(cnt)); memset(isp, 0, sizeof(isp)); for_(i, 2, 300000) { if (isp[i] == 0) { ++cnt[i]; for (int j = 2 * i; j < 300000; j += i) ...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
148
2