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> using namespace std; int a, sum; main() { for (int i = 0; i < 4; i++) { cin >> a; sum += a; } cout << a / 60 << endl << a % 60 << endl; }
#include <iostream> using namespace std; int a, s; main() { for (int i = 0; i < 4; i++) { cin >> a; s += a; } cout << s / 60 << endl << s % 60 << endl; }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 1,...
1
54
8
#include <bits/stdc++.h> using namespace std; int main() { int n, m; while (cin >> n >> m, n) { vector<vector<bool>> relation(n, vector<bool>(n)); for (int i = 0; i < n; ++i) { int a, b; cin >> a >> b; a--; b--; relation[a][b] = relation[b][a] = true; } vector<bool> fr...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; while (cin >> n >> m, n) { vector<vector<bool>> relation(n, vector<bool>(n)); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; a--; b--; relation[a][b] = relation[b][a] = true; } vector<bool> fr...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
207
2
#include <cstdio> #include <cstring> #include <queue> using namespace std; #define REP(i, a, b) for (i = a; i < b; ++i) #define rep(i, n) REP(i, 0, n) int graph[500][500], dist[500]; int main() { int n, m, i, j, k, a, b; for (;;) { scanf("%d", &n); scanf("%d", &m); if (!n) break; memset(gra...
#include <cstdio> #include <cstring> #include <queue> using namespace std; #define REP(i, a, b) for (i = a; i < b; ++i) #define rep(i, n) REP(i, 0, n) int graph[500][500], dist[500]; int main() { int n, m, i, j, k, a, b; for (;;) { scanf("%d", &n); scanf("%d", &m); if (!n) break; memset(gra...
[["-", 31, 69, 28, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 31, 22], ["-", 12, 11, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 12, 11, 31, 69, 341, 342, 0, 16, 31, 22]]
1
293
4
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using nam...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using nam...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
535
2
#include <iostream> #include <vector> using namespace std; int main() { int N, M; while (cin >> N >> M, N || M) { vector<int> v[500]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; v[a - 1].push_back(b - 1); v[b - 1].push_back(a - 1); } bool f[500] = {0}; for (...
#include <iostream> #include <vector> using namespace std; int main() { int N, M; while (cin >> N >> M, N || M) { vector<int> v[500]; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; v[a - 1].push_back(b - 1); v[b - 1].push_back(a - 1); } bool f[500] = {0}; for (...
[["+", 28, 69, 341, 342, 0, 69, 28, 69, 28, 22], ["+", 341, 342, 0, 69, 28, 69, 341, 342, 0, 70], ["+", 341, 342, 0, 69, 28, 69, 341, 342, 0, 13], ["+", 341, 342, 0, 69, 28, 69, 341, 342, 0, 73], ["+", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
222
6
#include <algorithm> #include <iostream> #include <map> #include <vector> #define F first #define S second using namespace std; typedef pair<int, int> P; int main() { int n, m; P p; while (cin >> n >> m && n && m) { int ans = 0; bool matrix[n + 2][n + 2]; for (int i = 0; i < n + 2; i++) for (i...
#include <algorithm> #include <iostream> #include <map> #include <vector> #define F first #define S second using namespace std; typedef pair<int, int> P; int main() { int n, m; P p; while (cin >> n >> m && n && m) { int ans = 0; bool matrix[n + 2][n + 2]; for (int i = 0; i < n + 2; i++) for (i...
[["-", 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, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 7, 10...
1
314
12
#include <algorithm> #include <cstring> #include <iostream> using namespace std; bool invite[500]; bool are_friend[500][500]; int main() { int n, m; while (cin >> n >> m, n || m) { memset(invite, false, sizeof(invite)); memset(are_friend, false, sizeof(are_friend)); for (int i = 0; i < m; i++) { ...
#include <algorithm> #include <cstring> #include <iostream> using namespace std; bool invite[500]; bool are_friend[500][500]; int main() { int n, m; while (cin >> n >> m, n || m) { memset(invite, false, sizeof(invite)); memset(are_friend, false, sizeof(are_friend)); for (int i = 0; i < m; i++) { ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
1
213
4
#include <cstdio> #include <iostream> using namespace std; int main() { int n, m; while (1) { scanf("%d%d", &n, &m); if (n == 0 && m == 0) break; bool a[501][501] = {{0}}; bool mem[501] = {0}; bool mem1[501] = {0}; for (int i = 0; i < m; i++) { int f, t; scanf("%d%d", &f, &...
#include <cstdio> #include <iostream> using namespace std; int main() { int n, m; while (1) { scanf("%d%d", &n, &m); if (n == 0 && m == 0) break; bool a[501][501] = {{0}}; bool mem[501] = {0}; bool mem1[501] = {0}; for (int i = 0; i < m; i++) { int f, t; scanf("%d%d", &f, &...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 73]]
1
290
5
#include <iostream> using namespace std; int main() { int n, m; int in[10010][2]; bool a[10010]; bool b[10010]; while (cin >> n >> m, n | m) { for (int i = 0; i < 10010; i++) { a[i] = false; b[i] = false; } for (int i = 0; i < m; i++) { cin >> in[i][0] >> in[i][1]; } ...
#include <iostream> using namespace std; int main() { int n, m; int in[10010][2]; bool a[10010]; bool b[10010]; while (cin >> n >> m, n | m) { for (int i = 0; i < 10010; i++) { a[i] = false; b[i] = false; } for (int i = 0; i < m; i++) { cin >> in[i][0] >> in[i][1]; } ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
332
4
#include <algorithm> #include <cstdio> #include <cstring> int fr[501]; int c[10001], d[10001]; using namespace std; int main(void) { int n, m; int a, b; while (scanf("%d%d", &n, &m)) { if (n == 0 && m == 0) break; for (int i = 0; i < 501; i++) fr[i] = 0, c[i] = 0, d[i] = 0; int j = 0; ...
#include <algorithm> #include <cstdio> #include <cstring> int fr[501]; int c[10001], d[10001]; using namespace std; int main(void) { int n, m; int a, b; while (scanf("%d%d", &n, &m)) { if (n == 0 && m == 0) break; for (int i = 0; i < 501; i++) fr[i] = 0, c[i] = 0, d[i] = 0; int j = 0; ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
314
2
#include <algorithm> #include <iostream> using namespace std; int main() { while (1) { int n, m; cin >> n; if (n == 0) break; cin >> m; bool t[502][502]; for (int i = 1; i <= n; i++) { fill(t[i] + 1, t[i] + n + 1, false); } for (int i = 0; i < m; i++) { int a, b;...
#include <algorithm> #include <iostream> using namespace std; int main() { while (1) { int n, m; cin >> n; if (n == 0) break; cin >> m; bool t[502][502]; for (int i = 1; i <= n; i++) { fill(t[i] + 1, t[i] + n + 1, false); } for (int i = 0; i < m; i++) { int a, b;...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
225
2
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <...
[["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13]]
1
403
2
while True: n = int(input()) m = int(input()) if n==0: break tab = [[] for _ in range(n)] for _ in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 tab[a].append(b) tab[b].append(a) ans = set(tab[0]) foff = set() for i in ans: foff = ...
while True: n = int(input()) m = int(input()) if n==0: break tab = [[] for _ in range(n)] for _ in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 tab[a].append(b) tab[b].append(a) ans = set(tab[0]) foff = set() for i in ans: foff = ...
[["-", 0, 652, 3, 4, 0, 657, 12, 282, 0, 612], ["+", 0, 652, 3, 4, 0, 657, 12, 282, 0, 612]]
5
131
2
while True: n = int(input()); m = int(input()); if n==0 and m==0: break e = [[0 for i in range(501)] for j in range(501)] u = [0]*501; ans = 0; for i in range(m): f,t = list(map(int, input().split())) e[f][t] = e[t][f] = 1 for i in range(2,n): if e[1][i]==1: i...
while True: n = int(input()); m = int(input()); if n==0 and m==0: break e = [[0 for i in range(501)] for j in range(501)] u = [0]*501; ans = 0; for i in range(m): f,t = list(map(int, input().split())) e[f][t] = e[t][f] = 1 for i in range(2,n+1): if e[1][i]==1: ...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
192
4
import sys import itertools readline = sys.stdin.readline while True: N = int(readline()) M = int(readline()) if N == 0 and M == 0: break pairs = set() for _ in range(M): a, b = tuple(int(x) for x in readline().split()) pairs.add((a, b)) pairs.add((b, a)) cnt = 0...
import sys import itertools readline = sys.stdin.readline while True: N = int(readline()) M = int(readline()) if N == 0 and M == 0: break pairs = set() for _ in range(M): a, b = tuple(int(x) for x in readline().split()) pairs.add((a, b)) pairs.add((b, a)) cnt = 0...
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
159
1
#include <stdio.h> #include <string.h> void addcard(char[], char[], char[], int[], int, int, int, int *); int main(void) { char cards[10 * 6000]; char nowcard[10]; char cardkouho[3 * 10]; int cardmaisuu; int sentakumaisuu; int cardnokori[10]; int i; int result; while (1) { scanf("%d", &cardmaisu...
#include <stdio.h> #include <string.h> void addcard(char[], char[], char[], int[], int, int, int, int *); int main(void) { char cards[10 * 6000]; char nowcard[10]; char cardkouho[3 * 10]; int cardmaisuu; int sentakumaisuu; int cardnokori[10]; int i; int result; while (1) { scanf("%d", &cardmaisu...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
476
1
#include <bits/stdc++.h> #define LL long long static const LL INF = 1 << 50; using namespace std; int n, k, ans = 1; vector<string> s; string num[11]; int t = 0; void cal(string sum, int depth, int bit) { if (depth == k) { s.push_back(sum); return; } for (int i = 1; i <= n; ++i) { int b = 1 << i; ...
#include <bits/stdc++.h> #define LL long long static const LL INF = 1 << 50; using namespace std; int n, k, ans = 1; vector<string> s; string num[11]; int t = 0; void cal(string sum, int depth, int bit) { if (depth == k) { s.push_back(sum); return; } for (int i = 1; i <= n; ++i) { int b = 1 << i; ...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
1
280
2
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, sum; cin >> a >> b >> c >> d; sum = a + b + c + d; int m = sum / 60; int s = sum % 60; cout << m << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, sum; cin >> a >> b >> c >> d; sum = a + b + c + d; int m = sum / 60; int s = sum % 60; cout << m << endl; cout << s << endl; return 0; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
68
4
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vecto...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vecto...
[["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
167
2
#include <cstdio> int a, b, c, d; main() { scanf("%d%d%d%d", &a, &b, &c, &d); printf("%d %d\n", (a + b + c + d) / 60, (a + b + c + d) % 60); }
#include <cstdio> int a, b, c, d; main() { scanf("%d%d%d%d", &a, &b, &c, &d); printf("%d\n%d\n", (a + b + c + d) / 60, (a + b + c + d) % 60); }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
67
4
#include <iostream> using namespace std; int main() { int n; int sum = 0; while (cin >> n) sum += n; cout << sum / 60 << " " << sum % 60 << endl; return 0; }
#include <iostream> using namespace std; int main() { int n; int sum = 0; while (cin >> n) sum += n; cout << sum / 60 << endl << sum % 60 << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
49
4
#include <iostream> #include <string> using namespace std; int main() { int a; cin >> a; int b; cin >> b; int c; cin >> c; int d; cin >> d; int e; e = a + b + c + d; int f; f = 0; while (e >= 60) { f = f + 1; e = e - 60; } cout << e << endl; cout << f << endl; }
#include <iostream> #include <string> using namespace std; int main() { int a; cin >> a; int b; cin >> b; int c; cin >> c; int d; cin >> d; int e; e = a + b + c + d; int f; f = 0; while (e >= 60) { f = f + 1; e = e - 60; } cout << f << endl; cout << e << endl; }
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
94
4
#include <cstdio> int main() { int sum = 0; for (int i = 0; i < 4; ++i) { int t; scanf("%d", &t); sum += t; } printf("%d %d\n", sum / 60, sum % 60); return 0; }
#include <cstdio> int main() { int sum = 0; for (int i = 0; i < 4; ++i) { int t; scanf("%d", &t); sum += t; } printf("%d\n%d\n", sum / 60, sum % 60); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
65
4
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { int a = 0, b, c; for (int i = 0; i < 4; i++) { cin >> b; a += b; } printf("%d\n", a / 60); a -= a / 60; printf("%d\n", a / 60); return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { int a = 0, b, c; for (int i = 0; i < 4; i++) { cin >> b; a += b; } printf("%d\n", a / 60); a -= a / 60 * 60; printf("%d\n", a); return 0; }
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 85], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
84
4
#include <cctype> #include <iostream> #include <map> #include <queue> #include <stdio.h> using namespace std; int main(int argc, char const *argv[]) { int time = 0; int tmp; for (int i = 0; i < 4; i++) { cin >> tmp; time += time; } cout << time / 60 << endl; cout << time % 60 << endl; return 0; ...
#include <cctype> #include <iostream> #include <map> #include <queue> #include <stdio.h> using namespace std; int main(int argc, char const *argv[]) { int time = 0; int tmp; for (int i = 0; i < 4; i++) { cin >> tmp; time += tmp; } cout << time / 60 << endl; cout << time % 60 << endl; return 0; }
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22]]
1
80
2
#include <stdio.h> int main(void) { int x, y, sum; int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); sum = a + b + c + d; x = 0; while (sum > 60) { sum = sum - 60; x++; } y = sum; printf("%d\n%d\n", x, y); return 0; }
#include <stdio.h> int main(void) { int x, y, sum; int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); sum = a + b + c + d; x = 0; while (sum >= 60) { sum = sum - 60; x++; } y = sum; printf("%d\n%d\n", x, y); return 0; }
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 20]]
1
96
2
#include <iostream> using namespace std; int main() { int n = 0, m; for (int i = 0; i < 4; i++) { cin >> m; n += m; } cout << n / 60 << n % 60 << endl; return 0; }
#include <iostream> using namespace std; int main() { int n = 0, m; for (int i = 0; i < 4; i++) { cin >> m; n += m; } cout << n / 60 << endl << n % 60 << endl; return 0; }
[["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
58
2
#include <algorithm> #include <iostream> using namespace std; int main() { int a, ans = 0; for (int i = 0; i < 4; i++) { cin >> a; ans += a; } cout << ans / 60 << ans - (ans / 60 * 60) << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int a, ans = 0; for (int i = 0; i < 4; i++) { cin >> a; ans += a; } cout << ans / 60 << endl << ans - (ans / 60 * 60) << endl; return 0; }
[["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
66
2
#include <stdio.h> #include <string.h> int main() { char ch[21]; char ring[21]; int n, i, j, count = 0; scanf("%s\n%d\n", &ch, &n); for (i = 0; i < n; i++) { scanf("%s\n", &ring); for (j = 0; j < 10; j++) { ring[10 + j] = ring[j]; } ring[10 + j] = '\0'; if (strstr(ch, ring)) co...
#include <stdio.h> #include <string.h> int main() { char ch[21]; char ring[21]; int n, i, j, count = 0; scanf("%s\n%d\n", &ch, &n); for (i = 0; i < n; i++) { scanf("%s\n", &ring); for (j = 0; j < 10; j++) { ring[10 + j] = ring[j]; } ring[10 + j] = '\0'; if (strstr(ring, ch)) co...
[["-", 0, 57, 15, 23, 0, 2, 3, 4, 0, 22], ["-", 0, 57, 15, 23, 0, 2, 3, 4, 0, 21], ["+", 0, 57, 15, 23, 0, 2, 3, 4, 0, 21], ["+", 0, 57, 15, 23, 0, 2, 3, 4, 0, 22]]
0
138
4
#include <stdio.h> #include <string.h> int main() { int n, i, j, k, res = 0; char search[20], ring[20]; scanf("%s", search); scanf("%d\n", &n); res = n; for (i = 0; i < n; i++) { scanf("%s", ring); int found = 0; for (j = 0; j < 10 && found == 0; j++) { found = 1; for (k = 0; k < str...
#include <stdio.h> #include <string.h> int main() { int n, i, j, k, res = 0; char search[20], ring[20]; scanf("%s", search); scanf("%d\n", &n); res = 0; for (i = 0; i < n; i++) { scanf("%s", ring); int found = 0; for (j = 0; j < 10 && found == 0; j++) { found = 1; for (k = 0; k < str...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
0
176
2
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int n; cin >> n; int co = 0; int c = 0; for (int i = 0; i < n; i++) { string str; cin >> str; str += str; for (int j = 0; j < 10; j++) { string a; a.assign(str, j, (int)s.size()); ...
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int n; cin >> n; int co = 0; int c = 0; for (int i = 0; i < n; i++) { string str; cin >> str; str += str; for (int j = 0; j < 10; j++) { string a; a.assign(str, j, (int)s.size()); ...
[["+", 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
129
4
#include <stdio.h> #include <string.h> int main(void) { int n, i, j; int cnt; char a[10], m[20], b[10]; cnt = 0; scanf("%s %d", a, &n); for (i = 0; i < n; i++) { scanf("%s", m); strcpy(b, m); strcat(m, b); if (strstr(m, a)) { cnt++; } printf("%d\n", cnt); } return 0; }
#include <stdio.h> #include <string.h> int main(void) { int n, i, j; int cnt; char a[11], m[21], b[11]; cnt = 0; scanf("%s %d", a, &n); for (i = 0; i < n; i++) { scanf("%s", m); strcpy(b, m); strcat(m, b); if (strstr(m, a)) { cnt++; } } printf("%d\n", cnt); return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
118
8
#include <iostream> #include <string> #pragma warning(disable : 4996) using namespace std; int main() { string s1, s2; int n, cnt = 0; cin >> s1; cin >> n; for (int i = 0; i < n; i++) { cin >> s2; s2 += s2; for (int j = 0; j < s2.size() / 2; j++) { if (s2.substr(j, s1.size()) == s1) { ...
#include <iostream> #include <string> #pragma warning(disable : 4996) using namespace std; int main() { string s1, s2; int n, cnt = 0; cin >> s1; cin >> n; for (int i = 0; i < n; i++) { cin >> s2; s2 += s2; for (int j = 0; j < s2.size() / 2; j++) { if (s2.substr(j, s1.size()) == s1) { ...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
113
16
#include <iostream> using namespace std; int main() { string x; int n, y = 0; cin >> x >> n; for (int i = 2; i < (n + 2); i++) { string s; cin >> s; if (s.find(x) <= 10) { y++; } } cout << y << endl; return 0; }
#include <iostream> using namespace std; int main() { string x; int n, y = 0; cin >> x >> n; for (int i = 2; i < (n + 2); i++) { string s; cin >> s; s = s + s; if (s.find(x) <= 10) { y++; } } cout << y << endl; return 0; }
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
80
6
#include <bits/stdc++.h> #define PB push_back #define MP make_pair #define REP(i, n) for (int i = 0; i < (n); i++) #define INF (1 << 29) using namespace std; typedef long long ll; int main() { string s; int n; int cnt = 0; cin >> s; cin >> n; REP(i, n) { string t; cin >> t; t += t; REP(i, t....
#include <bits/stdc++.h> #define PB push_back #define MP make_pair #define REP(i, n) for (int i = 0; i < (n); i++) #define INF (1 << 29) using namespace std; typedef long long ll; int main() { string s; int n; int cnt = 0; cin >> s; cin >> n; REP(i, n) { string t; cin >> t; t += t; REP(i, t....
[["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["+", 64, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 64, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
1
154
4
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <string> using namespace std; int main() { int n, a, cut = 0; string ring, f; cin >> f >> n; for (int i = 0; i < n; i++) { a = 0; cin >> ring; int a = ring.find(f); if (a >= 0...
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <string> using namespace std; int main() { int n, a, cut = 0; string ring, f; cin >> f >> n; for (int i = 0; i < n; i++) { a = 0; cin >> ring; ring += ring; int a = ring.find(...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
96
4
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0, l, jud = 0; string s; cin >> s; cin >> n; l = s.size(); for (int i = 1; i <= n; i++) { string t; cin >> t; t += t; int a = 0; for (int k = 0; k <= t.size(); k++) { if (s[0] == t[k]) { for (int ...
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0, l, jud = 0; string s; cin >> s; cin >> n; l = s.size(); for (int i = 1; i <= n; i++) { string t; cin >> t; t += t; int a = 0; for (int k = 0; k <= t.size(); k++) { if (s[0] == t[k]) { for (int b ...
[["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
176
2
#include <iostream> #include <string> using namespace std; int main() { string A, S, T; int P = 0; int n; cin >> A; cin >> n; for (int i = 0; i < n; i++) { cin >> S; T = S + S; for (int j = 0; j < n; j++) { if (T.substr(j, A.length()) == A) { P++; break; } } } ...
#include <iostream> #include <string> using namespace std; int main() { string A, S, T; int P = 0; int n; cin >> A; cin >> n; for (int i = 0; i < n; i++) { cin >> S; T = S + S; for (int j = 0; j < 10; j++) { if (T.substr(j, A.length()) == A) { P++; break; } } }...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
112
2
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> int main(void) { char str[11], ring[100][11]; int number, str_len; scanf("%s", str); str_len = strlen(str); scanf("%d", &number); for (int i = 0; i < number; i++) { scanf("%s", ring[i]); } int ring_count = 0, ring_len; for (...
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> int main(void) { char str[11], ring[100][11]; int number, str_len; scanf("%s", str); str_len = strlen(str); scanf("%d", &number); for (int i = 0; i < number; i++) { scanf("%s", ring[i]); } int ring_count = 0, ring_len; for (...
[["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
268
2
#include <cstring> #include <iostream> using namespace std; int main() { int ringCount = 0; int findCount = 0; char targetStr[11]; char tempRing[11]; int targetStringLength; int tempStringLength; bool isSame = true; cin >> targetStr >> ringCount; targetStringLength = strlen(targetStr); for (int i =...
#include <cstring> #include <iostream> using namespace std; int main() { int ringCount = 0; int findCount = 0; char targetStr[11]; char tempRing[11]; int targetStringLength; int tempStringLength; bool isSame = true; cin >> targetStr >> ringCount; targetStringLength = strlen(targetStr); for (int i =...
[["+", 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, 146], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
171
4
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" int m...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" int m...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
117
4
#include <bits/stdc++.h> using namespace std; #define Rep(i, N) for (int i = 0; i < N; i++) int main() { string w, s; int N; cin >> N; int cnt = 0; Rep(i, N) { cin >> s; s += s; cnt += s.find(w) != string::npos; } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define Rep(i, N) for (int i = 0; i < N; i++) int main() { string w, s; int N; cin >> w >> N; int cnt = 0; Rep(i, N) { cin >> s; s += s; cnt += s.find(w) != string::npos; } cout << cnt << endl; return 0; }
[["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]]
1
75
2
#include <iostream> #include <string> using namespace std; int main() { string s, t; int n, c = 0; cin >> s >> n; for (int i = 0; i < n; i++) { cin >> t; if ((s + s).find(t) != string::npos) c++; } cout << c << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { string s, t; int n, c = 0; cin >> s >> n; for (int i = 0; i < n; i++) { cin >> t; if ((t + t).find(s) != string::npos) c++; } cout << c << endl; return 0; }
[["-", 31, 2, 63, 118, 28, 23, 0, 16, 31, 22], ["+", 31, 2, 63, 118, 28, 23, 0, 16, 31, 22], ["-", 31, 2, 63, 118, 28, 23, 0, 16, 12, 22], ["+", 31, 2, 63, 118, 28, 23, 0, 16, 12, 22], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 22]]
1
81
6
#include <stdio.h> #include <string.h> int main() { char a[100], b[100], str[100]; int i, j, cnt = 0, n; scanf("%s", str); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", a); strcpy(a, a); if (strstr(b, str) != 0) { cnt++; } } printf("%d\n", cnt); }
#include <stdio.h> #include <string.h> int main() { char a[100], b[100], str[100]; int i, j, cnt = 0, n; scanf("%s", str); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", a); strcat(a, a); if (strstr(a, str) != 0) { cnt++; } } printf("%d\n", cnt); }
[["-", 0, 7, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 22]]
1
113
4
#include <iostream> using namespace std; #include <string.h> int main() { int c = 0, i, n; char a[10], b[10], z[100]; cin >> a >> n; for (i = 0; i <= n; i++) { cin >> b; strcpy(z, b); strcat(z, b); if (strstr(z, a)) c++; } cout << c << endl; return 0; }
#include <iostream> using namespace std; #include <string.h> int main() { int c = 0, i, n; char a[10], b[10], z[100]; cin >> a >> n; for (i = 0; i < n; i++) { cin >> b; strcpy(z, b); strcat(z, b); if (strstr(z, a)) c++; } cout << c << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
99
2
#include <algorithm> #include <functional> #include <iostream> #include <limits> #include <map> #include <string> #include <vector> using namespace std; int main() { string s, f; int n; cin >> s >> n; int ans = 0; for (int i = 0; i < n; i++) { cin >> f; f += f; for (int j = 0; j < f.size() - s.si...
#include <algorithm> #include <functional> #include <iostream> #include <limits> #include <map> #include <string> #include <vector> using namespace std; int main() { string s, f; int n; cin >> s >> n; int ans = 0; for (int i = 0; i < n; i++) { cin >> f; f += f; for (int j = 0; j < f.size() - s.si...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
121
2
#include <stdio.h> #include <string.h> int main() { char t[11], s[11], b[11]; int n, r; scanf("%s%d", t, &n); for (int i = 0; i < n; i++) { scanf("%s", s); for (int j = 0; j < 10; j++) { b[0] = s[9]; for (int k = 0; k < 9; k++) { b[k + 1] = s[k]; } strcpy(s, b); if ...
#include <stdio.h> #include <string.h> int main() { char t[11], s[11], b[11]; int n, r = 0; scanf("%s%d", t, &n); for (int i = 0; i < n; i++) { scanf("%s", s); for (int j = 0; j < 10; j++) { b[0] = s[9]; for (int k = 0; k < 9; k++) { b[k + 1] = s[k]; } strcpy(s, b); ...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
1
163
4
#include <cstring> #include <iostream> #include <string> using namespace std; int main() { char S[15], T[15]; cin >> S; int n, sum = 0; cin >> n; for (int i = 0; i < n; i++) { char TS[30]; cin >> TS; strcpy(T, TS); strcat(TS, T); if ((strstr(S, TS) == NULL)) { sum++; } } c...
#include <cstring> #include <iostream> #include <string> using namespace std; int main() { char S[15], T[15]; cin >> S; int n, sum = 0; cin >> n; for (int i = 0; i < n; i++) { char TS[30]; cin >> TS; strcpy(T, TS); strcat(TS, T); if (!(strstr(TS, S) == NULL)) { sum++; } } c...
[["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["-", 51, 23, 0, 16, 31, 2, 3, 4, 0, 22], ["-", 51, 23, 0, 16, 31, 2, 3, 4, 0, 21], ["+", 28, 23, 0, 16, 31, 2, 3, 4, 0, 21], ["+", 28, 23, 0, 16, 31, 2, 3, 4, 0, 22]]
1
106
5
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string findStr; int n; cin >> findStr; cin >> n; int cnt = 0; for (int i = 0; i < n; i++) { string str; cin >> str; // ใƒ„้–‹ใƒ„ๅง‹ใƒ„ๅœฐใƒ„็‚นใƒ„ใฅใƒผใƒ„ใฅใคใ‚ขใƒ„ใฅๅฏใคใ‚ญใƒ„ใฅใ‚ฅใƒ„ใคใ‚ฅ for (int j = 0; j < str.size()...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string findStr; int n; cin >> findStr; cin >> n; int cnt = 0; for (int i = 0; i < n; i++) { string str; cin >> str; // ใƒ„้–‹ใƒ„ๅง‹ใƒ„ๅœฐใƒ„็‚นใƒ„ใฅใƒผใƒ„ใฅใคใ‚ขใƒ„ใฅๅฏใคใ‚ญใƒ„ใฅใ‚ฅใƒ„ใคใ‚ฅ for (int j = 0; j < str.size()...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
163
2
#include <iostream> #include <string> typedef unsigned long long ull; const ull B = 100000007; using namespace std; int RabinKarp(string, string); int main(void) { string a, b; int n, count = 0; getline(cin, a); cin >> n; cin.ignore(); for (int i = 0; i < n; i++) { getline(cin, b); count += R...
#include <iostream> #include <string> typedef unsigned long long ull; const ull B = 100000007; using namespace std; int RabinKarp(string, string); int main(void) { string a, b; int n, count = 0; getline(cin, a); cin >> n; cin.ignore(); for (int i = 0; i < n; i++) { getline(cin, b); b += b; ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
261
4
#include <algorithm> #include <iostream> using namespace std; int main() { string lookingfor; string ring; int ans = 0; int n; cin >> lookingfor; cin >> n; for (int i = 0; i < n; i++) { cin >> ring; if (ring.find(lookingfor, 0) != string::npos) ans++; } cout << ans << endl; }
#include <algorithm> #include <iostream> using namespace std; int main() { string lookingfor; string ring; int ans = 0; int n; cin >> lookingfor; cin >> n; for (int i = 0; i < n; i++) { cin >> ring; ring += ring; if (ring.find(lookingfor, 0) != string::npos) ans++; } cout << ans ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
80
4
str=gets.chomp n=gets.chomp.to_i count=0 n.times do str2=gets.chomp if str2.include?(str) count+=1 end end p count
str=gets.chomp n=gets.chomp.to_i count=0 n.times do str2=gets.chomp if (str2+str2).include?(str) count+=1 end end p count
[["+", 8, 736, 0, 121, 15, 652, 486, 739, 0, 24], ["+", 0, 121, 15, 652, 486, 739, 0, 738, 31, 22], ["+", 0, 121, 15, 652, 486, 739, 0, 738, 17, 72], ["+", 8, 736, 0, 121, 15, 652, 486, 739, 0, 25]]
4
38
4
target_str = gets.strip.to_s N = gets.to_i count = 0 N.times do |i| str = gets..strip.to_s if (str+str).index(target_str) count += 1 end end p count
target_str = gets.strip.to_s N = gets.to_i count = 0 N.times do |i| str = gets.strip.to_s if (str+str).index(target_str) count += 1 end end p count
[["-", 196, 737, 8, 736, 0, 662, 12, 475, 17, 757], ["+", 8, 736, 0, 662, 12, 652, 486, 652, 17, 131]]
4
47
2
s = input() n = eval(input()) ans = 0 for i in range(n): t = input() t2 = t+t for j in range(len(t)): if s==t[j:j+len(s)]: ans += 1 break print(ans)
s = input() n = eval(input()) ans = 0 for i in range(n): t = input() t2 = t+t for j in range(len(t)): if s==t2[j:j+len(s)]: ans += 1 break print(ans)
[["-", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22]]
5
68
2
s=input() print(sum(len(2*input().split(s))>1 for _ in range(int(input()))))
s=input() print(sum(len((2*input()).split(s))>1 for _ in range(int(input()))))
[["+", 3, 4, 0, 652, 63, 319, 500, 23, 0, 24], ["+", 500, 23, 0, 657, 12, 652, 3, 4, 0, 25]]
5
38
2
import sys R = lambda:list(map(int,input().split())) s = input() l = len(s) #print s, l n = int(input()) neko = 0 for i in range(n): ring = input() #print ring rings = ring + ring #print rings for i in range(len(ring)): cc = [] for j in range(l): cc.append(rings[i+j]) ...
import sys R = lambda:list(map(int,input().split())) s = input() l = len(s) #print s, l n = int(input()) neko = 0 for i in range(n): ring = input() #print ring rings = ring + ring #print rings for i in range(len(ring)): cc = [] for j in range(l): cc.append(rings[i+j]) ...
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
120
1
#!/usr/bin/ruby while(n=gets.to_i)>0 k=gets.to_i h={} n.times.map{gets.chomp}.permutation(k){|a|h[a]=1} p h.size end
while(n=gets.to_i)>0 k=gets.to_i h={} n.times.map{gets.chomp}.permutation(k){|a|h[a*'']=1} p h.size end
[["+", 8, 734, 0, 662, 31, 742, 0, 738, 17, 48], ["+", 0, 662, 31, 742, 0, 738, 12, 557, 0, 62]]
4
51
3
from itertools import permutations as P import sys r=sys.stdin.readline for e in iter(r,'0\n'): n,k=int(e),int(r()) C=[r()for _ in[0]*n] print(len(set(''.join(s)for s in P(C,k))))
from itertools import permutations as P import sys r=sys.stdin.readline for e in iter(r,'0\n'): n,k=int(e),int(r()) C=[r()[:-1]for _ in[0]*n] print(len(set(''.join(s)for s in P(C,k))))
[["+", 0, 1, 0, 662, 12, 658, 8, 206, 0, 70], ["+", 0, 662, 12, 658, 8, 206, 206, 663, 0, 102], ["+", 12, 658, 8, 206, 206, 663, 0, 664, 17, 33], ["+", 12, 658, 8, 206, 206, 663, 0, 664, 28, 612], ["+", 0, 1, 0, 662, 12, 658, 8, 206, 0, 73]]
5
83
5
#include <stdio.h> int nx, ny, mem0[101][101], mem1[101][101]; int b(int, int, int); int b(int x, int y, int xy) { if (xy == 0 && mem0[x][y] != 0) return mem0[x][y]; else if (xy == 1 && mem1[x][y] != 0) return mem1[x][y]; if (x == nx && y == ny) return 1; else if (x > nx || y > ny) return 0; ...
#include <stdio.h> int nx, ny, mem0[101][101], mem1[101][101]; int b(int, int, int); int b(int x, int y, int xy) { if (xy == 0 && mem0[x][y] != 0) return mem0[x][y]; else if (xy == 1 && mem1[x][y] != 0) return mem1[x][y]; if (x == nx && y == ny) return 1; else if (x > nx || y > ny) return 0; ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
0
431
4
#include <stdio.h> #define MOD 100000 struct DP { int up, right, tup, tright, way; } dp[100][100]; int main() { int i, j = 0; for (i = 0; i <= 100; i++) { for (j = 0; j <= 100; j++) { if (i == 0 || j == 0) { dp[i][j].up = 0; dp[i][j].right = 0; dp[i][j].tup = 0; dp[i][j]...
#include <stdio.h> #define MOD 100000 struct DP { int up, right, tup, tright, way; } dp[101][101]; int main() { int i, j = 0; for (i = 0; i <= 100; i++) { for (j = 0; j <= 100; j++) { if (i == 0 || j == 0) { dp[i][j].up = 0; dp[i][j].right = 0; dp[i][j].tup = 0; dp[i][j]...
[["-", 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
431
4
#include <bits/stdc++.h> using namespace std; const int mod = 100000; int main() { int w, h; while (cin >> w >> h, w) { int dp[110][110][4] = {}; dp[1][0][2] = dp[0][1][3] = 1; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i > 0) { (dp[i][j][0] += dp[i - 1][j...
#include <bits/stdc++.h> using namespace std; const int mod = 100000; int main() { int w, h; while (cin >> w >> h, w) { int dp[110][110][4] = {}; dp[1][0][0] = dp[0][1][1] = 1; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i > 0) { (dp[i][j][0] += dp[i - 1][j...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["-", 0, 11, 12, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 11, 12, 11, 31, 69, 341, 342, 0, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 49, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 49, 22], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0...
1
306
12
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define LL long long static const LL INF = 1 << 24; static const LL LL_INF = 1 << 60; static const int mod = 1e+5; static const int MAX_N = 200; int dx[] = {0, 1}; int dy[] = {1, 0}; using namespace std; int w, h; LL mem[MAX_N][MAX_N][3][3][3][...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define LL long long static const LL INF = 1 << 24; static const LL LL_INF = 1 << 60; static const int mod = 1e+5; static const int MAX_N = 200; int dx[] = {0, 1}; int dy[] = {1, 0}; using namespace std; int w, h; LL mem[MAX_N][MAX_N][3][3][3][...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
407
2
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int a[101][101][4], h, w; main() { while (cin >> h >> w, h) { int ans = 0; memset(a, 0, sizeof(a)); r(i, 101) a[0][i][3] = 1; r(i, 101) a[i][0][2] = 1; for (int i = 1; i < h; i++) for (int j = 1; j < w;...
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int a[101][101][4], h, w; main() { while (cin >> h >> w, h) { int ans = 0; memset(a, 0, sizeof(a)); r(i, 101) a[0][i][3] = 1; r(i, 101) a[i][0][2] = 1; for (int i = 1; i < h; i++) for (int j = 1; j < w;...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
302
2
#include <algorithm> #include <iostream> using namespace std; const int MOD = 100000; int main() { int w, h; while (cin >> w >> h, w | h) { int dp[101][101][5] = {0}; for (int i = 1; i <= h; i++) dp[i][1][1] = 1; for (int i = 1; i <= w; i++) dp[1][i][3] = 1; for (int y = 2; y <= h; ...
#include <algorithm> #include <iostream> using namespace std; const int MOD = 100000; int main() { int w, h; while (cin >> w >> h, w | h) { int dp[101][101][5] = {0}; for (int i = 1; i <= h; i++) dp[i][1][1] = 1; for (int i = 1; i <= w; i++) dp[1][i][3] = 1; for (int y = 2; y <= h; ...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
315
2
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define all(c) (c).begin(), (c).end()...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define all(c) (c).begin(), (c).end()...
[["-", 8, 9, 0, 42, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 42, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 42, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 42, 0, 2, 3, 4, 0, 13]]
1
439
6
#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...
[["+", 0, 52, 8, 9, 0, 43, 39, 86, 0, 87], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
417
5
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int a, b, x, y, ans; int half = n - n / 2; for (int i = 0; i < k; i++) { cin >> a >> b; if (a > half) { if (a == n) { x = 1; } else { x = half - a % half; if (half % 2 == 0) { ...
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int a, b, x, y, ans; int half = n - n / 2; for (int i = 0; i < k; i++) { cin >> a >> b; if (a > half) { if (a == n) { x = 1; } else { x = half - a % half; if (n % 2 == 0) { x...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
216
4
#include <cmath> #include <iostream> using namespace std; int main() { int n, a, b, c, x[1000], y[1000]; cin >> n; cin >> a; for (int i = 0; i < a; i++) { cin >> x[i] >> y[i]; b = min(x[i], n + 1 - x[i]); b = min(b, y[i]); b = min(b, n + 1 - y[i]); if (b % 3 == 0) { c = 3; } else ...
#include <cmath> #include <iostream> using namespace std; int main() { int n, a, b, c, x[1000], y[1000]; cin >> n; cin >> a; for (int i = 0; i < a; i++) { cin >> x[i] >> y[i]; b = min(x[i], n + 1 - x[i]); b = min(b, y[i]); b = min(b, n + 1 - y[i]); if (b % 3 == 0) { c = 3; } else ...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
148
2
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; for (int i = 0; i < k; i++) { int a, b; cin >> a >> b; int mini = min(min(a, n - a + 1), min(b, n - b + 1)); cout << (mini % 3 ? mini : 3) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; for (int i = 0; i < k; i++) { int a, b; cin >> a >> b; int mini = min(min(a, n - a + 1), min(b, n - b + 1)) % 3; cout << (mini ? mini : 3) << endl; } }
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["-", 31, 16, 12, 23, 0, 41, 15, 16, 17, 109], ["-", 31, 16, 12, 23, 0, 41, 15, 16, 12, 13]]
1
92
4
#include <iostream> #include <vector> int main() { int N, n; std::cin >> N >> n; N -= 1; std::vector<int> x(n), y(n), ans(n); for (int i = 0; i < n; i += 1) { std::cin >> x[i] >> y[i]; x[i] -= 1, y[i] -= 1; if (x[i] < y[i]) { if (x[i] + y[i] > N) ans[i] = (N - y[i]) % 3 + 1; el...
#include <iostream> #include <vector> int main() { int N, n; std::cin >> N >> n; N -= 1; std::vector<int> x(n), y(n), ans(n); for (int i = 0; i < n; i += 1) { std::cin >> x[i] >> y[i]; x[i] -= 1, y[i] -= 1; if (x[i] < y[i]) { if (x[i] + y[i] > N) ans[i] = (N - y[i]) % 3 + 1; el...
[["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 25]]
1
233
2
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> using namespace std; #define FOR(I, A, B) for (in...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> using namespace std; #define FOR(I, A, B) for (in...
[["+", 31, 16, 12, 23, 0, 41, 75, 16, 17, 109], ["+", 31, 16, 12, 23, 0, 41, 75, 16, 12, 13]]
1
154
2
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { long long n, k, i, j, x, y, m, s; cin >> n >> k; for (i = 0; i < k; i++) { cin >> x >> y; if (x > n / 2) x = n - x; if (y > n / 2) y = n - y; m = min(x, y); s = m % 3; ...
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { long long n, k, i, j, x, y, m, s; cin >> n >> k; for (i = 0; i < k; i++) { cin >> x >> y; if (x > n / 2) x = n - x + 1; if (y > n / 2) y = n - y + 1; m = min(x, y); s = m...
[["+", 0, 57, 64, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 12, 13]]
1
125
4
#include <algorithm> #include <cstdio> using namespace std; int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < k; ++i) { int a, b; scanf("%d%d", &a, &b); a = min(a, n + 1 - a); b = min(b, n + 1 - b); int x = min(a, b); printf("%d\n", x % 3 + 1); } return 0; }
#include <algorithm> #include <cstdio> using namespace std; int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < k; ++i) { int a, b; scanf("%d%d", &a, &b); a = min(a, n + 1 - a); b = min(b, n + 1 - b); int x = min(a, b); printf("%d\n", (x - 1) % 3 + 1); } return 0; }
[["+", 3, 4, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["+", 3, 4, 0, 16, 31, 16, 31, 23, 0, 25]]
1
119
4
#include "algorithm" #include "climits" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "queue" #include "set" #include "stack" #include "string" using namespace std; const long long int MOD = 1000000007; long long int N, M, K, H, W, L, R; int main() { ios::syn...
#include "algorithm" #include "climits" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "queue" #include "set" #include "stack" #include "string" using namespace std; const long long int MOD = 1000000007; long long int N, M, K, H, W, L, R; int main() { ios::syn...
[["-", 0, 69, 28, 69, 28, 69, 341, 342, 0, 13], ["+", 0, 69, 28, 69, 28, 69, 341, 342, 0, 13]]
1
421
4
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = 1; i <= n; i++) #define drep(i, n) for (int i = n; i >= 0; i--) #define MAX 10001 #define ll long long #define dmp make_pair #define dpb push_back #define P pair<int, int> #define fi first #define se second using name...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = 1; i <= n; i++) #define drep(i, n) for (int i = n; i >= 0; i--) #define MAX 10001 #define ll long long #define dmp make_pair #define dpb push_back #define P pair<int, int> #define fi first #define se second using name...
[["-", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22]]
1
418
2
#include <algorithm> #include <iostream> using namespace std; const int INF = 200000000; int dp[2][2][5002]; int n; int cost[10000]; main() { cin >> n; for (int i = 0; i < n - 1; ++i) { cin >> cost[i]; } fill(dp[0][0], dp[2][0], INF); dp[0][1][0] = 0; dp[0][0][0] = 0; for (int i = 0; i < n - 1; ++...
#include <algorithm> #include <iostream> using namespace std; const int INF = 200000000; int dp[2][2][5002]; int n; int cost[10000]; main() { cin >> n; for (int i = 0; i < n - 1; ++i) { cin >> cost[i]; } fill(dp[0][0], dp[2][0], INF); dp[0][1][1] = 0; dp[0][0][0] = 0; for (int i = 0; i < n - 1; ++...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
362
4
#include <algorithm> #include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; const int INF = 1 << 29; int main() { int n; scanf("%d", &n); int cost[9999]; rep(i, n) scanf("%d", cost + i); int dp[2][5001][2]; rep(j, n / 2 + 1) rep(k, 2) dp[0][j][k] = INF; dp[0][1][0] = 0...
#include <algorithm> #include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; const int INF = 1 << 29; int main() { int n; scanf("%d", &n); int cost[9999]; rep(i, n - 1) scanf("%d", cost + i); int dp[2][5001][2]; rep(j, n / 2 + 1) rep(k, 2) dp[0][j][k] = INF; dp[0][1][0]...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
323
6
// Bokan ga bokka--nn!! // Daily Lunch Special Tanoshii !! #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; type...
// Bokan ga bokka--nn!! // Daily Lunch Special Tanoshii !! #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; type...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13]]
1
538
2
#include <cstdio> #include <cstring> #define min(a, b) ((a) > (b) ? (b) : (a)) int k[10000]; short dp[2][5001][2]; int main() { int N; scanf("%d", &N); for (int i = 0; i < (N - 1); i++) { scanf("%d", &k[i]); } memset(dp, 0x7f, sizeof(dp)); dp[0][0][0] = 0; for (int i = 0; i < N; i++) { int m = min...
#include <cstdio> #include <cstring> #define min(a, b) ((a) > (b) ? (b) : (a)) int k[10000]; short dp[2][5001][2]; int main() { int N; scanf("%d", &N); for (int i = 0; i < (N - 1); i++) { scanf("%d", &k[i]); } memset(dp, 0x7f, sizeof(dp)); dp[0][0][0] = 0; for (int i = 0; i < N; i++) { int m = min...
[["-", 3, 4, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 16, 12, 69, 341, 342, 0, 22]]
1
291
2
#include <iostream> using namespace std; #define N 10000 #define INF 1000000007 #define min(a, b) (a > b ? b : a) int main() { int dp[2][N][2], n, cost; cin >> n; for (int i = 0; i < 2; ++i) { for (int j = 0; j < n; ++j) { dp[i][j][0] = dp[i][j][1] = INF; } } dp[0][1][0] = dp[0][0][1] = 0; f...
#include <iostream> using namespace std; #define N 10000 #define INF 1000000007 #define min(a, b) (a > b ? b : a) int main() { int dp[2][N][2], n, cost; cin >> n; for (int i = 0; i < 2; ++i) { for (int j = 0; j < n; ++j) { dp[i][j][0] = dp[i][j][1] = INF; } } dp[0][1][0] = dp[0][0][1] = 0; f...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 69, 28, 69, 28, 69, 341, 342, 0, 13], ["+", 0, 69, 28, 69, 28, 69, 341, 342, 0, 13]]
1
304
6
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { int time; int len; int no; } ICICLE; int mymax(int a, int b) { if (a > b) { return (a); } return (b); } int comp(const void *a, const void *b) { ICICLE *x, *y; x = (ICICLE *)a; y = (ICICLE *)b; return ((y->len) - (x-...
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { int time; int len; int no; } ICICLE; int mymax(int a, int b) { if (a > b) { return (a); } return (b); } int comp(const void *a, const void *b) { ICICLE *x, *y; x = (ICICLE *)a; y = (ICICLE *)b; return ((y->len) - (x-...
[["+", 15, 23, 0, 16, 31, 118, 28, 69, 28, 22], ["+", 15, 23, 0, 16, 31, 118, 28, 69, 0, 70], ["+", 15, 23, 0, 16, 31, 118, 28, 69, 0, 73], ["+", 0, 57, 15, 23, 0, 16, 31, 118, 17, 131], ["+", 0, 57, 15, 23, 0, 16, 31, 118, 119, 120]]
0
712
5
#include <algorithm> #include <cstdio> #include <iostream> #define MAX_N 100000 using namespace std; int dp[MAX_N + 2]; int field[MAX_N + 2]; int ans; int N; int L; bool shape(int i) { if (field[i] > field[i - 1] && field[i] > field[i + 1]) { return true; } return false; } void search(int now, int cost...
#include <algorithm> #include <cstdio> #include <iostream> #define MAX_N 100000 using namespace std; int dp[MAX_N + 2]; int field[MAX_N + 2]; int ans; int N; int L; bool shape(int i) { if (field[i] > field[i - 1] && field[i] > field[i + 1]) { return true; } return false; } void search(int now, int cost...
[["-", 8, 9, 0, 7, 15, 16, 12, 69, 28, 22], ["-", 0, 7, 15, 16, 12, 69, 341, 342, 0, 70], ["-", 0, 7, 15, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 7, 15, 16, 12, 69, 341, 342, 0, 73], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
359
5
#include <algorithm> #include <cstdio> #include <math.h> #include <queue> #include <string.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) const int INF = 1001001001; pair<int, int> map[100002]; int time[100002]; int main() { int N, L; scanf("%d %d", &N, &L); rep(i, N) { ...
#include <algorithm> #include <cstdio> #include <math.h> #include <queue> #include <string.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) const int INF = 1001001001; pair<int, int> map[100002]; int time[100002]; int main() { int N, L; scanf("%d %d", &N, &L); rep(i, N) { ...
[["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72]]
1
258
4
#include <algorithm> #include <cstdio> #include <vector> #pragma warning(disable : 4996) using namespace std; int N, L, a[100009], dp[100009]; vector<int> x[50009]; int main() { scanf("%d%d", &N, &L); for (int i = 0; i < N; i++) { scanf("%d", &a[i]); x[a[i]].push_back(i + 1); } for (int i = L - 1; i >= ...
#include <algorithm> #include <cstdio> #include <vector> #pragma warning(disable : 4996) using namespace std; int N, L, a[100009], dp[100009]; vector<int> x[50009]; int main() { scanf("%d%d", &N, &L); for (int i = 0; i < N; i++) { scanf("%d", &a[i]); x[a[i]].push_back(i + 1); } for (int i = L - 1; i >= ...
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
181
4
#include <bits/stdc++.h> #define FOR(i, n) for (int i = 0; i < (int)(n); i++) #define FORR(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define pb(a) push_back(a) #define mp(x, y) make_pair(x, y) #define ALL(a) a.begin(), a.end() #define ZERO(a) memset(a, 0, sizeof(a)) #define len(a) sizeof(a) #define ll long lon...
#include <bits/stdc++.h> #define FOR(i, n) for (int i = 0; i < (int)(n); i++) #define FORR(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define pb(a) push_back(a) #define mp(x, y) make_pair(x, y) #define ALL(a) a.begin(), a.end() #define ZERO(a) memset(a, 0, sizeof(a)) #define len(a) sizeof(a) #define ll long lon...
[["-", 0, 37, 0, 11, 12, 16, 12, 69, 28, 22], ["+", 0, 37, 0, 11, 12, 16, 12, 69, 28, 22]]
1
305
2
#include <bits/stdc++.h> using namespace std; #define MAX 123456 typedef pair<int, int> pii; int main() { int N, L, x; cin >> N >> L; priority_queue<pii> pq; for (int i = 0; i < N; i++) { cin >> x; pq.push(pii(x, i + 1)); } int dp[MAX] = {}; while (!pq.empty()) { pii p = pq.top(); pq....
#include <bits/stdc++.h> using namespace std; #define MAX 123456 typedef pair<int, int> pii; int main() { int N, L, x; cin >> N >> L; priority_queue<pii> pq; for (int i = 0; i < N; i++) { cin >> x; pq.push(pii(x, i + 1)); } int dp[MAX] = {}; while (!pq.empty()) { pii p = pq.top(); pq....
[["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 25], ["-", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
1
174
2
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define INF_LL 9000000000000000000 #define INF 2000000000 #define REP(i, n) for (int i = 0; i < (n)...
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define INF_LL 9000000000000000000 #define INF 2000000000 #define REP(i, n) for (int i = 0; i < (n)...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
560
3
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define reps(i, n) for (int i = 1; i <= n; i++) #define INF 1000000000 int main() { int n, T; cin >> n >> T; int trr[110000] = {0}; rep(i, n) cin...
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define reps(i, n) for (int i = 1; i <= n; i++) #define INF 1000000000 int main() { int n, T; cin >> n >> T; int trr[110000] = {0}; rep(i, n) cin...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]]
1
236
4
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, int> P; const ll INF = 1000000000000LL; int main() { int n, l; cin >> n >> l; ll a[100001]; bool used[100001]; fill(used, used + 100001, false); for (int i = 0; i < n; i+...
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, int> P; const ll INF = 1000000000000LL; int main() { int n, l; cin >> n >> l; ll a[100001]; bool used[100001]; fill(used, used + 100001, false); for (int i = 0; i < n; i+...
[["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 22]]
1
771
4
#include <algorithm> #include <cstdio> #include <cstring> #include <map> #include <vector> using namespace std; long long qw[100000], dp[100000], a, b; long long solve(long long k) { if (dp[k] > 0) return dp[k]; if ((k == 0 && qw[k] > qw[k + 1]) || (k == a - 1 && qw[k] > qw[k - 1]) || (qw[k] > qw[k - 1] &...
#include <algorithm> #include <cstdio> #include <cstring> #include <map> #include <vector> using namespace std; long long qw[100000], dp[100000], a, b; long long solve(long long k) { if (dp[k] > 0) return dp[k]; if ((k == 0 && qw[k] > qw[k + 1]) || (k == a - 1 && qw[k] > qw[k - 1]) || (qw[k] > qw[k - 1] &...
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
360
3
#include <algorithm> #include <cstdio> #include <functional> #include <queue> using namespace std; #define MN (100000) int N, L; int I[MN]; typedef pair<int, int> P; int main() { int cnt = 0; int ctime = 0; scanf("%d %d", &N, &L); for (int i = 0; i < N; i++) { scanf("%d", &I[i]); } priority_queue<P, ...
#include <algorithm> #include <cstdio> #include <functional> #include <queue> using namespace std; #define MN (100000) int N, L; int I[MN]; typedef pair<int, int> P; int main() { int cnt = 0; int ctime = 0; scanf("%d %d", &N, &L); for (int i = 0; i < N; i++) { scanf("%d", &I[i]); } priority_queue<P, ...
[["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 21], ["+", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["+", 3, 347, 0, 77, 39, 344, 3, 347, 0, 18], ["+", 0, 77, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 3, 347, 0, 77, 39, 344, 3, 347, 0, 47]]
1
482
5
#include <cstdio> #include <queue> #include <utility> using namespace std; #define max(a, b) ((a) >= (b) ? (a) : (b)) typedef pair<int, int> P; int T[100002]; int main() { priority_queue<P> Q; int N, L; scanf("%d %d", &N, &L); for (int i = 1; i <= N; i++) { int a; scanf("%d", &a); Q.push(P(a, i)); ...
#include <cstdio> #include <queue> #include <utility> using namespace std; #define max(a, b) ((a) >= (b) ? (a) : (b)) typedef pair<int, int> P; int T[100002]; int main() { priority_queue<P> Q; int N, L; scanf("%d %d", &N, &L); for (int i = 1; i <= N; i++) { int a; scanf("%d", &a); Q.push(P(a, i)); ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
207
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define mp...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define mp...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
359
2
n, L = list(map(int, input().split())) dp = [0] * (n+2) l = [0] for i in range(n): l += [eval(input())] dp[i+1] = L - l[i+1] l += [0] for i in range(1,n): if l[i] < l[i-1]: dp[i] = dp[i-1] + (L - l[i]) ans = 0 for i in range(n,0,-1): if l[i] < l[i+1]: dp[i] = max(dp[i], dp[i+1] + (L - l[i])) ...
n, L = list(map(int, input().split())) dp = [0] * (n+2) l = [0] for i in range(n): l += [eval(input())] dp[i+1] = L - l[i+1] l += [0] for i in range(1,n+1): if l[i] < l[i-1]: dp[i] = dp[i-1] + (L - l[i]) ans = 0 for i in range(n,0,-1): if l[i] < l[i+1]: dp[i] = max(dp[i], dp[i+1] + (L - l[i])) ...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
188
13
def orderN(N,L,ices): upPeak = L - ices[0] downPeak = L - ices[0] peaks = [] for i in range(len(ices)): if i < N-1: if ices[i] < ices[i+1]: peaks.append(downPeak) downPeak = L - ices[i+1] upPeak += L - ices[i+1] else: ...
def orderN(N,L,ices): upPeak = L - ices[0] downPeak = L - ices[0] peaks = [] for i in range(len(ices)): if i < N-1: if ices[i] < ices[i+1]: peaks.append(downPeak) downPeak = L - ices[i+1] upPeak += L - ices[i+1] else: ...
[["-", 63, 319, 500, 652, 63, 319, 500, 652, 63, 22], ["+", 63, 319, 500, 652, 63, 319, 500, 652, 63, 22], ["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22]]
5
203
4
def solve(): n,l = map(int,input().split()) length = [int(input()) for i in range(n)] pare = [(length[i], i) for i in range(n)] pare.sort(reverse=True) dp = [0] * (n + 1) for p in pare: i = p[0] if i == 0: dp[i] = dp[i + 1] + (l - length[i]) else: dp[i] = max(dp[i - 1], dp[i + 1])...
def solve(): n,l = map(int,input().split()) length = [int(input()) for i in range(n)] pare = [(length[i], i) for i in range(n)] pare.sort(reverse=True) dp = [0] * (n + 1) for p in pare: i = p[1] if i == 0: dp[i] = dp[i + 1] + (l - length[i]) else: dp[i] = max(dp[i - 1], dp[i + 1])...
[["-", 8, 196, 0, 1, 0, 662, 12, 206, 206, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 206, 612]]
5
154
2
#include <algorithm> #include <cstdio> using namespace std; #define R for (i = 0; i < n; ++i) int a[1 << 17], b[1 << 17], amn = 1e7, amx = -1e7, bmn = 1e7, bmx = -1e7, n, c, d, ow = -1e7, oh = 1e7, i; int main() { scanf("%d", &n); R { scanf("%d %d", &c, &d); a[i] = c + d; b[i...
#include <algorithm> #include <cstdio> using namespace std; #define R for (i = 0; i < n; ++i) int a[1 << 17], b[1 << 17], amn = 1e7, amx = -1e7, bmn = 1e7, bmx = -1e7, n, c, d, ow = -1e7, oh = -1e7, i; int main() { scanf("%d", &n); R { scanf("%d %d", &c, &d); a[i] = c + d; b[...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
264
2
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define INF (2 << 28) #define fr first #define...
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define INF (2 << 28) #define fr first #define...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
356
2
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; typedef long long ll; int MAX = 10000000; int main() { int n, a, b, xmin = MAX, ymin = MAX, xmax = 0, ymax = 0, ans = 0, ans2 = 0, c, ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; typedef long long ll; int MAX = 10000000; int main() { int n, a, b, xmin = MAX, ymin = MAX, xmax = 0, ymax = 0, ans = 0, ans2 = 0, c, ...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
336
2
#include <algorithm> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define int long...
#include <algorithm> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define int long...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
284
2