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 <iostream> #define N 10 using namespace std; /* Hanafuda Shuffle http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1129&lang=jp */ int array[N]; void makearray(int n) { for (int i = 0; i < N; i++) { array[i] = n; if (n > 0) n -= 1; } } void shuffle(int p, int c) { int sarray[N]; /...
#include <iostream> #define N 50 using namespace std; /* Hanafuda Shuffle http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1129&lang=jp */ int array[N]; void makearray(int n) { for (int i = 0; i < N; i++) { array[i] = n; if (n > 0) n -= 1; } } void shuffle(int p, int c) { int sarray[N]; /...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
290
2
#include <stdio.h> int n, r, p, c, d[50], e[50]; int main() { while (true) { scanf("%d%d", &n, &r); if (n == 0 && r == 0) break; for (int i = 0; i < n; i++) d[i] = n - i; for (int i = 0; i < r; i++) { scanf("%d%d", &p, &c); for (int j = 0; j < c; j++) { e[j] = d[j + p];...
#include <stdio.h> int n, r, p, c, d[50], e[50]; int main() { while (true) { scanf("%d%d", &n, &r); if (n == 0 && r == 0) break; for (int i = 0; i < n; i++) d[i] = n - i; for (int i = 0; i < r; i++) { scanf("%d%d", &p, &c); p--; for (int j = 0; j < c; j++) { e[j] ...
[["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
212
3
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) using namespace std; int main() { int n, r, c, p, ar[50]; while (cin >> n >> r) { if (n == 0 && r == 0) return 0; for (int i = 0; i < n; i++) ar[i] = n - i; for (int i = 0; i < r; i++) { cin >> p >> c; i...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) using namespace std; int main() { int n, r, c, p, ar[50]; while (cin >> n >> r) { if (n == 0 && r == 0) return 0; for (int i = 0; i < n; i++) ar[i] = n - i; for (int i = 0; i < r; i++) { cin >> p >> c; i...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
247
2
#include <iostream> #include <utility> using namespace std; int main() { int n, r, p, c; int card[50]; int ncard[50]; cin >> n >> r; while (n || r) { for (int i = 0; i < n; ++i) { card[i] = i; ncard[i] = i; } for (int i = 0; i < r; ++i) { cin >> p >> c; for (int j = 0; j <...
#include <iostream> #include <utility> using namespace std; int main() { int n, r, p, c; int card[50]; int ncard[50]; cin >> n >> r; while (n || r) { for (int i = 0; i < n; ++i) { card[i] = i; ncard[i] = i; } for (int i = 0; i < r; ++i) { cin >> p >> c; for (int j = 0; j <...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
232
4
#include <iostream> using namespace std; int main() { int a[51] = {}; int st[51] = {}; int n, r; int p, c; while (1) { // in cin >> n >> r; if (n == 0 && r == 0) break; for (int i = 0; i < n; i++) { a[i] = n - i; } for (int i = 0; i < r; i++) { cin >> p >> c; fo...
#include <iostream> using namespace std; int main() { int a[51] = {}; int st[51] = {}; int n, r; int p, c; while (1) { // in cin >> n >> r; if (n == 0 && r == 0) break; for (int i = 0; i < n; i++) { a[i] = n - i; } for (int i = 0; i < r; i++) { cin >> p >> c; fo...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
210
4
#include <bits/stdc++.h> using namespace std; #define first fs #define second se #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < n; ++i) using pii = pair<int, int>; using vi = vector<int>; using lint = long long; const int inf = 1001001001; const lint linf = 1001001001001001001ll; const int m...
#include <bits/stdc++.h> using namespace std; #define first fs #define second se #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < n; ++i) using pii = pair<int, int>; using vi = vector<int>; using lint = long long; const int inf = 1001001001; const lint linf = 1001001001001001001ll; const int m...
[["-", 31, 69, 28, 2, 3, 4, 0, 16, 31, 22], ["-", 31, 69, 28, 2, 3, 4, 0, 16, 17, 72], ["-", 31, 69, 28, 2, 3, 4, 0, 16, 12, 22], ["+", 28, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 28, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 28, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 28, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 28, 2, 3, 4, ...
1
471
8
#include <iostream> using namespace std; #include <vector> int main() { while (1) { int n, r; cin >> n >> r; if (n == 0 && r == 0) break; vector<int> a(n); for (int i = 0; i < n; i++) { a[i] = n - i - 1; } for (int i = 0; i < r; i++) { int p, c; cin >> p >> c; ...
#include <iostream> using namespace std; #include <vector> int main() { while (1) { int n, r; cin >> n >> r; if (n == 0 && r == 0) break; vector<int> a(n); for (int i = 0; i < n; i++) { a[i] = n - i - 1; } for (int i = 0; i < r; i++) { int p, c; cin >> p >> c; ...
[["+", 15, 339, 51, 16, 12, 16, 31, 16, 17, 33], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13]]
1
204
2
#include <algorithm> #include <iostream> #include <numeric> #include <queue> #include <string> using namespace std; int main() { int n, r; while (cin >> n >> r, n | r) { vector<int> now(100), next(100); for (int i = 0; i < n; i++) { now[n - 1 - i] = i + 1; } for (int i = 0; i < r; i++) { ...
#include <algorithm> #include <iostream> #include <numeric> #include <queue> #include <string> using namespace std; int main() { int n, r; while (cin >> n >> r, n | r) { vector<int> now(100), next(100); for (int i = 0; i < n; i++) { now[n - 1 - i] = i + 1; } for (int i = 0; i < r; i++) { ...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
199
2
#include <bits/stdc++.h> #define FOR(i, a, b) for (long long int i = (a); i <= (b); i++) #define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--) #define MOD 1000000007 #define INF 1000000000 // 2000000000 #define LLINF 1000000000000000000 // 9000000000000000000 #define PI 3.14159265358979 using na...
#include <bits/stdc++.h> #define FOR(i, a, b) for (long long int i = (a); i <= (b); i++) #define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--) #define MOD 1000000007 #define INF 1000000000 // 2000000000 #define LLINF 1000000000000000000 // 9000000000000000000 #define PI 3.14159265358979 using na...
[["-", 31, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
1
241
4
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, n) fo...
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, n) fo...
[["-", 12, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 12, 69, 341, 342, 0, 16, 31, 16, 31, 22]]
1
288
2
#include <bits/stdc++.h> using namespace std; #define inf 1e9 #define ll long long #define ull unsigned long long #define M 1000000007 #define P pair<int, int> #define PLL pair<ll, ll> #define FOR(i, m, n) for (int i = m; i < n; i++) #define RFOR(i, m, n) for (int i = m; i >= n; i--) #define rep(i, n) FOR(i, 0, n) #def...
#include <bits/stdc++.h> using namespace std; #define inf 1e9 #define ll long long #define ull unsigned long long #define M 1000000007 #define P pair<int, int> #define PLL pair<ll, ll> #define FOR(i, m, n) for (int i = m; i < n; i++) #define RFOR(i, m, n) for (int i = m; i >= n; i--) #define rep(i, n) FOR(i, 0, n) #def...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
278
6
#include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) int main() { int yama[51]; int n, r; int tmp[51]; while (std::cin >> n >> r && (n || r)) { int c, p; rep(i, n) { yama[i] = n - i; } rep(i, r) { std::cin >> p >> c; rep(j, c) { tmp[j] = yama[p - 1 + j]; } rep(k, p ...
#include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) int main() { int yama[51]; int n, r; int tmp[51]; while (std::cin >> n >> r && (n || r)) { int c, p; rep(i, n) { yama[i] = n - i; } rep(i, r) { std::cin >> p >> c; rep(j, c) { tmp[j] = yama[p - 1 + j]; } rep(k, p ...
[["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
176
4
#include <algorithm> #include <iostream> #include <utility> #include <vector> using namespace std; int solve(int n, int r) { vector<pair<int, int>> p; for (int i = 0; i < r; i++) { int a, b; cin >> a >> b; p.push_back(make_pair(a, b)); } reverse(p.begin(), p.end()); int x = n; for (vector<pai...
#include <algorithm> #include <iostream> #include <utility> #include <vector> using namespace std; int solve(int n, int r) { vector<pair<int, int>> p; for (int i = 0; i < r; i++) { int a, b; cin >> a >> b; p.push_back(make_pair(a, b)); } reverse(p.begin(), p.end()); int x = n; for (vector<pai...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
247
2
#include <iostream> using namespace std; int card[50]; int buffer[50]; int main() { int n, r; while (cin >> n >> r, n != 0) { for (int i = 0; i < n; i++) card[i] = i + 1; for (int i = 0; i < r; i++) { int p, c; cin >> p >> c; for (int j = 0; j < p - 1; j++) buffer[j] = card[j...
#include <iostream> using namespace std; int card[50]; int buffer[50]; int main() { int n, r; while (cin >> n >> r, n != 0) { for (int i = 0; i < n; i++) card[i] = n - i; for (int i = 0; i < r; i++) { int p, c; cin >> p >> c; for (int j = 0; j < p - 1; j++) buffer[j] = card[j...
[["+", 0, 7, 8, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 7, 8, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 7, 8, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 7, 8, 1, 0, 11, 12, 16, 12, 13]]
1
187
4
#include <iostream> using namespace std; int main() { int card[50], tmp[50]; int n, r, p, c; while (cin >> n >> r, n) { for (int i = 0; i < n; i++) card[i] = n - i; for (int x = 0; x < r; x++) { cin >> p >> c; for (int i = 0; i < c; i++) tmp[i] = card[p - 1 + i]; for (i...
#include <iostream> using namespace std; int main() { int card[50], tmp[50]; int n, r, p, c; while (cin >> n >> r, n) { for (int i = 0; i < n; i++) card[i] = n - i; for (int x = 0; x < r; x++) { cin >> p >> c; for (int i = 0; i < c; i++) tmp[i] = card[p - 1 + i]; for (i...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
178
2
#include <climits> #include <cstdio> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int n, r, p, c; int before[50], after[50]; void init() { for (int i = 0; i < 50; i++) before[i] = after[i] = 0; } bool input() { int i; cin >> n; cin >> r; ...
#include <climits> #include <cstdio> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int n, r, p, c; int before[50], after[50]; void init() { for (int i = 0; i < 50; i++) before[i] = after[i] = 0; } bool input() { int i; cin >> n; cin >> r; ...
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
303
2
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <ctype.h> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #includ...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <ctype.h> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #includ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
1
365
4
import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); for (int i = 0; i < n; i++) { int x = 0; int y = 0; ...
import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); for (int i = 0; i < n; i++) { int x = 0; int y = 0; ...
[["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 17, 32], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35]]
3
224
4
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; int N; ll twi(ll a) { return a * a; } int main() { cin >> N; for (int t = 0; t < N; t++) { int x = 0, y = 0; int dx, dy; ll maxk = 0; int ax = ...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; int N; ll twi(ll a) { return a * a; } int main() { cin >> N; for (int t = 0; t < N; t++) { int x = 0, y = 0; int dx, dy; ll maxk = 0; int ax = ...
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 98]]
1
197
2
import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; import java.util.Stack; import java.util.TreeSet; // Pile Up! public class Main { void run() { Scanner sc = new Scanner(System.in); for (;;) { int n = sc.nextInt(); if (n == 0) br...
import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; import java.util.Stack; import java.util.TreeSet; // Pile Up! public class Main { void run() { Scanner sc = new Scanner(System.in); for (;;) { int n = sc.nextInt(); if (n == 0) br...
[["-", 0, 57, 15, 15, 0, 16, 31, 492, 141, 22], ["+", 0, 57, 15, 15, 0, 16, 31, 492, 141, 22], ["+", 15, 15, 0, 16, 31, 492, 3, 4, 0, 499]]
3
775
3
#include <stdio.h> #include <stdlib.h> int cube_all; int cube_num[100]; int cube_map[100][100]; int cube_where[100]; /* syo-zyun */ int qsort_comp(const void *x, const void *y) { int *a = (int *)x; int *b = (int *)y; if (*a > *b) return 1; if (*a < *b) return -1; return 0; } int main(void) { int ...
#include <stdio.h> #include <stdlib.h> int cube_all; int cube_num[100]; int cube_map[100][100]; int cube_where[100]; /* syo-zyun */ int qsort_comp(const void *x, const void *y) { int *a = (int *)x; int *b = (int *)y; if (*a > *b) return 1; if (*a < *b) return -1; return 0; } int main(void) { int ...
[["-", 64, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["-", 64, 9, 0, 7, 10, 11, 12, 16, 12, 13]]
0
677
2
#include <bits/stdc++.h> using namespace std; int aidx, ah, bidx, bh; vector<int> pile[105]; int m; void put_floor(int x) { for (int i = 0; i < m; i++) if (!pile[i].size()) pile[i].push_back(x); } void get_place_a(int x) { for (int i = 0; i < m; i++) { for (int j = 0; j < pile[i].size(); j++) { ...
#include <bits/stdc++.h> using namespace std; int aidx, ah, bidx, bh; vector<int> pile[105]; int m; void put_floor(int x) { for (int i = 0; i < m; i++) if (!pile[i].size()) { pile[i].push_back(x); return; } } void get_place_a(int x) { for (int i = 0; i < m; i++) { for (int j = 0; j < pi...
[["+", 8, 9, 0, 7, 8, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 7, 8, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 7, 8, 57, 64, 9, 0, 46]]
1
594
4
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { int m; while (cin >> m && m != 0) { int s, d; vector<vector<int>> pileSet; for (int i = 0; i < m; i++) pileSet.push_back(vector<int>(1, i + 1)); while (cin >> s >> d && !(s == 0 && d...
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { int m; while (cin >> m && m != 0) { int s, d; vector<vector<int>> pileSet; for (int i = 0; i < m; i++) pileSet.push_back(vector<int>(1, i + 1)); while (cin >> s >> d && !(s == 0 && d...
[["-", 15, 339, 51, 16, 31, 2, 63, 118, 17, 131], ["-", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341...
1
843
9
#include <algorithm> #include <cstdio> #include <iostream> #include <queue> #define REP(i, n) for (int i = 0; i < (int)(n); i++) inline int getInt() { int s; scanf("%d", &s); return s; } using namespace std; int main() { while (int m = getInt()) { vector<int> memo(m); vector<vector<int>> t(m); qu...
#include <algorithm> #include <cstdio> #include <iostream> #include <queue> #define REP(i, n) for (int i = 0; i < (int)(n); i++) inline int getInt() { int s; scanf("%d", &s); return s; } using namespace std; int main() { while (int m = getInt()) { vector<int> memo(m); vector<vector<int>> t(m); qu...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]]
1
538
2
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
889
2
#include <algorithm> #include <bitset> #include <iostream> #include <set> #include <tuple> #include <vector> using namespace std; typedef tuple<vector<int>, int, int> Hint; enum { TRY, HIT, BLOW }; const int NUMBERS = 10; vector<vector<int>> subset_combination(int n, int k, vector<int> number) { vector<vector<int>...
#include <algorithm> #include <bitset> #include <iostream> #include <set> #include <tuple> #include <vector> using namespace std; typedef tuple<vector<int>, int, int> Hint; enum { TRY, HIT, BLOW }; const int NUMBERS = 10; vector<vector<int>> subset_combination(int n, int k, vector<int> number) { vector<vector<int>...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
743
2
#include <algorithm> #include <iostream> using namespace std; int main() { int N, R, p, c; while (cin >> N >> R && N) { int A[100] = {}; for (int i = 0; i < N; i++) { A[i] = i + 1; } reverse(A, A + N); for (int i = 0; i < R; ++i) { cin >> p >> c; rotate(A, A + p, A + p + c); ...
#include <algorithm> #include <iostream> using namespace std; int main() { int N, R, p, c; while (cin >> N >> R && N) { int A[100] = {}; for (int i = 0; i < N; i++) { A[i] = i + 1; } reverse(A, A + N); for (int i = 0; i < R; ++i) { cin >> p >> c; rotate(A, A + p - 1, A + p + c...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
127
4
while True: n, r = map(int, input().split()) if (n, r) == (0, 0): break cards = list(range(1, n+1))[::-1] print(cards) for i in range(r): p, c = map(int, input().split()) cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:] print(cards[0])
while True: n, r = map(int, input().split()) if (n, r) == (0, 0): break cards = list(range(1, n+1))[::-1] for i in range(r): p, c = map(int, input().split()) cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:] print(cards[0])
[["-", 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
119
4
while True: n, r = map(int, input().split()) if n == 0 and r == 0: break cards = list(range(1, n+1))[::-1] for _ in range(r): p, c = map(int, input().split()) cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p+c:] print(cards[0])
while True: n, r = map(int, input().split()) if n == 0 and r == 0: break cards = list(range(1, n+1))[::-1] for _ in range(r): p, c = map(int, input().split()) cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:] print(cards[0])
[["+", 12, 206, 206, 663, 0, 657, 31, 657, 17, 33], ["+", 12, 206, 206, 663, 0, 657, 31, 657, 12, 612]]
5
109
2
while True: sousa=input().sprit() #????????? sousa=[int(sousa[0]),int(sousa[1])] if sousa==[0,0]:break yama=[] for k in range(sousa[0]):yama.append(k+1) yama=yama[::-1] for r in range(sousa[1]): [p,c]=input().sprit() [p,c]=[int(p),int(c)] yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-2] print(yama[0])
while True: sousa=input().split() sousa=[int(sousa[0]),int(sousa[1])] if sousa==[0,0]:break yama=[] for k in range(sousa[0]):yama.append(k+1) yama=yama[::-1] for r in range(sousa[1]): [p,c]=input().split() [p,c]=[int(p),int(c)] yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-1] print(yama[0])
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["-", 12, 657, 12, 206, 206, 663, 0, 657, 12, 612], ["+", 12, 657, 12, 206, 206, 663, 0, 657, 12, 612]]
5
152
6
first = input().split() n = int(first[0]) r = int(first[1]) while n != 0 or r != 0: i = 0 card = list(range(1,n+1))[::-1] while i < r: sh = input().split() p, c = list(map(int,sh)) card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:] i = i + 1 print(card) next = input()...
first = input().split() n = int(first[0]) r = int(first[1]) while n != 0 or r != 0: i = 0 card = list(range(1,n+1))[::-1] while i < r: sh = input().split() p, c = list(map(int,sh)) card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:] i = i + 1 print(card[0]) next = inpu...
[["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
148
3
while True: n, r = list(map(lambda x: int(x), input().split(" "))) if n == 0 and r == 0: break cards = [i for i in range(1,n+1)] cards = cards[::-1] for i in range(r): print(cards) p, c = list(map(lambda x: int(x), input().split(" "))) p -= 1 cards = cards[p:...
while True: n, r = list(map(lambda x: int(x), input().split(" "))) if n == 0 and r == 0: break cards = [i for i in range(1,n+1)] cards = cards[::-1] for i in range(r): p, c = list(map(lambda x: int(x), input().split(" "))) p -= 1 cards = cards[p:p+c] + cards[0:p] + c...
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
141
4
while True: n, r = list(map(int, input().split())) if n == 0 and r == 0: break Cards = [list(range(n, 0, -1))] for i in range(r): p, c = list(map(int, input().split())) Cards = Cards[p-1:p-1+c] + Cards[:p-1] + Cards[p-1+c:] print(Cards[0])
while True: n, r = list(map(int, input().split())) if n == 0 and r == 0: break Cards = list(range(n, 0, -1)) for i in range(r): p, c = list(map(int, input().split())) Cards = Cards[p-1:p-1+c] + Cards[:p-1] + Cards[p-1+c:] print(Cards[0])
[["-", 8, 196, 0, 1, 0, 662, 12, 634, 0, 70], ["-", 8, 196, 0, 1, 0, 662, 12, 634, 0, 73]]
5
114
2
function bomb(y, x) { var dy = [ 0, 0, -1, 1 ]; var dx = [ -1, 1, 0, 0 ]; for (var i = 0; i < 4; i++) { var yy = y + dy[i]; var xx = x + dx[i]; if (yy < 0 || yy >= H || xx < 0 || xx >= W) continue; if (yx[yy][xx] == ".") { cnt++; yx[yy][xx] = cnt; bomb(yy, xx); } } } ...
function bomb(y, x) { var dy = [ 0, 0, -1, 1 ]; var dx = [ -1, 1, 0, 0 ]; for (var i = 0; i < 4; i++) { var yy = y + dy[i]; var xx = x + dx[i]; if (yy < 0 || yy >= H || xx < 0 || xx >= W) continue; if (yx[yy][xx] == ".") { cnt++; yx[yy][xx] = cnt; bomb(yy, xx); } } } ...
[["-", 8, 556, 0, 198, 0, 200, 51, 69, 500, 22], ["+", 8, 556, 0, 198, 0, 200, 51, 69, 500, 22]]
2
326
4
import java.util.*; public class Main { int[][] land, looked; int sx, sy, w, h, count; int[] dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1}; Scanner stdin = new Scanner(System.in); Queue qx = new LinkedList(); Queue qy = new LinkedList(); void Solve() { while (true) { w = stdin.nextInt(); h = s...
import java.util.*; public class Main { int[][] land, looked; int sx, sy, w, h, count; int[] dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1}; Scanner stdin = new Scanner(System.in); Queue qx = new LinkedList(); Queue qy = new LinkedList(); void Solve() { while (true) { w = stdin.nextInt(); h = s...
[["-", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
3
424
2
import static java.lang.System.in; import static java.lang.System.out; import java.util.*; public class Main { Scanner sc = new Scanner(in); void run() { StringTokenizer st; while (true) { st = new StringTokenizer(sc.nextLine()); int w = Integer.parseInt(st.nextToken()); int h = Integer...
import static java.lang.System.in; import static java.lang.System.out; import java.util.*; public class Main { Scanner sc = new Scanner(in); void run() { StringTokenizer st; while (true) { st = new StringTokenizer(sc.nextLine()); int w = Integer.parseInt(st.nextToken()); int h = Integer...
[["-", 75, 57, 64, 196, 0, 1, 0, 11, 12, 146], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 147]]
3
510
2
#include <iostream> using namespace std; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int H, W, count = 0; char **map; bool **isCount; bool valid(int x, int y) { return x <= (W - 1) && x >= 0 && y <= (H - 1) && y >= 0; } void bfs(int x, int y) { if (valid(x, y) && map[y][x] != '#' && !isCount[y][x]) { ...
#include <iostream> using namespace std; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int H, W, count = 0; char **map; bool **isCount; bool valid(int x, int y) { return x <= (W - 1) && x >= 0 && y <= (H - 1) && y >= 0; } void bfs(int x, int y) { if (valid(x, y) && map[y][x] != '#' && !isCount[y][x]) { ...
[["+", 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
398
4
#include <iostream> using namespace std; char a[22][22]; int w, h; int yy[4] = {-1, 0, 0, 1}, xx[4] = {0, 1, -1, 0}; int solve(int y, int x) { if (a[y][x] == '#') return 0; a[y][x] = '#'; int ans = 0; for (int i = 0; i < 4; i++) { ans += solve(y + yy[i], x + xx[i]); } return ans + 1; } int main() ...
#include <iostream> using namespace std; char a[22][22]; int w, h; int yy[4] = {-1, 0, 0, 1}, xx[4] = {0, 1, -1, 0}; int solve(int y, int x) { if (a[y][x] == '#') return 0; a[y][x] = '#'; int ans = 0; for (int i = 0; i < 4; i++) { ans += solve(y + yy[i], x + xx[i]); } return ans + 1; } int main() ...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
258
2
#include <bits/stdc++.h> using namespace std; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; int W, H; char board[30][30]; int dfs(int y, int x) { board[y][x] = '#'; int ret = 1; for (int i = 0; i < 4; i++) { int ny = y + dy[i], nx = x + dx[i]; if (ny >= 0 && ny < H && nx >= 0 && nx < W...
#include <bits/stdc++.h> using namespace std; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; int W, H; char board[30][30]; int dfs(int y, int x) { board[y][x] = '#'; int ret = 1; for (int i = 0; i < 4; i++) { int ny = y + dy[i], nx = x + dx[i]; if (ny >= 0 && ny < H && nx >= 0 && nx < W...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
262
4
#include <stdio.h> //#include<windows.h> int masu[22][22]; int ans = 0; int i, j; void saiki(int x, int y) { /* for(i=0;i<22;i++){ for(j=0;j<22;j++){ if(masu[i][j]==0)printf(" "); if(masu[i][j]==1)printf("¡"); } puts(""); } printf("%d",ans); ...
#include <stdio.h> //#include<windows.h> int masu[22][22]; int ans = 0; int i, j; void saiki(int x, int y) { /* for(i=0;i<22;i++){ for(j=0;j<22;j++){ if(masu[i][j]==0)printf(" "); if(masu[i][j]==1)printf("¡"); } puts(""); } printf("%d",ans); ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
356
4
#include <iostream> using namespace std; char map[21][21]; int count; int x, y; void dfs(int nx, int ny) { map[ny][nx] = '#'; count++; if (nx < x && map[ny][nx + 1] == '.') { dfs(nx + 1, ny); } if (nx > 0 && map[ny][nx - 1] == '.') { dfs(nx - 1, ny); } if (ny < y && map[ny + 1][nx] == '.') { ...
#include <iostream> using namespace std; char map[21][21]; int count; int x, y; void dfs(int nx, int ny) { map[ny][nx] = '#'; count++; if (nx + 1 < x && map[ny][nx + 1] == '.') { dfs(nx + 1, ny); } if (nx > 0 && map[ny][nx - 1] == '.') { dfs(nx - 1, ny); } if (ny + 1 < y && map[ny + 1][nx] == '....
[["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 72], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 13]]
1
292
4
#include <iostream> #define MAX (256) using namespace std; int N, M; char field[MAX][MAX]; int sx, sy; int ans = 0; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; void dfs(int x, int y) { if (0 <= x && x < N && 0 <= y && y < M && field[x][y] == '.') { field[x][y] = '#'; ans++; for (int i = 0; i < 4...
#include <iostream> #define MAX (256) using namespace std; int N, M; char field[MAX][MAX]; int sx, sy; int ans = 0; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; void dfs(int x, int y) { if (0 <= x && x < N && 0 <= y && y < M && field[x][y] == '.') { field[x][y] = '#'; ans++; for (int i = 0; i < 4...
[["+", 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
320
4
#include <iostream> #include <string> #include <vector> using namespace std; typedef vector<vector<int>> vector2d; int main() { int H, W, count = 0, kaisuu = 0, kosuu, sum, judge; char map[20][20]; vector2d nextx, nexty; // nextx[回数][個数] nextx.reserve(50); nexty.reserve(50); while (1) { cin >> W >> ...
#include <iostream> #include <string> #include <vector> using namespace std; typedef vector<vector<int>> vector2d; int main() { int H, W, count = 0, kaisuu = 0, kosuu, sum, judge; char map[20][20]; vector2d nextx, nexty; // nextx[回数][個数] nextx.reserve(10000); nexty.reserve(10000); while (1) { cin >>...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
708
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <vector> using namespace std; int main() { int nb_ligne...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <vector> using namespace std; int main() { int nb_ligne...
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
407
4
#include <stdio.h> #include <string.h> #define W 21 #define H 21 int w, h; char map[W][H]; int search(int s, int t) { if (s < 0 || t < 0 || s >= h || t >= w || map[s][t] == '#') return 0; int sum = 1; map[s][t] = '#'; sum += search(s - 1, t); sum += search(s, t + 1); sum += search(s + 1, t); sum += se...
#include <stdio.h> #include <string.h> #define W 21 #define H 21 int w, h; char map[W][H]; int search(int s, int t) { if (s < 0 || t < 0 || s >= h || t >= w || map[s][t] == '#') return 0; int sum = 1; map[s][t] = '#'; sum += search(s - 1, t); sum += search(s, t + 1); sum += search(s + 1, t); sum += se...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25]]
0
287
6
#include <iostream> #include <vector> using namespace std; const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1}; int dfs(int y, int x, vector<string> &g) { if (g[y][x] == '.') return 0; g[y][x] = '.'; int res = 1; for (int i = 0; i < 4; i++) { int ny = y + dy[i], nx = x + dx[i]; if (ny < 0 || nx ...
#include <iostream> #include <vector> using namespace std; const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1}; int dfs(int y, int x, vector<string> &g) { if (g[y][x] == '#') return 0; g[y][x] = '#'; int res = 1; for (int i = 0; i < 4; i++) { int ny = y + dy[i], nx = x + dx[i]; if (ny < 0 || nx ...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["-", 8, 9, 0, 1, 0, 11, 12, 103, 0, 125], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 125]]
1
301
4
#include <iostream> using namespace std; char map[20][20]; int W, H, start_x, start_y, ans = 0; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; void dfs(int x, int y) { ans++; if (map[x][y] != '#') { map[x][y] = '#'; for (int i = 0; i < 4; i++) { int next_x = x + dx[i], next_y = y + dy[i]; ...
#include <iostream> using namespace std; char map[20][20]; int W, H, start_x, start_y, ans = 0; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; void dfs(int x, int y) { ans++; if (map[x][y] != '#') { map[x][y] = '#'; for (int i = 0; i < 4; i++) { int next_x = x + dx[i], next_y = y + dy[i]; ...
[["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
1
297
4
#include <algorithm> #include <cmath> #include <complex> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define vvi vector<vector<int>> #define vi vector<int> #define All(X) X.begin...
#include <algorithm> #include <cmath> #include <complex> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define vvi vector<vector<int>> #define vi vector<int> #define All(X) X.begin...
[["-", 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
434
4
#include <iostream> #include <string> using namespace std; int w, h; string map[40]; int vec[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}}; int move(int x, int y) { int ans = 0; map[x][y] = '#'; for (int i = 0; i < 4; i++) { if ((x + vec[i][0] >= 0) && (y + vec[i][1] >= 0) && (x + vec[i][0] < h) && (y + ...
#include <iostream> #include <string> using namespace std; int w, h; string map[40]; int vec[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}}; int move(int x, int y) { int ans = 1; map[x][y] = '#'; for (int i = 0; i < 4; i++) { if ((x + vec[i][0] >= 0) && (y + vec[i][1] >= 0) && (x + vec[i][0] < h) && (y + ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
338
2
// // RedAndBlack.cpp // // // Created by ??°????????? on 2015/10/30. // // #include <iostream> using namespace std; int w, h, num = 0, room[20][20]; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 0}; void dfs(int x, int y) { num++; room[y][x] = 0; // ??????????????¢?´¢ for (int i = 0; i < 4; i++) { ...
// // RedAndBlack.cpp // // // Created by ??°????????? on 2015/10/30. // // #include <iostream> using namespace std; int w, h, num = 0, room[20][20]; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; void dfs(int x, int y) { num++; room[y][x] = 0; // ??????????????¢?´¢ for (int i = 0; i < 4; i++) { ...
[["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13]]
1
331
2
#include "bits/stdc++.h" #include <unordered_map> #pragma warning(disable : 4996) using namespace std; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, 1, 0, -1}; struct aa { int y; int x; bool black; }; int main() { while (1) { int w, h; cin >> w >> h; if (!w) break; vector<vecto...
#include "bits/stdc++.h" #include <unordered_map> #pragma warning(disable : 4996) using namespace std; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, 1, 0, -1}; struct aa { int y; int x; bool black; }; int main() { while (1) { int w, h; cin >> w >> h; if (!w) break; vector<vecto...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
510
2
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <string> #include <vector> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <string> #include <vector> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (...
[["+", 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
412
4
/* * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1130&lang=jp */ #include <iostream> #include <limits> constexpr size_t MAX_HEIGHT = 20; const char START_TILE = '@'; const char PASSABLE_TILE = '.'; const char PROHIBITED_TILE = '#'; const char PASSED_TILE = 'P'; bool is_wall(std::string world[MAX_HEIGH...
/* * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1130&lang=jp */ #include <iostream> #include <limits> constexpr size_t MAX_HEIGHT = 20; const char START_TILE = '@'; const char PASSABLE_TILE = '.'; const char PROHIBITED_TILE = '#'; const char PASSED_TILE = 'P'; bool is_wall(std::string world[MAX_HEIGH...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 345, 348], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 0, 349], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 141, 22]]
1
433
4
#include <iostream> using namespace std; typedef pair<int, int> pii; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; char fld[20][20]; bool used[20][20]; int W, H; void rec(int i, int j) { used[i][j] = 1; for (int k = 0; k < 4; k++) { int ni = i + dy[k]; int nj = j + dx[k]; if ((0 <= ni && ni < H &...
#include <iostream> using namespace std; typedef pair<int, int> pii; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; char fld[20][21]; int used[20][20]; int W, H; void rec(int i, int j) { used[i][j] = 1; for (int k = 0; k < 4; k++) { int ni = i + dy[k]; int nj = j + dx[k]; if (0 <= ni && ni < H && ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 60], ["...
1
385
8
#include <iostream> using namespace std; int w, h; int tx[4] = {0, -1, 0, 1}; int ty[4] = {-1, 0, 1, 0}; char map[21][21]; int slv(int x, int y) { map[y][x] = '#'; int ans = 0; for (int i = 0; i < 4; ++i) if (x + tx[i] != -1 || y + ty[i] != -1 || x + tx[i] != w || y + ty[i] != h) if (map[y + ty[i]][x +...
#include <iostream> using namespace std; int w, h; int tx[4] = {0, -1, 0, 1}; int ty[4] = {-1, 0, 1, 0}; char map[21][21]; int slv(int x, int y) { map[y][x] = '#'; int ans = 0; for (int i = 0; i < 4; ++i) if (x + tx[i] != -1 && y + ty[i] != -1 && x + tx[i] != w && y + ty[i] != h) if (map[y + ty[i]][x +...
[["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 106], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 98], ["-", 8, 57, 15, 339, 51, 16, 31, 16, 17, 106], ["+", 8, 57, 15, 339, 51, 16, 31, 16, 17, 98], ["-", 0, 7, 8, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 17, 98]]
1
295
6
#include <bits/stdc++.h> using namespace std; static int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; int h, w, r; string s[20]; void dfs(int y, int x) { r++; s[y][x] = '#'; for (int i = 0; i < 4; i++) if (0 <= y + dy[i] && y + dy[i] < h && 0 <= x + dx[i] && x + dx[i] < w) if (s[y + dy[i]][x + dx[i]] =...
#include <bits/stdc++.h> using namespace std; static int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; int h, w, r; string s[20]; void dfs(int y, int x) { r++; s[y][x] = '#'; for (int i = 0; i < 4; i++) if (0 <= y + dy[i] && y + dy[i] < h && 0 <= x + dx[i] && x + dx[i] < w) if (s[y + dy[i]][x + dx[i]] =...
[["+", 0, 14, 8, 9, 0, 7, 15, 34, 0, 21], ["+", 0, 14, 8, 9, 0, 7, 15, 34, 12, 22]]
1
284
2
while True: N = int(input()) if N == 0: break W,H = map(int,input().split()) fld = [[0 for w in range(W)] for h in range(H)] for i in range(N): x,y = map(lambda s:int(s)-1,raw_input().split()) fld[y][x] = 1 cums = [[0 for w in range(W+1)] for h in range(H+1)] for y in range(H...
while True: N = int(input()) if N == 0: break W,H = map(int,input().split()) fld = [[0 for w in range(W)] for h in range(H)] for i in range(N): x,y = map(lambda s:int(s)-1,input().split()) fld[y][x] = 1 cums = [[0 for w in range(W+1)] for h in range(H+1)] for y in range(H): ...
[["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22]]
5
276
2
import java.util.*; public class Main { private void doit() { Scanner sc = new Scanner(System.in); while (true) { int w = sc.nextInt(); int h = sc.nextInt(); if ((w | h) == 0) break; char[][] data = new char[h][w]; for (int i = 0; i < h; i++) { String s = sc.next...
import java.util.*; public class Main { private void doit() { Scanner sc = new Scanner(System.in); while (true) { int w = sc.nextInt(); int h = sc.nextInt(); if ((w | h) == 0) break; char[][] data = new char[h][w]; for (int i = 0; i < h; i++) { String s = sc.next...
[["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 72], ["-", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]]
3
836
2
#include <algorithm> #include <cctype> #include <cstring> #include <iostream> #include <string> using namespace std; typedef long long ll; char field[71][71]; string dp[71][71]; bool str_less(const string &a, const string &b) { if (a.size() < b.size()) { return true; } if (a.size() > b.size()) { return...
#include <algorithm> #include <cctype> #include <cstring> #include <iostream> #include <string> using namespace std; typedef long long ll; char field[71][71]; string dp[71][71]; bool str_less(const string &a, const string &b) { if (a.size() < b.size()) { return true; } if (a.size() > b.size()) { return...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
445
4
#define _USE_MATH_DEFINES #define INF 100000000 #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #incl...
#define _USE_MATH_DEFINES #define INF 100000000 #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #incl...
[["+", 63, 118, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 63, 118, 28, 69, 341, 342, 0, 16, 12, 13]]
1
698
2
#include <algorithm> #include <iostream> #include <string> using namespace std; int W, H; string s[71][71]; char in[71][71]; bool comp2(string s, string r) { if (s.size() != r.size()) return s.size() > r.size(); return s > r; } bool comp(string s, string r) { while (s[0] == '0' && isdigit(s[1])) s = s....
#include <algorithm> #include <iostream> #include <string> using namespace std; int W, H; string s[71][71]; char in[71][71]; bool comp2(string s, string r) { if (s.size() != r.size()) return s.size() > r.size(); return s > r; } bool comp(string s, string r) { while (s[0] == '0' && isdigit(s[1])) s = s....
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 8, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["-", 8, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
515
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; const int dx[] = {1, 0}; const int dy[] = {0, 1}; vector<string> board(80); string memo[80][80]; int W, H; inline bool isDigit(int x, int y) { if ('0' <= board[y][x] && board[y][x] <= '9') return true; else return false; } ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; const int dx[] = {1, 0}; const int dy[] = {0, 1}; vector<string> board(80); string memo[80][80]; int W, H; inline bool isDigit(int x, int y) { if ('0' <= board[y][x] && board[y][x] <= '9') return true; else return false; } ...
[["-", 63, 118, 28, 69, 28, 69, 341, 342, 0, 22], ["+", 63, 118, 28, 69, 28, 69, 341, 342, 0, 22], ["-", 31, 2, 63, 118, 28, 69, 341, 342, 0, 22], ["+", 31, 2, 63, 118, 28, 69, 341, 342, 0, 22]]
1
495
4
$x=0 $y=0 $bord = [] loop{ line = gets if line==nil then break end sp = line.split(nil) if sp.count() != 2 then break else $x = sp[0].to_i() $y = sp[1].to_i() if $x == 0 and $y == 0 then break end $bord = Array.new($y).map{Array.new($x,0)} max = 0 for i in 0..$y-1 line = gets left = ...
$x=0 $y=0 $bord = [] loop{ line = gets if line==nil then break end sp = line.split(nil) if sp.count() != 2 then break else $x = sp[0].to_i() $y = sp[1].to_i() if $x == 0 and $y == 0 then break end $bord = Array.new($y).map{Array.new($x,0)} max = 0 for i in 0..$y-1 line = gets left = ...
[["-", 0, 88, 8, 170, 0, 662, 12, 748, 17, 33], ["-", 0, 88, 8, 170, 0, 662, 12, 748, 439, 612], ["+", 8, 170, 0, 88, 8, 170, 0, 662, 12, 612], ["-", 64, 749, 0, 121, 75, 95, 0, 662, 0, 32], ["+", 64, 749, 0, 121, 75, 95, 0, 755, 17, 107], ["-", 0, 121, 75, 95, 0, 662, 12, 738, 17, 72], ["-", 0, 121, 75, 95, 0, 662, 12...
4
215
7
while True: W, H = list(map(int,input().split(" "))) if W == H == 0: break field = [[c for c in input()] for _ in range(H)] secret = [0, ""] for j in range(H): for i in range(W): if not field[j][i].isdigit(): continue pre = left = top = "" if i > 0 and field[j][i-1].isdigit() and field[j][i-1] !=...
while True: W, H = list(map(int,input().split(" "))) if W == H == 0: break field = [[c for c in input()] for _ in range(H)] secret = [0, ""] for j in range(H): for i in range(W): if not field[j][i].isdigit(): continue pre = left = top = "" if i > 0 and field[j][i-1].isdigit() and field[j][i-1] !=...
[["-", 0, 57, 75, 665, 15, 679, 12, 666, 667, 18], ["+", 0, 57, 75, 665, 15, 679, 12, 666, 667, 47]]
5
320
41
# -*- coding: utf-8 -*- def recursion(y, x, island, dp): if island[y][x].isdigit() and int(island[y][x]) in range(10): if y == 0 and x == 0: dp[y][x] = int(island[y][x]) elif y == 0: if dp[y][x-1] != -1: dp[y][x] = dp[y][x-1] * 10 + int(island[y][x]) ...
# -*- coding: utf-8 -*- def recursion(y, x, island, dp): if island[y][x].isdigit() and int(island[y][x]) in range(10): if y == 0 and x == 0: dp[y][x] = int(island[y][x]) elif y == 0: if dp[y][x-1] != -1: dp[y][x] = dp[y][x-1] * 10 + int(island[y][x]) ...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24]]
5
608
4
import java.io.*; import java.util.*; class Main { public static void main(String[] args) { new Main().new P1127().run(); } class P1127 { void run() { Scanner sc = new Scanner(System.in); for (;;) { int n = sc.nextInt(); if (n == 0) break; Pos[] p = new Pos[n]; ...
import java.io.*; import java.util.*; class Main { public static void main(String[] args) { new Main().new P1127().run(); } class P1127 { void run() { Scanner sc = new Scanner(System.in); for (;;) { int n = sc.nextInt(); if (n == 0) break; Pos[] p = new Pos[n]; ...
[["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 44]]
3
554
1
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc = new Scanner(System.in); public void run() { while (sc.hasNext()) { int n = sc.nextInt(); if (n == 0) break; else calc(n); } } double xs[]; double ys[]; ...
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc = new Scanner(System.in); public void run() { while (sc.hasNext()) { int n = sc.nextInt(); if (n == 0) break; else calc(n); } } double xs[]; double ys[]; ...
[["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491]]
3
584
2
// // main.c // Numeral System // // Created by x15071xx on 2016/06/09. // Copyright ?? 2016??´ AIT. All rights reserved. // #include <stdio.h> #include <string.h> int main(int argc, const char *argv[]) { int n, i, j, k; scanf("%d", &n); for (i = 0; i < n; i++) { char mcxi1[9] = {0}, mcxi2[9] = {0},...
// // main.c // Numeral System // // Created by x15071xx on 2016/06/09. // Copyright ?? 2016??´ AIT. All rights reserved. // #include <stdio.h> #include <string.h> int main(int argc, const char *argv[]) { int n, i, j, k; scanf("%d", &n); for (i = 0; i < n; i++) { char mcxi1[9] = {0}, mcxi2[9] = {0},...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22]]
0
713
2
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int Integer(char *s) { int i, n, answer = 0; char temp; for (i = 0; i < strlen(s) / 2; i++) { temp = s[i]; s[i] = s[(strlen(s) - 1) - i]; s[(strlen(s) - 1) - i] = temp; } i = 0; while (i <= strlen(s) - 1) { if...
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int Integer(char *s) { int i, n, answer = 0; char temp; for (i = 0; i < strlen(s) / 2; i++) { temp = s[i]; s[i] = s[(strlen(s) - 1) - i]; s[(strlen(s) - 1) - i] = temp; } i = 0; while (i <= strlen(s) - 1) { if...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
0
469
4
#include <bits/stdc++.h> using namespace std; int z[26] = {0}; char ch[4] = {'i', 'x', 'c', 'm'}; string s1, s2; int n; string enc(int x); int dec(string s); int main() { int a; cin >> n; z['m' - 'a'] = 1000; z['c' - 'a'] = 100; z['x' - 'a'] = 10; z['i' - 'a'] = 1; for (a = 0; a < n; ++a) { cin >> ...
#include <bits/stdc++.h> using namespace std; int z[26] = {0}; char ch[4] = {'i', 'x', 'c', 'm'}; string s1, s2; int n; string enc(int x); int dec(string s); int main() { int a; cin >> n; z['m' - 'a'] = 1000; z['c' - 'a'] = 100; z['x' - 'a'] = 10; z['i' - 'a'] = 1; for (a = 0; a < n; ++a) { cin >> ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
358
2
#include <cctype> #include <cstring> #include <iostream> using namespace std; int MCXI2D(string str) { int d = 1; int sum = 0; int p = 0; while (p < str.size()) { if (isdigit(str[p])) { d = str[p] - '0'; } else { if (str[p] == 'm') { sum += d * 1000; } else if (str[p] == 'c') ...
#include <cctype> #include <cstring> #include <iostream> using namespace std; int MCXI2D(string str) { int d = 1; int sum = 0; int p = 0; while (p < str.size()) { if (isdigit(str[p])) { d = str[p] - '0'; } else { if (str[p] == 'm') { sum += d * 1000; } else if (str[p] == 'c') ...
[["-", 0, 1, 0, 11, 12, 23, 0, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 31, 22]]
1
449
2
#include <cstdio> #include <iostream> #include <sstream> #include <string> using namespace std; int n; int main(void) { scanf("%d", &n); for (int i = 0; i < n; i++) { string str, str2; cin >> str >> str2; int c = 0; int f = 1; for (int i = 0; i < str.size(); i++) { if (str[i] >= '2' && ...
#include <cstdio> #include <iostream> #include <sstream> #include <string> using namespace std; int n; int main(void) { scanf("%d", &n); for (int i = 0; i < n; i++) { string str, str2; cin >> str >> str2; int c = 0; int f = 1; for (int i = 0; i < str.size(); i++) { if (str[i] >= '2' && ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
472
2
#include <iostream> #include <math.h> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> using namespace std; int main(void) { // FILE* fp_in = freopen("data.txt", "r", stdin); int N; cin >> N; for (int cnt = 0; cnt < N; cnt++) { string s[2]; int num[2][4];...
#include <iostream> #include <math.h> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> using namespace std; int main(void) { // FILE* fp_in = freopen("data.txt", "r", stdin); int N; cin >> N; for (int cnt = 0; cnt < N; cnt++) { string s[2]; int num[2][4];...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
763
8
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; string itos(int n) { int a, b, c, d; a = n / 1000; n = n % 1000; b = n / 100; n = n % 100; c = n / 10; c = n % 10; d = n; string s = ""; if (a > 1) s = s + to_string(a); if (a > 0)...
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; string itos(int n) { int a, b, c, d; a = n / 1000; n = n % 1000; b = n / 100; n = n % 100; c = n / 10; n = n % 10; d = n; string s = ""; if (a > 1) s = s + to_string(a); if (a > 0)...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22]]
1
441
2
// #define USE_CPP11 // #define USE_PRINTF #include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #in...
// #define USE_CPP11 // #define USE_PRINTF #include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #in...
[["-", 64, 9, 0, 1, 0, 11, 12, 103, 0, 125], ["+", 64, 9, 0, 1, 0, 11, 12, 103, 0, 125]]
1
842
2
#include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char *argv[]) { int n; char mcxi[] = {'m', 'c', 'x', 'i'}; string num; cin >> n; while (n--) { vector<pair<char, int>> vp; for (int i = 0; i < 4; ++i) vp.push_back(make_pair(mcxi[i], 0)); for (in...
#include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char *argv[]) { int n; char mcxi[] = {'m', 'c', 'x', 'i'}; string num; cin >> n; while (n--) { vector<pair<char, int>> vp; for (int i = 0; i < 4; ++i) vp.push_back(make_pair(mcxi[i], 0)); for (in...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 20], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 52, 8, 9, 0, 7...
1
377
8
#include <iostream> #include <string> using namespace std; int m, c, x, ii = 0; void mcxiDisassembly(string &mcxi) { int sum = 0; int number = 0; for (int i = 0; i <= mcxi.length(); i++) { if (mcxi[i] != 'm' && mcxi[i] != 'c' && mcxi[i] != 'x' && mcxi[i] != 'i') { number = (int)(mcxi[i] - '0'); } ...
#include <iostream> #include <string> using namespace std; int m, c, x, ii = 0; void mcxiDisassembly(string &mcxi) { int sum = 0; int number = 0; for (int i = 0; i <= mcxi.length(); i++) { if (mcxi[i] != 'm' && mcxi[i] != 'c' && mcxi[i] != 'x' && mcxi[i] != 'i') { number = (int)(mcxi[i] - '0'); } ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
517
2
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <v...
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <v...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
435
2
#include <stdio.h> int main() { int i, sum, n, j, b, a, k; char m, m2, o; scanf("%d%c", &a, &o); for (i = 0; i < a; i++) { sum = 0; while (1) { if (scanf("%c", &m) == EOF) break; if (m == '\n') break; if ('2' <= m && m <= '9') { scanf("%c", &m2); if (m2 ...
#include <stdio.h> int main() { int i, sum, n, j, b, a, k; char m, m2, o; scanf("%d%c", &a, &o); for (i = 0; i < a; i++) { sum = 0; while (1) { if (scanf("%c", &m) == EOF) break; if (m == '\n') break; if ('2' <= m && m <= '9') { scanf("%c", &m2); if (m2 ...
[["-", 0, 57, 64, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 57, 64, 1, 0, 2, 3, 4, 0, 22]]
1
461
2
#include <bits/stdc++.h> using namespace std; int main() { string s, s1; int n, i; cin >> n; while (n--) { cin >> s >> s1; int w1 = 1, w2 = 0, w3 = 0, w4 = 0; int sum = 0; for (i = 0; i < s.size(); i++) { if (s[i] >= '2' && s[i] <= '9') w1 = s[i] - '0'; else if (s[i] == 'm') ...
#include <bits/stdc++.h> using namespace std; int main() { string s, s1; int n, i; cin >> n; while (n--) { cin >> s >> s1; int w1 = 1, w2 = 0, w3 = 0, w4 = 0; int sum = 0; for (i = 0; i < s.size(); i++) { if (s[i] >= '2' && s[i] <= '9') w1 = s[i] - '0'; else if (s[i] == 'm') ...
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]]
1
516
4
#include <bits/stdc++.h> #define ll long long #define inf 100000000 using namespace std; int n; int toInt(char a) { char b[8] = {'2', '3', '4', '5', '6', '7', '8', '9'}; for (int i = 0; i < 8; i++) { if (a == b[i]) { return 2 + i; } } } bool isint(char a) { char b[8] = {'2', '3', '4', '5', '6...
#include <bits/stdc++.h> #define ll long long #define inf 100000000 using namespace std; int n; int toInt(char a) { char b[8] = {'2', '3', '4', '5', '6', '7', '8', '9'}; for (int i = 0; i < 8; i++) { if (a == b[i]) { return 2 + i; } } } bool isint(char a) { char b[8] = {'2', '3', '4', '5', '6...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
842
2
#include <bits/stdc++.h> using namespace std; #define R(i, n) for (int i = 0; i < n; ++i) int n, a, b, y[] = {1000, 100, 10, 1}; map<char, int> x; string s, t = "mcxi"; main() { x['m'] = 1000, x['c'] = 100, x['x'] = 10, x['i'] = 1; cin >> n; R(i, n) { a = 0; R(j, 2) { cin >> s; R(k, s.size()) ...
#include <bits/stdc++.h> using namespace std; #define R(i, n) for (int i = 0; i < n; ++i) int n, a, b, y[] = {1000, 100, 10, 1}; map<char, int> x; string s, t = "mcxi"; main() { x['m'] = 1000, x['c'] = 100, x['x'] = 10, x['i'] = 1; cin >> n; R(i, n) { a = 0; R(j, 2) { cin >> s; R(k, s.size()) ...
[["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
239
27
m[10][2], x[10][2], z[10][2], zz[10][2]; rotx[4][2] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}}; roty[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; mov[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; main(N, M, Z, t, i, j, k, mxm, mym, mxM, myM, zxm, zym, zxM, zyM) { for (; scanf("%d", &N), N; puts("+++++")) { /*input zero*/ ...
m[10][2], x[10][2], z[10][2], zz[10][2]; rotx[4][2] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}}; roty[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; mov[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; main(N, M, Z, t, i, j, k, mxm, mym, mxM, myM, zxm, zym, zxM, zyM) { for (; scanf("%d", &N), N; puts("+++++")) { /*input zero*/ ...
[["-", 12, 34, 12, 34, 12, 11, 31, 69, 71, 13], ["+", 12, 34, 12, 34, 12, 11, 31, 69, 71, 13]]
0
843
2
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef vector<P> LL; #define EPS (1e-10) LL A; int N; void viewLine(LL a) { cout << "view LINE" << endl; for (int i = 0; i < (int)a.size(); i++) { printf("%.8lf %.8lf\n", a[i].real(), a[i].imag()); } } void inputLine(LL &l) { int m; ...
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef vector<P> LL; #define EPS (1e-10) LL A; int N; void viewLine(LL a) { cout << "view LINE" << endl; for (int i = 0; i < (int)a.size(); i++) { printf("%.8lf %.8lf\n", a[i].real(), a[i].imag()); } } void inputLine(LL &l) { int m; ...
[["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 147], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
611
3
#include <algorithm> #include <cmath> #include <complex> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define vvi vector<vector<int>> #define vi vector<int> #define All(X) X.begin...
#include <algorithm> #include <cmath> #include <complex> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define vvi vector<vector<int>> #define vi vector<int> #define All(X) X.begin...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
827
2
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> P; typedef pair<ll, ll> Pll; typedef vector<int> Vi; typedef tuple<int, int, int> T; #define FOR(i, s, x) for (int i = s; i < (int)(x); i++) #define REP(i, x) FOR(i, 0, x) #define ALL(c) c.begin(), c.end() #define MP make_pa...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> P; typedef pair<ll, ll> Pll; typedef vector<int> Vi; typedef tuple<int, int, int> T; #define FOR(i, s, x) for (int i = s; i < (int)(x); i++) #define REP(i, x) FOR(i, 0, x) #define ALL(c) c.begin(), c.end() #define MP make_pa...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
656
2
def round(points) 3.times.each_with_object([points]){ |_, obj| obj << obj[-1].map{ |p| [-p[1], p[0]] } } end def same(a, b) a.size == b.size && a.zip(b).map { |(xa, ya), (xb, yb)| [xb - xa, yb - ya] }.uniq.size == 1 end while (n = gets.to_i) != 0 target = gets.to_i.times.map{ gets.split.map(&:to_i) } cand = n...
def round(points) 3.times.each_with_object([points]){ |_, obj| obj << obj[-1].map{ |p| [-p[1], p[0]] } } end def same(a, b) a.size == b.size && a.zip(b).map { |(xa, ya), (xb, yb)| [xb - xa, yb - ya] }.uniq.size == 1 end while (n = gets.to_i) != 0 target = gets.to_i.times.map{ gets.split.map(&:to_i) } cand = n...
[["+", 15, 652, 3, 4, 0, 742, 0, 738, 17, 33], ["+", 15, 652, 3, 4, 0, 742, 0, 738, 12, 612]]
4
216
2
mx = [0, 1, 0, -1] my = [-1, 0, 1, 0] while True: w, h = map(int, input().split()) if w == h == 0: break tiles = [[i for i in input()] for j in range(h)] ax = ay = 0 for i in range(h): for j in range(w): if tiles[i][j] == '@': ax, ay = j, i que = [(ax...
mx = [0, 1, 0, -1] my = [-1, 0, 1, 0] while True: w, h = map(int, input().split()) if w == h == 0: break tiles = [[i for i in input()] for j in range(h)] ax = ay = 0 for i in range(h): for j in range(w): if tiles[i][j] == '@': ax, ay = j, i que = [(ax...
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
246
6
def move_a(y,x,count): count += 1 li[x][y] = "#" if li[x-1][y] == ".": count = move_a(y,x-1,count) if li[x+1][y]== ".": count = move_a(y,x+1, count) if li[x][y-1]== ".": count = move_a(y-1,x, count) if li[x][y+1]== ".": count = move_a(y+1,x, count) return coun...
def move_a(y,x,count): count += 1 li[x][y] = "#" if li[x-1][y] == ".": count = move_a(y,x-1,count) if li[x+1][y]== ".": count = move_a(y,x+1, count) if li[x][y-1]== ".": count = move_a(y-1,x, count) if li[x][y+1]== ".": count = move_a(y+1,x, count) return coun...
[["-", 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
288
4
if __name__ == "__main__": while 1: w,h = list(map(int,input().strip().split())) if w == h == 0:break data = [] data = [] for _ in range(h):data.append(list(input())) visited = [] for i in range(h): if '@'in data[i]:stack= [(i,data[i].index('@'))] ...
#data????§???????[y???][x???]??§?????? if __name__ == "__main__": while 1: w,h = list(map(int,input().strip().split())) if w == h == 0:break data = [] data = [] for _ in range(h):data.append(list(input())) visited = [] for i in range(h): if '@'in ...
[["+", 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
356
4
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc; Main() { sc = new Scanner(System.in); } int ni() { return sc.nextInt(); } public static void main(String[] args) { new Main().run(); } int a, n; int p, q; int dfs(int last, int sa, int sn, double sm) { if (sn > n...
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc; Main() { sc = new Scanner(System.in); } int ni() { return sc.nextInt(); } public static void main(String[] args) { new Main().run(); } int a, n; int p, q; int dfs(int last, int sa, int sn, double sm) { if (sn > n...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 515], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 515]]
3
287
4
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; const int INF = 1 << 30; const int MOD = 1e9 + 7; const double EPS = 1e-6; int a, n; ...
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; const int INF = 1 << 30; const int MOD = 1e9 + 7; const double EPS = 1e-8; int a, n; ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
222
2
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define INF ((long long)1e18) #define MOD ((int)1e9 + 7) #define endl "\n" #define yn(f) ((f) ? "Yes" : "No") #de...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define INF ((long long)1e18) #define MOD ((int)1e9 + 7) #define endl "\n" #define yn(f) ((f) ? "Yes" : "No") #de...
[["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 13], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 13]]
1
491
2
#include <iostream> using namespace std; int P, Q, A, N; int res; void solve(int a, int n, int sum, int b) { if (P * a == Q * sum) { res++; return; } if (P * a < Q * sum || n >= 0) return; for (int i = b; a * i <= A; i++) solve(a * i, n + 1, sum * i + a, i); } int main() { while (cin >> P ...
#include <iostream> using namespace std; int P, Q, A, N; int res; void solve(int a, int n, int sum, int b) { if (P * a == Q * sum) { res++; return; } if (P * a < Q * sum || n >= N) return; for (int i = b; a * i <= A; i++) solve(a * i, n + 1, sum * i + a, i); } int main() { while (cin >> P ...
[["-", 8, 9, 0, 57, 15, 339, 51, 43, 51, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 43, 51, 22]]
1
169
2
#include <bits/stdc++.h> using namespace std; #define int long long int int gcd(int p, int q) { return p == 0 ? q : gcd(q % p, p); } int dfs(int p, int q, int a, int n, int m, int pre) { if (p == 0) return 1; if (n == 0) return 0; int res = 0; for (int i = pre; i * m <= a; i++) { if (n * q < p * i...
#include <bits/stdc++.h> using namespace std; #define int long long int int gcd(int p, int q) { return p == 0 ? q : gcd(q % p, p); } int dfs(int p, int q, int a, int n, int m, int pre) { if (p == 0) return 1; if (n == 0) return 0; int res = 0; for (int i = pre; i * m <= a; i++) { if (n * q < p * i...
[["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
234
2
/* 2017_03_02_AC ?????????????????? ????¬????????????????????????????i???A?????§????????????????????????????????§???????????????*i???A????¶??????????????????§????????? ????´???????????????????????????????????????£??????(a/b)+(c/d)??????(a*d+c*b)/(b*d)??¨??????????????§????????? ???????????????????????¨LTE??? ??????????...
/* 2017_03_02_AC ?????????????????? ????¬????????????????????????????i???A?????§????????????????????????????????§???????????????*i???A????¶??????????????????§????????? ????´???????????????????????????????????????£??????(a/b)+(c/d)??????(a*d+c*b)/(b*d)??¨??????????????§????????? ???????????????????????¨LTE??? ??????????...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
221
2
#include <iostream> using namespace std; int p, q, a, n; int seek(int pp, int qq, int aa, int nn) { if (p * qq == pp * q) return 1; if (p * qq < pp * q) return 0; if (nn == n) return 0; int count = 0; for (int i = aa; i * qq <= a; i++) count += seek(qq + pp * i, i * qq, i, n + 1); return ...
#include <iostream> using namespace std; int p, q, a, n; int seek(int pp, int qq, int aa, int nn) { if (p * qq == pp * q) return 1; if (p * qq < pp * q) return 0; if (nn == n) return 0; int count = 0; for (int i = aa; i * qq <= a; i++) { count += seek(qq + pp * i, i * qq, i, nn + 1); } ...
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
158
4
// clang-format off #include <bits/stdc++.h> using namespace std; #define int long long #define main signed main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n)...
// clang-format off #include <bits/stdc++.h> using namespace std; #define int long long #define main signed main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n)...
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22]]
1
749
2
#include "bits/stdc++.h" using namespace std; int p, q, a, n; int ans; int dfs(int deep, int bs, int bb, int x) { // cout<<deep<<" "<<bs<<" "<<bb<<endl; if (p * bb == q * bs) { // cout<<bs<<" "<<bb<<endl; ans++; } if (deep != n) { // cout<<deep<<" "<<bs<<" "<<bb<<endl; for (int i = x; i <= a; ...
#include "bits/stdc++.h" using namespace std; int p, q, a, n; int ans; int dfs(int deep, int bs, int bb, int x) { // cout<<deep<<" "<<bs<<" "<<bb<<endl; if (p * bb == q * bs) { // cout<<bs<<" "<<bb<<endl; ans++; } if (deep != n) { // cout<<deep<<" "<<bs<<" "<<bb<<endl; for (int i = x; i <= a; ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
197
2
#include <iostream> #include <vector> using namespace std; int p, q, a, n; int num; void calc(int depth, vector<int> &hist, int max_l) { if (depth >= 7) return; int mul = 1; for (int i = 0; i < hist.size(); i++) mul *= hist[i]; for (int i = max_l;; i++) { int next_mul = mul * i; if (next_mul ...
#include <iostream> #include <vector> using namespace std; int p, q, a, n; int num; void calc(int depth, vector<int> &hist, int max_l) { if (depth >= n) return; int mul = 1; for (int i = 0; i < hist.size(); i++) mul *= hist[i]; for (int i = max_l;; i++) { int next_mul = mul * i; if (next_mul ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
259
4