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 <stdio.h> int main(void) { int num; float w, h, bmi; while (scanf("%d,%lf,%lf", &num, &w, &h) != EOF) { bmi = w / h / h; if (bmi >= 25) printf("%d\n", num); } return 0; }
#include <stdio.h> int main(void) { int num; double w, h, bmi; while (scanf("%d,%lf,%lf", &num, &w, &h) != EOF) { bmi = w / h / h; if (bmi >= 25.0) printf("%d\n", num); } return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
68
4
#include <stdio.h> int main(void) { int i, n, m, BMI; double w, h; while (scanf("%d, %lf, %lf", &i, &w, &h) != EOF) { BMI = w / h / h; if (BMI >= 25) { printf("%d", i); } } return 0; }
#include <stdio.h> int main(void) { int i, n, m, BMI; double w, h; while (scanf("%d, %lf, %lf", &i, &w, &h) != EOF) { BMI = w / h / h; if (BMI >= 25) { printf("%d\n", i); } } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
73
1
#include <stdio.h> int main() { int num; double wei, high; while (scanf("%d,%f,%f", &num, &wei, &high) != EOF) { if (wei / (high * high) >= 25.0) printf("%d\n", num); } return 0; }
#include <stdio.h> int main() { int num; double wei, high; while (scanf("%d,%lf,%lf", &num, &wei, &high) != EOF) { if (wei / (high * high) >= 25.0) printf("%d\n", num); } return 0; }
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
0
63
2
#include <stdio.h> int main(void) { int no; double w, h, bmi; int cnt = 0; while (scanf("%d,%lf,%lf", &no, &w, &h) != EOF) { bmi = w / h / h; if (bmi >= 25.0) { printf("%n\n", no); cnt++; } } if (cnt == 0) printf("該当なし\n"); return 0; }
#include <stdio.h> int main(void) { int no; double w, h, bmi; int cnt = 0; while (scanf("%d,%lf,%lf", &no, &w, &h) != EOF) { bmi = w / h / h; if (bmi >= 25.0) { printf("%d\n", no); cnt++; } } if (cnt == 0) printf("該当なし\n"); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
92
2
#include <stdio.h> int main(void) { int n; double g, m; while (scanf("%d,%lf,%lf", &n, &g, &m) != EOF) { if (25 <= g / m * m) { printf("%d\n", n); } } return 0; }
#include <stdio.h> int main(void) { int n; double g, m; while (scanf("%d,%lf,%lf", &n, &g, &m) != EOF) { if (25 <= g / m / m) { printf("%d\n", n); } } return 0; }
[["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 85]]
0
64
2
#include <stdio.h> int main() { double num, weight, height; while (scanf("%d,%lf,%lf", &num, &weight, &height) != EOF) { if ((weight / (height * height)) >= 25.0) printf("%d\n", num); } return 0; }
#include <stdio.h> int main() { int num; double weight, height; while (scanf("%d,%lf,%lf", &num, &weight, &height) != EOF) { if ((weight / (height * height)) >= 25.0) printf("%d\n", num); } return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35]]
0
64
5
#include <stdio.h> int main(void) { int num; double kg, m; while (scanf("%d,%lf,%lf", &num, &kg, &m) != EOF) { if (kg / (m * m) >= 25) { printf("%d", num); } } return 0; }
#include <stdio.h> int main(void) { int num; double kg, m; while (scanf("%d,%lf,%lf", &num, &kg, &m) != EOF) { if (kg / (m * m) >= 25) { printf("%d\n", num); } } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
65
1
#include <stdio.h> int main() { int id; double h, w, bmi; while (scanf("%d,%lf,%lf", &id, &w, &h) != EOF) { bmi = w / h * h; if (bmi >= 25.0) printf("%d\n", id); } return 0; }
#include <stdio.h> int main() { int id; double h, w, bmi; while (scanf("%d,%lf,%lf", &id, &w, &h) != EOF) { bmi = w / h / h; // printf("%f\n",bmi); if (bmi >= 25.0) printf("%d\n", id); } return 0; }
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85]]
1
67
2
#include <cmath> #include <iostream> using namespace std; double BMI(double height, double weight) { return weight / pow(height / 100.0, 2); } int main() { const int DATASETS = 1000; int Number[DATASETS], C = 0; double H[DATASETS], W[DATASETS]; char ch; while (cin >> Number[C] >> ch >> H[C] >> ch >> W[C]) { C++; } for (int i = 0; i < C; i++) { if (BMI(H[i] * 100.0, W[i]) >= 25.0) { cout << Number[i] << endl; } } return 0; }
#include <cmath> #include <iostream> using namespace std; double BMI(double height, double weight) { return weight / pow(height / 100.0, 2); } int main() { const int DATASETS = 1000; int Number[DATASETS], C = 0; double H[DATASETS], W[DATASETS]; char ch; while (cin >> Number[C] >> ch >> W[C] >> ch >> H[C]) { C++; } for (int i = 0; i < C; i++) { if (BMI(H[i] * 100.0, W[i]) >= 25.0) { cout << Number[i] << endl; } } return 0; }
[["-", 51, 16, 31, 16, 31, 16, 12, 69, 28, 22], ["+", 51, 16, 31, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 52, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 0, 52, 15, 339, 51, 16, 12, 69, 28, 22]]
1
144
4
#include <iostream> using namespace std; int num; double h, w; char a; int main() { while (cin >> num >> a >> h >> a >> w) { if (h * h * 25 <= w) { cout << num << endl; } } }
#include <iostream> using namespace std; int num; double h, w; char a; int main() { while (cin >> num >> a >> w >> a >> h) { if (h * h * 25 <= w) { cout << num << endl; } } }
[["-", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
57
4
#include <cstdio> using namespace std; int main() { int no; double w, h, bmi; while (~scanf("%lf,%lf,%lf", &no, &w, &h)) { if (w / h / h >= 25) printf("%d\n", no); } return 0; }
#include <cstdio> using namespace std; int main() { int no; double w, h, bmi; while (~scanf("%d,%lf,%lf", &no, &w, &h)) { if (w / h / h >= 25) printf("%d\n", no); } return 0; }
[["-", 51, 91, 28, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 91, 28, 2, 3, 4, 0, 5, 0, 6]]
1
66
2
#include <iostream> using namespace std; int main() { double bmi; int s; double w, h; while (scanf("%d,%lf,%lf", &s, &w, &h) + 1) { bmi = w / (h * h); if (bmi >= 25) { cout << s; } } return 0; }
#include <iostream> using namespace std; int main() { double bmi; int s; double w, h; while (scanf("%d,%lf,%lf", &s, &w, &h) + 1) { bmi = w / (h * h); if (bmi >= 25) { cout << s << endl; } } return 0; }
[["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
1
70
2
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> using namespace std; int main() { double s, w, h; char g; while (cin >> s >> g >> w >> g >> h) { if (w / (s * s) >= 25) cout << s << endl; } return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> using namespace std; int main() { double s, w, h; char g; while (cin >> s >> g >> w >> g >> h) { if (w / (h * h) >= 25) cout << s << endl; } return 0; }
[["-", 51, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 51, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["-", 51, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 51, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
1
67
4
import java.util.*; class Main { Scanner sc = new Scanner(System.in); public void run() { while (sc.hasNextLine()) { char[] str = sc.nextLine().toCharArray(); StringBuilder res = new StringBuilder(); for (int i = 0; i < str.length; i++) { if (str[i] == '@') { i++; int n = str[i] - '0'; i++; for (int j = 0; j < n; j++) { res.append(str[i]); } } res.append(str[i]); } ln(res); } } public static void main(String[] args) { new Main().run(); } public static void pr(Object o) { System.out.print(o); } public static void ln(Object o) { System.out.println(o); } public static void ln() { System.out.println(); } } class P { double x; double y; P(double _x, double _y) { x = _x; y = _y; } public static final P Xunit = new P(1, 0); public static final P Yunit = new P(0, 1); public static double dot(P a, P b) { return a.x * b.x + a.y * b.y; } public static double cross(P a, P b) { return a.x * b.y - a.y * b.x; } public static boolean isParallel(P a1, P a2, P b1, P b2) { return Math.abs(cross(a2.s(a1), b2.s(b1))) < Double.MIN_NORMAL; } public static boolean isVertical(P a1, P a2, P b1, P b2) { return Math.abs(dot(a2.s(a1), b2.s(b1))) < Double.MIN_NORMAL; } public P a(P a) { return new P(x + a.x, y + a.y); } public P s(P a) { return new P(x - a.x, y - a.y); } public double norm() { return Math.sqrt(x * x + y * y); } public double arg() { double s = Math.acos(x / norm()); return y > 0 ? s : 2 * Math.PI - s; } public P rotate(double t) { return new P(Math.cos(t) * this.x - Math.sin(t) * this.y, Math.sin(t) * this.x + Math.cos(t) * this.y); } public static int ccw(P a, P b, P c) { if (P.cross(b.s(a), c.s(a)) > Double.MIN_NORMAL) { return 1; } if (P.cross(b.s(a), c.s(a)) < -Double.MIN_NORMAL) { return -1; } if (P.dot(b, c) < -Double.MIN_NORMAL) return 2; if (b.norm() < c.norm() - Double.MIN_NORMAL) return -2; return 0; } @Override public boolean equals(Object obj) { if (obj instanceof P) { P p = (P)obj; return x == p.x && y == p.y; } return false; } public String toString() { return "(" + x + "," + y + ")"; } }
import java.util.*; class Main { Scanner sc = new Scanner(System.in); public void run() { while (sc.hasNextLine()) { char[] str = sc.nextLine().toCharArray(); StringBuilder res = new StringBuilder(); for (int i = 0; i < str.length; i++) { if (str[i] == '@') { i++; int n = str[i] - '0'; i++; for (int j = 0; j < n; j++) { res.append(str[i]); } } else { res.append(str[i]); } } ln(res); } } public static void main(String[] args) { new Main().run(); } public static void pr(Object o) { System.out.print(o); } public static void ln(Object o) { System.out.println(o); } public static void ln() { System.out.println(); } } class P { double x; double y; P(double _x, double _y) { x = _x; y = _y; } public static final P Xunit = new P(1, 0); public static final P Yunit = new P(0, 1); public static double dot(P a, P b) { return a.x * b.x + a.y * b.y; } public static double cross(P a, P b) { return a.x * b.y - a.y * b.x; } public static boolean isParallel(P a1, P a2, P b1, P b2) { return Math.abs(cross(a2.s(a1), b2.s(b1))) < Double.MIN_NORMAL; } public static boolean isVertical(P a1, P a2, P b1, P b2) { return Math.abs(dot(a2.s(a1), b2.s(b1))) < Double.MIN_NORMAL; } public P a(P a) { return new P(x + a.x, y + a.y); } public P s(P a) { return new P(x - a.x, y - a.y); } public double norm() { return Math.sqrt(x * x + y * y); } public double arg() { double s = Math.acos(x / norm()); return y > 0 ? s : 2 * Math.PI - s; } public P rotate(double t) { return new P(Math.cos(t) * this.x - Math.sin(t) * this.y, Math.sin(t) * this.x + Math.cos(t) * this.y); } public static int ccw(P a, P b, P c) { if (P.cross(b.s(a), c.s(a)) > Double.MIN_NORMAL) { return 1; } if (P.cross(b.s(a), c.s(a)) < -Double.MIN_NORMAL) { return -1; } if (P.dot(b, c) < -Double.MIN_NORMAL) return 2; if (b.norm() < c.norm() - Double.MIN_NORMAL) return -2; return 0; } @Override public boolean equals(Object obj) { if (obj instanceof P) { P p = (P)obj; return x == p.x && y == p.y; } return false; } public String toString() { return "(" + x + "," + y + ")"; } }
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
3
787
3
#include <stdio.h> #include <string.h> int i, j, k, l; char nyuroku[114514], m; int main(int argc, char **argv) { while (scanf("%s", &nyuroku[0]) != EOF) { l = strlen(nyuroku); for (i = 0; i < l; i++) { if (nyuroku[i] != '@') { printf("%c", nyuroku[i]); } else { for (m = '0'; m < nyuroku[i + 1]; m++) { printf("%c", nyuroku[i + 2]); } } } puts(""); } return 0; }
#include <stdio.h> #include <string.h> int i, j, k, l; char nyuroku[114514], m; int main(int argc, char **argv) { while (scanf("%s", &nyuroku[0]) != EOF) { l = strlen(nyuroku); for (i = 0; i < l; i++) { if (nyuroku[i] != '@') { printf("%c", nyuroku[i]); } else { for (m = '0'; m < nyuroku[i + 1]; m++) { printf("%c", nyuroku[i + 2]); } i = i + 2; } } puts(""); } return 0; }
[["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
0
148
6
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int n, i, o; char line[101], ans[500], ch[2], ch1[2]; while (scanf("%s", line) != EOF) { i = 0; o = 0; while (line[i]) { if (line[i] == '@') { ch[0] = line[i + 1]; ch[1] = 0; memset(ans + o, line[i + 2], atoi(ch)); o += atoi(ch); i += 2; } else { ans[o] = line[i]; o++; } i++; } ans[o + 1] = 0; printf("%s\n", ans); } return 0; }
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int n, i, o; char line[101], ans[500], ch[2], ch1[2]; while (scanf("%s", line) != EOF) { i = 0; o = 0; while (line[i]) { if (line[i] == '@') { ch[0] = line[i + 1]; ch[1] = 0; memset(ans + o, line[i + 2], atoi(ch)); o += atoi(ch); i += 2; } else { ans[o] = line[i]; o++; } i++; } ans[o] = 0; printf("%s\n", ans); } return 0; }
[["-", 0, 1, 0, 11, 31, 69, 71, 16, 17, 72], ["-", 0, 1, 0, 11, 31, 69, 71, 16, 12, 13]]
0
176
2
main(i, j) { char s[256]; for (; ~scanf("%s", s);) { for (i = 0; s[i]; i++) { if (s[i] == '@') { for (j = 0; j < s[i + 1] - '0'; j++) putchar(s[i + 2]); i++; } else putchar(s[i]); } puts(""); } exit(0); }
main(i, j) { char s[256]; for (; ~scanf("%s", s);) { for (i = 0; s[i]; i++) { if (s[i] == '@') { for (j = 0; j < s[i + 1] - '0'; j++) putchar(s[i + 2]); i += 2; } else putchar(s[i]); } puts(""); } exit(0); }
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
0
114
3
#include <stdio.h> int main(void) { int i, j, n; char code[101], buf; while (scanf("%s", &code) != EOF) { i = 0; while (code[i] != '\0') { if (code[i] != '@') { printf("%c", code[i]); i++; continue; } else { n = code[i + 1] - '0'; for (j = 1; j <= n; j++) { printf("%c", code[i + 2]); } i += 3; } } } return 0; }
#include <stdio.h> int main(void) { int i, j, n; char code[101], buf; while (scanf("%s", &code) != EOF) { i = 0; while (code[i] != '\0') { if (code[i] != '@') { printf("%c", code[i]); i++; continue; } else { n = code[i + 1] - '0'; for (j = 1; j <= n; j++) { printf("%c", code[i + 2]); } i += 3; } } printf("\n"); } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
139
7
#include <iostream> using namespace std; string s; main() { while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { char c = s[i + 1]; int n = s[i + 2] - '0'; i += 2; for (int j = 0; j < n; j++) cout << c; } else cout << s[i]; } cout << endl; } }
#include <iostream> using namespace std; string s; main() { while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { char c = s[i + 2]; int n = s[i + 1] - '0'; i += 2; for (int j = 0; j < n; j++) cout << c; } else cout << s[i]; } cout << endl; } }
[["-", 49, 50, 51, 69, 341, 342, 0, 16, 12, 13], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 12, 13], ["-", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
113
4
#include <iostream> using namespace std; #include <string> int main() { string s; while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { for (int j = s[i + 1]; j > 0; j--) { cout << s[j + 1]; } i += 2; } else { cout << s[i]; } } cout << endl; } return 0; }
#include <iostream> using namespace std; #include <string> int main() { string s; while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { for (int j = s[i + 1]; j > '0'; j--) { cout << s[i + 2]; } i += 2; } else { cout << s[i]; } } cout << endl; } return 0; }
[["+", 64, 9, 0, 7, 15, 16, 12, 103, 0, 104], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
109
6
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { while (s.find("@") != -1) { int x = s.find("@"); string buf; for (int i = 0; i < s[x + 1]; i++) buf += s[x + 2]; s.replace(x, 3, buf); } cout << s << endl; } }
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { while (s.find("@") != -1) { int x = s.find("@"); string buf; for (int i = 0; i < s[x + 1] - '0'; i++) buf += s[x + 2]; s.replace(x, 3, buf); } cout << s << endl; } }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 0, 7, 15, 16, 12, 16, 12, 103, 0, 104], ["+", 0, 7, 15, 16, 12, 16, 12, 103, 0, 125]]
1
100
4
#include <stdio.h> #include <string.h> int main(void) { int len; int i, j, k; char str[128]; while (fgets(str, 128, stdin) != NULL) { len = strlen(str); for (i = 0; i < len; i++) { if (str[i] == '@') { i++; for (k = 0; k <= str[i] - '0'; k++) { printf("%c", str[i + 1]); } i++; } else { printf("%c", str[i]); } } // printf("\n"); } return (0); }
#include <stdio.h> #include <string.h> int main(void) { int len; int i, j, k; char str[128]; while (fgets(str, 128, stdin) != NULL) { len = strlen(str); for (i = 0; i < len; i++) { if (str[i] == '@') { i++; for (k = 0; k < str[i] - '0'; k++) { printf("%c", str[i + 1]); } i++; } else { printf("%c", str[i]); } } // printf("\n"); } return (0); }
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18]]
1
140
2
#include <algorithm> #include <cctype> #include <climits> #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> using namespace std; int main() { int n; string str; string ans; cin >> str; for (int i = 0; i < str.size(); i++) { if (str[i] == '@') { cout << ans.append(str[i + 1] - '0', str[i + 2]); i += 2; ans = ""; } else { cout << str[i]; } } cout << endl; return 0; }
#include <algorithm> #include <cctype> #include <climits> #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> using namespace std; int main() { int n; string str; string ans; while (cin >> str) { for (int i = 0; i < str.size(); i++) { if (str[i] == '@') { cout << ans.append(str[i + 1] - '0', str[i + 2]); i += 2; ans = ""; } else { cout << str[i]; } } cout << endl; } return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
145
6
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { for (int j = 0; j < s[i + 1] - '0'; j++) { cout << s[i + 2]; } i += 2; } else { cout << s[i]; } } } return 0; }
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { for (int j = 0; j < s[i + 1] - '0'; j++) { cout << s[i + 2]; } i += 2; } else { cout << s[i]; } } cout << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
109
4
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { for (int j = 0; j < s[i + 1] - '0'; j++) { cout << s[i + 2]; } i += 2; } else cout << s[i]; } } return 0; }
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { for (int j = 0; j < s[i + 1] - '0'; j++) { cout << s[i + 2]; } i += 2; } else cout << s[i]; } cout << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
107
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define vi vector<int> #define vvi vector<vector<int>> #define ll long long int #define vl vector<ll> #define vvl vector<vector<ll>> #define vb vector<bool> #define vc vector<char> #define vs vector<string> #define ld long double #define INF 1e9 #define EPS 0.0000000001 #define rep(i, n) for (int i = 0; i < n; i++) #define CC puts("-------ok--------"); #define all(in) in.begin(), in.end() #define bv vector<bool> using namespace std; typedef pair<int, int> PA; using namespace std; #define MAX 1000 int main() { string s; while (cin >> s) { string temp; rep(i, s.size()) { if (s[i] == '@') { rep(j, s[i + 1] - 48) temp.push_back(s[i + 1]); i++; } else temp.push_back(s[i]); } cout << temp << endl; } }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define vi vector<int> #define vvi vector<vector<int>> #define ll long long int #define vl vector<ll> #define vvl vector<vector<ll>> #define vb vector<bool> #define vc vector<char> #define vs vector<string> #define ld long double #define INF 1e9 #define EPS 0.0000000001 #define rep(i, n) for (int i = 0; i < n; i++) #define CC puts("-------ok--------"); #define all(in) in.begin(), in.end() #define bv vector<bool> using namespace std; typedef pair<int, int> PA; using namespace std; #define MAX 1000 int main() { string s; while (cin >> s) { string temp; rep(i, s.size()) { if (s[i] == '@') { rep(j, s[i + 1] - 48) temp.push_back(s[i + 2]); i += 2; } else temp.push_back(s[i]); } cout << temp << endl; } }
[["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
187
5
#include "bits/stdc++.h" using namespace std; string s; int main(void) { while (cin >> s) { for (int i = 0; i < s.length(); ++i) { if (s[i] == '@') { for (int j = 0; j < s[i + 1] - '0'; ++j) { cout << s[i + 2]; } i = i + 2; } else { cout << s[i]; } } } }
#include "bits/stdc++.h" using namespace std; string s; int main(void) { while (cin >> s) { for (int i = 0; i < s.length(); ++i) { if (s[i] == '@') { for (int j = 0; j < s[i + 1] - '0'; ++j) { cout << s[i + 2]; } i = i + 2; } else { cout << s[i]; } } cout << endl; } }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
109
4
#include <bits/stdc++.h> using namespace std; int main() { string s; while (cin >> s) { for (int i = 0; i < s.size(); ++i) { if (s[i] == '@') { int x = s[i + 1] - '0'; cout << string(x, s[i + 2]); } else { cout << s[i]; } } cout << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { string s; while (cin >> s) { for (int i = 0; i < s.size(); ++i) { if (s[i] == '@') { int x = s[i + 1] - '0'; cout << string(x, s[i + 2]); i += 2; } else { cout << s[i]; } } cout << endl; } }
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
98
4
#include <algorithm> #include <iostream> using namespace std; int main() { string str; while (cin >> str) { for (int i = 0; i < str.size(); i++) { if (str[i] != '@') { cout << str[i]; continue; } for (int j = 0; j < str[i + 1] - '0'; j++) { cout << str[i + 2]; } i += 2; } } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { string str; while (cin >> str) { for (int i = 0; i < str.size(); i++) { if (str[i] != '@') { cout << str[i]; continue; } for (int j = 0; j < str[i + 1] - '0'; j++) { cout << str[i + 2]; } i += 2; } cout << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
108
4
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define LOOP(i, x, n) for (int i = x; i < n; i++) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define MP make_pair #define FR first #define SC second #define int long long using namespace std; const int MOD = 1000000007; const int INF = 1000000009; signed main() { string s; while (cin >> s) { REP(i, s.size()) { if (s[i] == '@') { int tmp = s[i + 1] - '0'; REP(j, tmp) cout << s[i + 2]; i += 2; } else cout << s[i]; } } return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define LOOP(i, x, n) for (int i = x; i < n; i++) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define MP make_pair #define FR first #define SC second #define int long long using namespace std; const int MOD = 1000000007; const int INF = 1000000009; signed main() { string s; while (cin >> s) { REP(i, s.size()) { if (s[i] == '@') { int tmp = s[i + 1] - '0'; REP(j, tmp) cout << s[i + 2]; i += 2; } else cout << s[i]; } cout << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
144
4
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <memory.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define all(c) ((c).begin()), ((c).end()) #define debug(c) cerr << "> " << #c << " = " << (c) << endl; #define iter(c) __typeof((c).begin()) #define present(c, e) ((c).find((e)) != (c).end()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) #define mp make_pair #define fst first #define snd second #define pb push_back const double EPS = 1e-10; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef complex<double> P; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template <class T> void pvp(T a, T b) { for (T i = a; i != b; ++i) cout << "(" << i->first << ", " << i->second << ") "; cout << endl; } int main() { for (string s; cin >> s;) { rep(i, s.size()) { if (s[i] == '@') { rep(j, s[i + 1] - '0') cout << s[i + 2]; } else { cout << s[i]; } } cout << endl; } return 0; }
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <memory.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define all(c) ((c).begin()), ((c).end()) #define debug(c) cerr << "> " << #c << " = " << (c) << endl; #define iter(c) __typeof((c).begin()) #define present(c, e) ((c).find((e)) != (c).end()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) #define mp make_pair #define fst first #define snd second #define pb push_back const double EPS = 1e-10; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef complex<double> P; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template <class T> void pvp(T a, T b) { for (T i = a; i != b; ++i) cout << "(" << i->first << ", " << i->second << ") "; cout << endl; } int main() { for (string s; cin >> s;) { rep(i, s.size()) { if (s[i] == '@') { rep(j, s[i + 1] - '0') cout << s[i + 2]; i += 2; } else { cout << s[i]; } } cout << endl; } return 0; }
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
328
4
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string s; int a; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { a = s[i + 1] - '0'; for (int j = 0; j < a; j++) { cout << s[i + 2]; } i += 2; } else cout << s[i]; } cout << endl; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string s; int a; while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '@') { a = s[i + 1] - '0'; for (int j = 0; j < a; j++) { cout << s[i + 2]; } i += 2; } else cout << s[i]; } cout << endl; } }
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
115
6
#include <algorithm> #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> using namespace std; int main() { string buffer; while (cin >> buffer) { for (unsigned int i = 0; i < buffer.length(); i++) { if (buffer[i] == '@') { int num = buffer[++i] - '0'; char c = buffer[++i]; i++; for (int i = 0; i < num; i++) { cout << c; } } else { cout << buffer[i]; } } cout << endl; } return 0; }
#include <algorithm> #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> using namespace std; int main() { string buffer; while (cin >> buffer) { for (unsigned int i = 0; i < buffer.length(); i++) { if (buffer[i] == '@') { int num = buffer[++i] - '0'; char c = buffer[++i]; for (int i = 0; i < num; i++) { cout << c; } } else { cout << buffer[i]; } } cout << endl; } return 0; }
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
145
3
#include <iostream> #include <string> using namespace std; void solve() { string str; while (cin >> str) { for (int i = 0; i < str.size(); ++i) { if (str[i] == '@') { for (int j = 0; j < (str[i + 1] - '0'); ++j) { cout << str[i + 2]; } i += 2; } else { cout << str[i]; } } } } int main() { solve(); return (0); }
#include <iostream> #include <string> using namespace std; void solve() { string str; while (cin >> str) { for (int i = 0; i < str.size(); ++i) { if (str[i] == '@') { for (int j = 0; j < (str[i + 1] - '0'); ++j) { cout << str[i + 2]; } i += 2; } else { cout << str[i]; } } cout << endl; } } int main() { solve(); return (0); }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
123
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { string s; string out = ""; int n; while (cin >> s) { for (int i = 0; i < s.length(); i++) { if (s[i] == '@') { i++; n = s[i] - '0'; i++; for (int j = 0; j < n; j++) { out += s[i]; } } else { out += s[i]; } } cout << out << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { string s; string out = ""; int n; while (cin >> s) { out = ""; for (int i = 0; i < s.length(); i++) { if (s[i] == '@') { i++; n = s[i] - '0'; i++; for (int j = 0; j < n; j++) { out += s[i]; } } else { out += s[i]; } } cout << out << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
132
5
#include <iostream> #include <string> using namespace std; int main() { string s; while (getline(cin, s), !cin.eof()) while (1) { size_t p = s.find("@"); if (p == string::npos) break; s.replace(p, 3, string(int(s[p + 1] - '0'), s[p + 2])); } cout << s << "\n"; }
#include <iostream> #include <string> using namespace std; int main() { string s; while (getline(cin, s), !cin.eof()) { while (1) { size_t p = s.find("@"); if (p == string::npos) break; s.replace(p, 3, string(int(s[p + 1] - '0'), s[p + 2])); } cout << s << "\n"; } }
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
102
2
//============================================================================ // Name : 0077.cpp // Author : afterCmidday // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <stdio.h> #include <string.h> int main(void) { int i, j; char str[1024]; while (scanf("%s", str) != EOF) { for (i = 0; i < strlen(str); i++) { if (i + 1 < strlen(str) && str[i] == '@') { for (j = 0; j < (str[i] - '0'); j++) { printf("%c", str[i + 2]); } i += 2; } else { printf("%c", str[i]); } } printf("\n"); } return 0; }
//============================================================================ // Name : 0077.cpp // Author : afterCmidday // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <stdio.h> #include <string.h> int main(void) { int i, j; char str[1024]; while (scanf("%s", str) != EOF) { for (i = 0; i < strlen(str); i++) { if (i + 1 < strlen(str) && str[i] == '@') { for (j = 0; j < (str[i + 1] - '0'); j++) { printf("%c", str[i + 2]); } i += 2; } else { printf("%c", str[i]); } } printf("\n"); } return 0; }
[["+", 0, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
151
2
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { char input[101]; while (scanf(" %s", input) != EOF) { for (int i = 0; i < strlen(input); i++) { if (input[i] == '@') { for (int j = 0; j < input[i + 1] - '0'; j++) { cout << input[i + 2] << endl; } i += 2; } else { cout << input[i]; } } cout << endl; } }
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { char input[101]; while (scanf(" %s", input) != EOF) { for (int i = 0; i < strlen(input); i++) { if (input[i] == '@') { for (int j = 0; j < input[i + 1] - '0'; j++) { cout << input[i + 2]; } i += 2; } else { cout << input[i]; } } cout << endl; } }
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22]]
1
123
2
try: s, w, h = map(float, input().split(',')) if w / h**2 >= 25: print(int(s)) except: pass
try: while True: s, w, h = map(float, input().split(',')) if w / h**2 >= 25: print(int(s)) except: pass
[["+", 0, 656, 0, 246, 8, 196, 0, 52, 0, 89], ["+", 0, 656, 0, 246, 8, 196, 0, 52, 15, 146], ["+", 0, 656, 0, 246, 8, 196, 0, 52, 0, 102]]
5
42
3
while True: try: n, w, h = list(map(float, input().split())) if w/h**2 >= 25.0: print(int(n)) except: break
while True: try: n, w, h = list(map(float, input().split(","))) if w/h**2 >= 25.0: print(int(n)) except: break
[["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 655]]
5
45
3
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { String line = scanner.nextLine(); StringBuilder builder = new StringBuilder(line); while (true) { int num = builder.indexOf("@"); if (num == -1) { break; } builder.replace(num, num + 2, getStr(num, builder)); } System.out.println(builder); } } private static String getStr(int num, StringBuilder builder) { int a = builder.charAt(num + 1) - '0'; StringBuilder b = new StringBuilder(); String s = builder.substring(num + 2, num + 3); for (int i = 0; i < a; i++) { b.append(s); } return b.toString(); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { String line = scanner.nextLine(); StringBuilder builder = new StringBuilder(line); while (true) { int num = builder.indexOf("@"); if (num == -1) { break; } builder.replace(num, num + 3, getStr(num, builder)); } System.out.println(builder); } } private static String getStr(int num, StringBuilder builder) { int a = builder.charAt(num + 1) - '0'; StringBuilder b = new StringBuilder(); String s = builder.substring(num + 2, num + 3); for (int i = 0; i < a; i++) { b.append(s); } return b.toString(); } }
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499]]
3
200
2
import java.io.PrintWriter; import java.util.Scanner; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); while (sc.hasNext()) { String str = sc.nextLine(); for (int i = 0; i < str.length(); i++) { // System.out.println(str.charAt(i)); if (String.valueOf(str.charAt(i)).equals("@")) { String temp = String.valueOf(str.charAt(i + 1)); int n = Integer.parseInt(temp); for (int j = 0; j < n; j++) { pw.write(str.charAt(i + 2)); } i += 2; } else { pw.write(str.charAt(i)); } } pw.flush(); } } }
import java.io.PrintWriter; import java.util.Scanner; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); while (sc.hasNext()) { String str = sc.nextLine(); for (int i = 0; i < str.length(); i++) { // System.out.println(str.charAt(i)); if (String.valueOf(str.charAt(i)).equals("@")) { String temp = String.valueOf(str.charAt(i + 1)); int n = Integer.parseInt(temp); for (int j = 0; j < n; j++) { pw.write(str.charAt(i + 2)); } i += 2; } else { pw.write(str.charAt(i)); } } pw.println(); pw.flush(); } } }
[["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 500, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 0, 131]]
3
197
6
class Main { public static void main(String[] z) throws Exception { for (int n, b; 0 < (b = System.in.read());) { n = 1; if (b == 64) { n = System.in.read() - 49; b = System.in.read(); } for (; n-- > 0;) System.out.print((char)b); } } }
class Main { public static void main(String[] z) throws Exception { for (int n, b; 0 < (b = System.in.read());) { n = 1; if (b == 64) { n = System.in.read() - 48; b = System.in.read(); } for (; n-- > 0;) System.out.print((char)b); } } }
[["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 499], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 499]]
3
97
2
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static char[] input; public static void main(String[] args) { while (read()) { solve(); } } static boolean read() { if (!sc.hasNext()) return false; input = sc.next().toCharArray(); return true; } static void solve() { StringBuffer sb = new StringBuffer(); int index = 0; while (index < input.length) { if (input[index] == '@') { int count = input[++index] - '0'; index++; for (int i = 0; i < count; i++) { sb.append(input[index]); } } else { sb.append(input[index]); index++; } } System.out.println(sb); } }
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static char[] input; public static void main(String[] args) { while (read()) { solve(); } } static boolean read() { if (!sc.hasNext()) return false; input = sc.next().toCharArray(); return true; } static void solve() { StringBuffer sb = new StringBuffer(); int index = 0; while (index < input.length) { if (input[index] == '@') { int count = input[++index] - '0'; index++; for (int i = 0; i < count; i++) { sb.append(input[index]); } } else { sb.append(input[index]); } index++; } System.out.println(sb); } }
[["+", 0, 52, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 0, 52, 8, 196, 0, 57, 75, 196, 0, 46]]
3
194
2
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) begin(a), end(a) #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(5) typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> P; typedef complex<double> Point; typedef long long ll; const int INF = 114514810; const int MOD = 1000000007; const double EPS = 1e-8; const double PI = acos(-1.0); struct edge { int from, to, cost; bool operator<(const edge &e) const { return cost < e.cost; } bool operator>(const edge &e) const { return cost > e.cost; } }; ///*************************************************************************************/// ///*************************************************************************************/// ///*************************************************************************************/// int n, s; int memo[100][1000][1 << 11]; int solve(int i, int j, int v) { if (memo[i][j][v] >= 0) return memo[i][j][v]; if (i == n) { if (j == s) return 1; else return 0; } int res = 0; REP(k, 10) { if ((v >> k) & 1) continue; if (j + k * (i + 1) > s) break; res += solve(i + 1, j + (i + 1) * k, v | (1 << k)); } return memo[i][j][v] = res; } int main() { while (cin >> n >> s) { MS(memo, -1); cout << solve(0, 0, 0) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) begin(a), end(a) #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(5) typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> P; typedef complex<double> Point; typedef long long ll; const int INF = 114514810; const int MOD = 1000000007; const double EPS = 1e-8; const double PI = acos(-1.0); struct edge { int from, to, cost; bool operator<(const edge &e) const { return cost < e.cost; } bool operator>(const edge &e) const { return cost > e.cost; } }; ///*************************************************************************************/// ///*************************************************************************************/// ///*************************************************************************************/// int n, s; int memo[11][800][1 << 10]; int solve(int i, int j, int v) { if (memo[i][j][v] >= 0) return memo[i][j][v]; if (i == n) { if (j == s) return 1; else return 0; } int res = 0; REP(k, 10) { if ((v >> k) & 1) continue; if (j + k * (i + 1) > s) break; res += solve(i + 1, j + (i + 1) * k, v | (1 << k)); } return memo[i][j][v] = res; } int main() { while (cin >> n >> s) { MS(memo, -1); cout << solve(0, 0, 0) << endl; } return 0; }
[["-", 0, 43, 49, 80, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 80, 49, 80, 49, 80, 81, 13], ["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 30, 0, 43, 49, 80, 81, 16, 12, 13], ["+", 0, 30, 0, 43, 49, 80, 81, 16, 12, 13]]
1
359
6
#include <algorithm> #include <iostream> #include <vector> using namespace std; int res[10][1000]; int main() { vector<int> v; for (int i = 0; i < 10; i++) { v.push_back(i); } sort(v.begin(), v.end()); do { int tmp = 0; for (int j = 0; j < 10; j++) { tmp += v[j] * (1 + j); res[j][tmp]++; } } while (next_permutation(v.begin(), v.end())); int fact = 1; for (int i = 0; i < 10; i++) { for (int j = 0; j < 1000; j++) { res[9 - i][j] /= fact; } fact *= (i + 1); } int n, s; while (cin >> n >> s) { if (n == 0 || n > 10 || s >= 1000) cout << 0 << endl; cout << res[n - 1][s] << endl; } }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int res[10][1000]; int main() { vector<int> v; for (int i = 0; i < 10; i++) { v.push_back(i); } sort(v.begin(), v.end()); int mx = 0; do { int tmp = 0; for (int j = 0; j < 10; j++) { tmp += v[j] * (1 + j); res[j][tmp]++; } } while (next_permutation(v.begin(), v.end())); int fact = 1; for (int i = 0; i < 10; i++) { for (int j = 0; j < 1000; j++) { res[9 - i][j] /= fact; } fact *= (i + 1); } int n, s; while (cin >> n >> s) { if (n == 0 || n > 10 || s >= 1000) cout << 0 << endl; else cout << res[n - 1][s] << endl; } }
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95]]
1
239
6
#include <cmath> #include <cstring> #include <iostream> using namespace std; int x[10][600][1024], y[10][600], n, s; int main() { x[0][0][0] = 1; for (int i = 1; i < 10; i++) { for (int j = 0; j < 500; j++) { for (int k = 0; k < 1024; k++) { for (int l = 0; l < 10; l++) { if ((k / (1 << l)) % 2 == 0) { x[i][j + i * l][k + (1 << l)] += x[i - 1][j][k]; } } } } } for (int i = 1; i < 10; i++) { for (int j = 0; j < 500; j++) { for (int k = 0; k < 1024; k++) { y[i][j] += x[i][j][k]; } } } while (cin >> n >> s) { cout << y[n][s] << endl; } }
#include <cmath> #include <cstring> #include <iostream> using namespace std; int x[11][600][1024], y[11][600], n, s; int main() { x[0][0][0] = 1; for (int i = 1; i <= 10; i++) { for (int j = 0; j < 500; j++) { for (int k = 0; k < 1024; k++) { for (int l = 0; l < 10; l++) { if ((k / (1 << l)) % 2 == 0) { x[i][j + i * l][k + (1 << l)] += x[i - 1][j][k]; } } } } } for (int i = 0; i <= 10; i++) { for (int j = 0; j < 500; j++) { for (int k = 0; k < 1024; k++) { y[i][j] += x[i][j][k]; } } } while (cin >> n >> s) { cout << y[n][s] << endl; } }
[["-", 0, 43, 49, 80, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 80, 49, 80, 49, 80, 81, 13], ["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
258
10
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ALL(c) (c).begin(), (c).end() const int INF = 1 << 29; int main() { const int N = 10; int dp[1 << N][331] = {}; int res = 0; REP(i, N) { dp[1 << i][i] = 1; } REP(S, 1 << N) { vector<int> se; REP(j, N) if ((S >> j) & 1) { se.push_back(j); // cout << j << " "; } FOR(it, se) { REP(i, 331) { if (i + (*it) * se.size() >= 331) break; dp[S][i + (*it) * se.size()] += dp[S - (1 << *it)][i]; } } // REP(i,331) { // if (dp[S][i])cout << i << " "; // }cout << endl; } int table[11][331] = {}; for (int i = 1; i <= N; ++i) { int comb = (1 << i) - 1; while (comb < 1 << 10) { REP(j, 331) { table[i][j] += dp[comb][j]; } int x = comb & -comb, y = comb + x; comb = ((comb & ~y) / x >> 1) | y; } // if (i == 3) { // REP(j,331) { // cout << table[i][j] << endl; // } // } // cout << table[i][10] << endl; } int n, s; while (cin >> n >> s) { if (n < 0 || n > 10 || s < 0 || s >= 331) cout << 0 << endl; cout << table[n][s] << endl; } }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ALL(c) (c).begin(), (c).end() const int INF = 1 << 29; int main() { const int N = 10; int dp[1 << N][331] = {}; int res = 0; REP(i, N) { dp[1 << i][i] = 1; } REP(S, 1 << N) { vector<int> se; REP(j, N) if ((S >> j) & 1) { se.push_back(j); // cout << j << " "; } FOR(it, se) { REP(i, 331) { if (i + (*it) * se.size() >= 331) break; dp[S][i + (*it) * se.size()] += dp[S - (1 << *it)][i]; } } // REP(i,331) { // if (dp[S][i])cout << i << " "; // }cout << endl; } int table[11][331] = {}; for (int i = 1; i <= N; ++i) { int comb = (1 << i) - 1; while (comb < 1 << 10) { REP(j, 331) { table[i][j] += dp[comb][j]; } int x = comb & -comb, y = comb + x; comb = ((comb & ~y) / x >> 1) | y; } // if (i == 3) { // REP(j,331) { // cout << table[i][j] << endl; // } // } // cout << table[i][10] << endl; } int n, s; while (cin >> n >> s) { if (n < 0 || n > 10 || s < 0 || s >= 331) cout << 0 << endl; else cout << table[n][s] << endl; } }
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95]]
1
385
1
#include <iostream> using namespace std; int n, s; int dp[350][1024]; int rec(int k, int sum, int u) { int res = 0; if (k == 0 && sum == 0) return 1; if (dp[sum][u] >= 0) return dp[sum][u]; if (k == 0) return 0; for (int i = 0; i < 10; i++) { if (u >> i & 1) { if (sum - k * i >= 0) res += rec(k - 1, sum - k * i, u - (1 << i)); } } dp[sum][u] = res; return res; } int main() { for (int i = 0; i < 350; i++) { for (int j = 0; j < 1024; j++) dp[i][j] = -1; } while (cin >> n >> s) { if (s > 330) cout << 0 << endl; else { int up = 0; for (int i = 0; i < n; i++) up += i * (i + 1); for (int i = 0; i < up; i++) { for (int j = 0; j < 1024; j++) dp[i][j] = -1; } cout << rec(n, s, 1023) << endl; } } }
#include <iostream> using namespace std; int n, s; int dp[350][1024]; int rec(int k, int sum, int u) { int res = 0; if (k == 0 && sum == 0) return 1; if (dp[sum][u] >= 0) return dp[sum][u]; if (k == 0) return 0; for (int i = 0; i < 10; i++) { if (u >> i & 1) { if (sum - k * i >= 0) res += rec(k - 1, sum - k * i, u - (1 << i)); } } dp[sum][u] = res; return res; } int main() { for (int i = 0; i < 350; i++) { for (int j = 0; j < 1024; j++) dp[i][j] = -1; } while (cin >> n >> s) { if (s > 330) cout << 0 << endl; else { int up = 0; for (int i = 0; i < n; i++) up += i * (i + 1); for (int i = 0; i < 350; i++) { for (int j = 0; j < 1024; j++) dp[i][j] = -1; } cout << rec(n, s, 1023) << endl; } } }
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 22], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13]]
1
307
2
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <memory.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define all(c) ((c).begin()), ((c).end()) #define debug(c) cerr << "> " << #c << " = " << (c) << endl; #define iter(c) __typeof((c).begin()) #define present(c, e) ((c).find((e)) != (c).end()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) #define mp make_pair #define fst first #define snd second #define pb push_back const double EPS = 1e-10; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef complex<double> P; int go(int n, int s, int used) { if (n == 0) { return s == 0; } if (s < 0) return 0; if (s - 9 * n > 0) return 0; int res = 0; rep(i, 10) if (!(used & 1 << i)) { res += go(n - 1, s - n * i, used | 1 << i); } return res; } int main() { for (int n, s; cin >> n >> s;) { cout << go(n, s, 0) << endl; } return 0; }
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <memory.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define all(c) ((c).begin()), ((c).end()) #define debug(c) cerr << "> " << #c << " = " << (c) << endl; #define iter(c) __typeof((c).begin()) #define present(c, e) ((c).find((e)) != (c).end()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) #define mp make_pair #define fst first #define snd second #define pb push_back const double EPS = 1e-10; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef complex<double> P; int go(int n, int s, int used) { if (n == 0) { return s == 0; } if (s < 0) return 0; if (s - 9 * n * n > 0) return 0; int res = 0; rep(i, 10) if (!(used & 1 << i)) { res += go(n - 1, s - n * i, used | 1 << i); } return res; } int main() { for (int n, s; cin >> n >> s;) { cout << go(n, s, 0) << endl; } return 0; }
[["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22]]
1
280
2
@memo = Array.new(10){Array.new(331){ Array.new(1024) }} def calc(num,n,s) return 0 if n<=0 || s<=0 || s>330 || n>10 return @memo[n][s][num] if @memo[n][s][num] ans = 0 d,m = num.divmod(2) cnt = 0 while d>0 || cnt<10 if m==0 t = s-cnt*n if t==0 && n-1==0 ans = 1 break end ans += calc(num+2**cnt,n-1,t) end cnt += 1 d,m = d.divmod(2) end @memo[n][s][num] = ans return ans end while l=gets n,s = l.split.map(&:to_i) puts calc(0, n, s) end
@memo = Array.new(11){Array.new(331){ Array.new(1024) }} def calc(num,n,s) return 0 if n<=0 || s<0 || s>330 || n>10 return @memo[n][s][num] if @memo[n][s][num] ans = 0 d,m = num.divmod(2) cnt = 0 while d>0 || cnt<10 if m==0 t = s-cnt*n if t==0 && n==1 ans = 1 break end ans += calc(num+2**cnt,n-1,t) end cnt += 1 d,m = d.divmod(2) end @memo[n][s][num] = ans return ans end while l=gets n,s = l.split.map(&:to_i) puts calc(0, n, s) end
[["-", 0, 493, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 493, 0, 662, 12, 652, 3, 4, 0, 612], ["-", 15, 738, 31, 738, 31, 738, 12, 738, 17, 19], ["+", 15, 738, 31, 738, 31, 738, 12, 738, 17, 18], ["-", 0, 121, 15, 738, 12, 738, 31, 738, 17, 33], ["-", 0, 121, 15, 738, 12, 738, 31, 738, 12, 612], ["-", 64, 749, 0, 121, 15, 738, 12, 738, 12, 612], ["+", 64, 749, 0, 121, 15, 738, 12, 738, 12, 612]]
4
196
8
from collections import defaultdict, Counter import sys # dp[n][使った数字(bit)][合計] = count dp = [defaultdict(Counter) for _ in [0]*11] dp[0][0][0] = 0 for i in range(1, 11): for used, counter in dp[i-1].items(): for j in filter(lambda x: used & 2**x == 0, range(10)): for total, count in counter.items(): dp[i][used|2**j][total+j*i] += 1 for n, s in (map(int, l.rstrip().split()) for l in sys.stdin): print(sum(v for counter in dp[n].values() for k, v in counter.items() if k == s))
from collections import defaultdict, Counter import sys # dp[n][使った数字(bit)][合計] = count dp = [defaultdict(Counter) for _ in [0]*11] dp[0][0][0] = 1 for i in range(1, 11): for used, counter in dp[i-1].items(): for j in filter(lambda x: used & 2**x == 0, range(10)): for total, count in counter.items(): dp[i][used|2**j][total+j*i] += count for n, s in (map(int, l.rstrip().split()) for l in sys.stdin): print(sum(v for counter in dp[n].values() for k, v in counter.items() if k == s))
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22]]
5
176
4
function bomb(y, x) { var dx = [ -1, 1, 0, 0 ]; var dy = [ 0, 0, -1, 1 ]; for (var i = 0; i < 4; i++) { for (var j = 1; j <= 3; j++) { var yy = y + (dy[i] * j); var xx = x + (dx[i] * j); if (yy < 0 || yy >= 8 || xx < 0 || xx >= 8) continue; if (yx[yy][xx] == 1) { yx[yy][xx] = 0; bomb(yy, xx); } } } } var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); var AL = Arr.shift(); for (var i = 0; i < AL; i++) { Arr.shift(); var yx = []; for (var j = 0; j < 8; j++) { var line = Arr.shift().split("").map(Number); yx.push(line); } var X = (Arr.shift() - 0) - 1; var Y = (Arr.shift() - 0) - 1; if (yx[Y][X] == 1) { yx[yy][xx] = 0; bomb(Y, X); } console.log("Data " + (i + 1) + ":"); for (var j = 0; j < 8; j++) console.log(yx[j].join("")); }
function bomb(y, x) { var dx = [ -1, 1, 0, 0 ]; var dy = [ 0, 0, -1, 1 ]; for (var i = 0; i < 4; i++) { for (var j = 1; j <= 3; j++) { var yy = y + (dy[i] * j); var xx = x + (dx[i] * j); if (yy < 0 || yy >= 8 || xx < 0 || xx >= 8) continue; if (yx[yy][xx] == 1) { yx[yy][xx] = 0; bomb(yy, xx); } } } } var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); var AL = Arr.shift(); for (var i = 0; i < AL; i++) { Arr.shift(); var yx = []; for (var j = 0; j < 8; j++) { var line = Arr.shift().split("").map(Number); yx.push(line); } var X = (Arr.shift() - 0) - 1; var Y = (Arr.shift() - 0) - 1; if (yx[Y][X] == 1) { yx[Y][X] = 0; bomb(Y, X); } console.log("Data " + (i + 1) + ":"); for (var j = 0; j < 8; j++) console.log(yx[j].join("")); }
[["-", 0, 1, 0, 11, 31, 69, 500, 69, 71, 22], ["+", 0, 1, 0, 11, 31, 69, 500, 69, 71, 22], ["-", 64, 556, 0, 1, 0, 11, 31, 69, 71, 22], ["+", 64, 556, 0, 1, 0, 11, 31, 69, 71, 22]]
2
377
4
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { static int[][] map = new int[8][8]; static void bomb(int x, int y) { if (map[y][x] == 0) return; else { // map[y][x]==1 map[y][x] = 0; if (y != 0) bomb(x, y - 1); if (y >= 2) bomb(x, y - 2); if (y >= 3) bomb(x, y - 3); if (y != 7) bomb(x, y + 1); if (y <= 5) bomb(x, y + 2); if (y <= 4) bomb(x, y + 3); if (x != 0) bomb(x - 1, y); if (x >= 2) bomb(x - 2, y); if (x >= 3) bomb(x - 3, y); if (x != 7) bomb(x + 1, y); if (x <= 5) bomb(x + 2, y); if (x <= 4) bomb(x + 3, y); } } public static void main(String args[]) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { String line; while ((line = br.readLine()) != null) { if (line.isEmpty()) break; int n = Integer.parseInt(line); for (int i = 0; i < n; i++) { line = br.readLine(); for (int y = 0; y < 8; y++) { line = br.readLine(); for (int x = 0; x < 8; x++) map[y][x] = Integer.parseInt(line.charAt(x) + ""); } line = br.readLine(); int bX = Integer.parseInt(line); line = br.readLine(); int bY = Integer.parseInt(line); bomb(bX - 1, bY - 1); System.out.println("Data " + (n + 1) + ":"); for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { System.out.print(map[y][x] + ""); } System.out.println(""); } } break; } br.close(); } catch (Exception e) { e.printStackTrace(); } } }
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { static int[][] map = new int[8][8]; static void bomb(int x, int y) { if (map[y][x] == 0) return; else { // map[y][x]==1 map[y][x] = 0; if (y != 0) bomb(x, y - 1); if (y >= 2) bomb(x, y - 2); if (y >= 3) bomb(x, y - 3); if (y != 7) bomb(x, y + 1); if (y <= 5) bomb(x, y + 2); if (y <= 4) bomb(x, y + 3); if (x != 0) bomb(x - 1, y); if (x >= 2) bomb(x - 2, y); if (x >= 3) bomb(x - 3, y); if (x != 7) bomb(x + 1, y); if (x <= 5) bomb(x + 2, y); if (x <= 4) bomb(x + 3, y); } } public static void main(String args[]) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { String line; while ((line = br.readLine()) != null) { if (line.isEmpty()) break; int n = Integer.parseInt(line); for (int i = 0; i < n; i++) { line = br.readLine(); for (int y = 0; y < 8; y++) { line = br.readLine(); for (int x = 0; x < 8; x++) map[y][x] = Integer.parseInt(line.charAt(x) + ""); } line = br.readLine(); int bX = Integer.parseInt(line); line = br.readLine(); int bY = Integer.parseInt(line); bomb(bX - 1, bY - 1); System.out.println("Data " + (i + 1) + ":"); for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { System.out.print(map[y][x] + ""); } System.out.println(""); } } break; } br.close(); } catch (Exception e) { e.printStackTrace(); } } }
[["-", 0, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 31, 22]]
3
566
2
import java.awt.Point; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int m = 1; m <= n; m++) { sc.nextLine(); sc.nextLine(); System.out.println("Data " + m); int[][] map = new int[14][14]; for (int i = 0; i < 14; i++) { Arrays.fill(map[i], -1); } for (int i = 3; i <= 10; i++) { char tmp[] = sc.nextLine().toCharArray(); for (int j = 0; j < 8; j++) { map[i][j + 3] = tmp[j] - '0'; } } int sx = sc.nextInt() + 2; int sy = sc.nextInt() + 2; Queue<Point> q = new LinkedList<Point>(); q.add(new Point(sx, sy)); map[sy][sx] = 0; while (q.peek() != null) { Point p = q.poll(); int x = p.x; int y = p.y; int dx[] = {0, 1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3}; int dy[] = {1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3, 0}; for (int i = 0; i < 12; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (map[ny][nx] == -1) continue; if (map[ny][nx] == 1) { map[ny][nx] = 0; q.add(new Point(nx, ny)); } } } for (int i = 3; i <= 10; i++) { for (int j = 3; j <= 10; j++) { System.out.print(map[i][j]); } System.out.println(); } } } }
import java.awt.Point; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int m = 1; m <= n; m++) { sc.nextLine(); sc.nextLine(); System.out.println("Data " + m + ":"); int[][] map = new int[14][14]; for (int i = 0; i < 14; i++) { Arrays.fill(map[i], -1); } for (int i = 3; i <= 10; i++) { char tmp[] = sc.nextLine().toCharArray(); for (int j = 0; j < 8; j++) { map[i][j + 3] = tmp[j] - '0'; } } int sx = sc.nextInt() + 2; int sy = sc.nextInt() + 2; Queue<Point> q = new LinkedList<Point>(); q.add(new Point(sx, sy)); map[sy][sx] = 0; while (q.peek() != null) { Point p = q.poll(); int x = p.x; int y = p.y; int dx[] = {0, 1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3}; int dy[] = {1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3, 0}; for (int i = 0; i < 12; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (map[ny][nx] == -1) continue; if (map[ny][nx] == 1) { map[ny][nx] = 0; q.add(new Point(nx, ny)); } } } for (int i = 3; i <= 10; i++) { for (int j = 3; j <= 10; j++) { System.out.print(map[i][j]); } System.out.println(); } } } }
[["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 62], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 491]]
3
529
4
import java.util.Scanner; public class Main { static int base[][]; static int h, w; public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int I = 1; while (N-- > 0) { String S = in.nextLine(); String SS = in.nextLine(); base = new int[9][9]; for (int i = 1; i <= 8; i++) { String str = in.next(); for (int j = 0; j <= 7; j++) { if (str.charAt(j) == '0') base[i][j + 1] = 0; else base[i][j + 1] = 1; } } w = in.nextInt(); h = in.nextInt(); bomb(h, w); System.out.println("Data " + I++ + ":"); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) System.out.print(base[i][j]); System.out.println(); } } } public static void bomb(int h, int w) { base[h][w] = 0; for (int i = 1; i <= 3; i++) { if (h + i < 9 && base[h + i][w] == 1) bomb(h + i, w); if (w + i < 9 && base[h][w + i] == 1) bomb(h, w + i); if (h - i >= 0 && base[h - i][w] == 1) bomb(h - i, w); if (w - i >= 0 && base[h][w - i] == 1) bomb(h, w - i); } } }
import java.util.Scanner; public class Main { static int base[][]; static int h, w; public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int I = 1; while (N-- > 0) { String S = in.nextLine(); String SS = in.nextLine(); base = new int[9][9]; for (int i = 1; i <= 8; i++) { String str = in.next(); for (int j = 0; j <= 7; j++) { if (str.charAt(j) == '0') base[i][j + 1] = 0; else base[i][j + 1] = 1; } } w = in.nextInt(); h = in.nextInt(); bomb(h, w); System.out.println("Data " + I++ + ":"); for (int i = 1; i < 9; i++) { for (int j = 1; j < 9; j++) System.out.print(base[i][j]); System.out.println(); } } } public static void bomb(int h, int w) { base[h][w] = 0; for (int i = 1; i <= 3; i++) { if (h + i < 9 && base[h + i][w] == 1) bomb(h + i, w); if (w + i < 9 && base[h][w + i] == 1) bomb(h, w + i); if (h - i >= 1 && base[h - i][w] == 1) bomb(h - i, w); if (w - i >= 1 && base[h][w - i] == 1) bomb(h, w - i); } } }
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["-", 0, 57, 15, 15, 0, 16, 31, 16, 12, 499], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 12, 499]]
3
427
8
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int n = sc.nextInt(); for (int a = 1; a <= n; a++) { int[][] map = new int[8][8]; String s = ""; for (int i = 0; i < 8; i++) { s = sc.next(); for (int j = 0; j < 8; j++) { if (s.codePointAt(j) == 49) map[i][j] = 1; } } ArrayDeque<Integer> px = new ArrayDeque<Integer>(); ArrayDeque<Integer> py = new ArrayDeque<Integer>(); px.push(sc.nextInt() - 1); py.push(sc.nextInt() - 1); int x, y; while (true) { int k = px.size(); if (k == 0) break; for (int i = 0; i < k; i++) { x = px.pop(); y = py.pop(); map[y][x]--; for (int j = 1; j < 4; j++) { if (x + j == 8) break; if (map[y][x + j] == 1) { py.push(y); px.push(x + j); } } for (int j = 1; j < 4; j++) { if (x - j == -1) break; if (map[y][x - j] == 1) { py.push(y); px.push(x - j); } } for (int j = 1; j < 4; j++) { if (y + j == 8) break; if (map[y + j][x] == 1) { py.push(y + j); px.push(x); } } for (int j = 1; j < 4; j++) { if (y - j == -1) break; if (map[y - j][x] == 1) { py.push(y - j); px.push(x); } } } } System.out.println("Data " + a + ":"); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { System.out.print(map[i][j]); } System.out.println(); } } } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int n = sc.nextInt(); for (int a = 1; a <= n; a++) { int[][] map = new int[8][8]; String s = ""; for (int i = 0; i < 8; i++) { s = sc.next(); for (int j = 0; j < 8; j++) { if (s.codePointAt(j) == 49) map[i][j] = 1; } } ArrayDeque<Integer> px = new ArrayDeque<Integer>(); ArrayDeque<Integer> py = new ArrayDeque<Integer>(); px.push(sc.nextInt() - 1); py.push(sc.nextInt() - 1); int x, y; while (true) { int k = px.size(); if (k == 0) break; for (int i = 0; i < k; i++) { x = px.pop(); y = py.pop(); map[y][x] = 0; for (int j = 1; j < 4; j++) { if (x + j == 8) break; if (map[y][x + j] == 1) { py.push(y); px.push(x + j); } } for (int j = 1; j < 4; j++) { if (x - j == -1) break; if (map[y][x - j] == 1) { py.push(y); px.push(x - j); } } for (int j = 1; j < 4; j++) { if (y + j == 8) break; if (map[y + j][x] == 1) { py.push(y + j); px.push(x); } } for (int j = 1; j < 4; j++) { if (y - j == -1) break; if (map[y - j][x] == 1) { py.push(y - j); px.push(x); } } } } System.out.println("Data " + a + ":"); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { System.out.print(map[i][j]); } System.out.println(); } } } } }
[["-", 0, 7, 8, 196, 0, 1, 0, 27, 0, 68], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 499]]
3
582
3
#include <stdio.h> int main() { int n, x[65], y[65], c, i, j, t, r; char m[15][15]; int X[4] = {0, 1, 0, -1}; int Y[4] = {1, 0, -1, 0}; scanf("%d", &n); for (c = 0; c < n; c++) { for (i = 0; i < 8; i++) scanf(" %s", m[i + 3] + 3); scanf(" %d %d", &x[0], &y[t = 0]); x[0] += 2; y[0] += 2; m[y[0]][x[0]] = '0'; for (r = 1; t != r; t++) { for (i = 1; i < 4; i++) { for (j = 0; j < 4; j++) { if (m[y[t] + Y[j] * i][x[t] + X[j] * i] == '1') { x[r] = x[t] + X[j] * i; y[r] = y[t] + Y[j] * i; m[y[r]][x[r++]] = '0'; } } } } printf("Date %d:\n", c + 1); for (i = 0; i < 8; i++) { printf("%s\n", m[i + 3] + 3); } } return 0; }
#include <stdio.h> int main() { int n, x[65], y[65], c, i, j, t, r; char m[15][15]; int X[4] = {0, 1, 0, -1}; int Y[4] = {1, 0, -1, 0}; scanf("%d", &n); for (c = 0; c < n; c++) { for (i = 0; i < 8; i++) scanf(" %s", m[i + 3] + 3); scanf(" %d %d", &x[0], &y[t = 0]); x[0] += 2; y[0] += 2; m[y[0]][x[0]] = '0'; for (r = 1; t != r; t++) { for (i = 1; i < 4; i++) { for (j = 0; j < 4; j++) { if (m[y[t] + Y[j] * i][x[t] + X[j] * i] == '1') { x[r] = x[t] + X[j] * i; y[r] = y[t] + Y[j] * i; m[y[r]][x[r++]] = '0'; } } } } printf("Data %d:\n", c + 1); for (i = 0; i < 8; i++) { printf("%s\n", m[i + 3] + 3); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
360
2
#include <stdio.h> int main() { int n, i, j, k, t, r, ny, nx, x[100], y[100]; int X[] = {0, 1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3}; int Y[] = {1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3, 0}; char xx, yy, m[15][15] = {0}; scanf("%d", &n); // printf("%d\n",n); for (i = 0; i < n; i++) { for (j = t = 0; j < 8; j++) scanf(" %s", m[j + 3] + 3); // for(j=0;j<8;j++)printf("%s\n",m[j+3]+3);printf("b"); scanf(" %c %c", &xx, &yy); // printf("a\n"); x[0] = xx - '0' + 2; y[0] = yy - '0' + 2; m[y[0]][x[0]] = '0'; // printf("%d %d\n",y[0],x[0]); for (r = 1; r - t; t++) { for (k = 0; k < 12; k++) { ny = y[t] + Y[k]; nx = x[t] + X[k]; if (m[ny][nx] == '1') { m[ny][nx] = '0'; y[r] = ny; x[r++] = nx; } } } printf("Date %d:\n", i + 1); for (j = 0; j < 8; j++) printf("%s\n", m[j + 3] + 3); } return 0; }
#include <stdio.h> int main() { int n, i, j, k, t, r, ny, nx, x[100], y[100]; int X[] = {0, 1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3}; int Y[] = {1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3, 0}; char xx, yy, m[15][15] = {0}; scanf("%d", &n); // printf("%d\n",n); for (i = 0; i < n; i++) { for (j = t = 0; j < 8; j++) scanf(" %s", m[j + 3] + 3); // for(j=0;j<8;j++)printf("%s\n",m[j+3]+3);printf("b"); scanf(" %c %c", &xx, &yy); // printf("a\n"); x[0] = xx - '0' + 2; y[0] = yy - '0' + 2; m[y[0]][x[0]] = '0'; // printf("%d %d\n",y[0],x[0]); for (r = 1; r - t; t++) { for (k = 0; k < 12; k++) { ny = y[t] + Y[k]; nx = x[t] + X[k]; if (m[ny][nx] == '1') { m[ny][nx] = '0'; y[r] = ny; x[r++] = nx; } } } printf("Data %d:\n", i + 1); for (j = 0; j < 8; j++) printf("%s\n", m[j + 3] + 3); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
373
2
// mitocode #include <stdio.h> void bomb(int x, int y); char field[10][10]; int main(void) { int n, m; int i, j; int x, y; m = 0; scanf("%d", &n); while (m < n) { for (i = 0; i < 8; i++) { scanf("%s", field[i]); } scanf("%d %d", &x, &y); bomb(x - 1, y - 1); printf("Date %d:\n", m + 1); for (i = 0; i < 8; i++) { printf("%s\n", field[i]); } m++; } return (0); } void bomb(int x, int y) { int i; field[y][x] = '0'; for (i = 1; i <= 3; i++) { if (field[y][x - i] == '1' && x - i >= 0) { bomb(x - i, y); } if (field[y][x + i] == '1' && x + i <= 7) { // 8 -> 7 bomb(x + i, y); } if (field[y - i][x] == '1' && y - i >= 0) { bomb(x, y - i); } if (field[y + i][x] == '1' && y + i <= 7) { // 8 -> 7 bomb(x, y + i); } } }
// mitocode #include <stdio.h> void bomb(int x, int y); char field[10][10]; int main(void) { int n, m; int i, j; int x, y; m = 0; scanf("%d", &n); while (m < n) { for (i = 0; i < 8; i++) { scanf("%s", field[i]); } scanf("%d %d", &x, &y); bomb(x - 1, y - 1); printf("Data %d:\n", m + 1); for (i = 0; i < 8; i++) { printf("%s\n", field[i]); } m++; } return (0); } void bomb(int x, int y) { int i; field[y][x] = '0'; for (i = 1; i <= 3; i++) { if (field[y][x - i] == '1' && x - i >= 0) { bomb(x - i, y); } if (field[y][x + i] == '1' && x + i < 8) { bomb(x + i, y); } if (field[y - i][x] == '1' && y - i >= 0) { bomb(x, y - i); } if (field[y + i][x] == '1' && y + i < 8) { bomb(x, y + i); } } }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
0
340
10
#include <stdio.h> int main(void) { int nu, x, y; char bomb[14][14] = {0}; int num[14][14]; int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r; scanf("%d", &nu); for (a = 0; a < nu; a++) { for (b = 3; b < 11; b++) { scanf("%s", bomb[b]); } for (c = 0; c < 8; c++) { for (d = 7; d >= 0; d--) { bomb[c + 3][d + 3] = bomb[c + 3][d]; bomb[c + 3][d] = 0; } } for (e = 0; e < 14; e++) { for (f = 0; f < 14; f++) { if (bomb[e][f] == '\0') { bomb[e][f] = '0'; } } } for (g = 0; g < 14; g++) { for (h = 0; h < 14; h++) { num[g][h] = bomb[g][h] - '0'; } } scanf("%d%d", &x, &y); num[y + 2][x + 2] = 3; while (1) { p = 0; for (i = 3; i < 11; i++) { for (j = 3; j < 11; j++) { for (k = 0; k < 7; k++) { if (num[i - 3 + k][j] == 3 || num[i][j - 3 + k] == 3) { if (num[i][j] == 1) { num[i][j] = 2; } } } } } for (l = 3; l < 11; l++) { for (m = 3; m < 11; m++) { if (num[l][m] == 3) { num[l][m] = 0; p++; } } } for (n = 3; n < 11; n++) { for (o = 3; o < 11; o++) { if (num[n][o] == 2) { num[n][o] = 3; } } } if (p == 0) { break; } } printf("Data %d\n", a + 1); for (q = 3; q < 11; q++) { for (r = 3; r < 11; r++) { printf("%d", num[q][r]); } printf("\n"); } } return 0; }
#include <stdio.h> int main(void) { int nu, x, y; char bomb[14][14] = {0}; int num[14][14]; int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r; scanf("%d", &nu); for (a = 0; a < nu; a++) { for (b = 3; b < 11; b++) { scanf("%s", bomb[b]); } for (c = 0; c < 8; c++) { for (d = 7; d >= 0; d--) { bomb[c + 3][d + 3] = bomb[c + 3][d]; bomb[c + 3][d] = 0; } } for (e = 0; e < 14; e++) { for (f = 0; f < 14; f++) { if (bomb[e][f] == '\0') { bomb[e][f] = '0'; } } } for (g = 0; g < 14; g++) { for (h = 0; h < 14; h++) { num[g][h] = bomb[g][h] - '0'; } } scanf("%d%d", &x, &y); num[y + 2][x + 2] = 3; while (1) { p = 0; for (i = 3; i < 11; i++) { for (j = 3; j < 11; j++) { for (k = 0; k < 7; k++) { if (num[i - 3 + k][j] == 3 || num[i][j - 3 + k] == 3) { if (num[i][j] == 1) { num[i][j] = 2; } } } } } for (l = 3; l < 11; l++) { for (m = 3; m < 11; m++) { if (num[l][m] == 3) { num[l][m] = 0; p++; } } } for (n = 3; n < 11; n++) { for (o = 3; o < 11; o++) { if (num[n][o] == 2) { num[n][o] = 3; } } } if (p == 0) { break; } } printf("Data %d:\n", a + 1); for (q = 3; q < 11; q++) { for (r = 3; r < 11; r++) { printf("%d", num[q][r]); } printf("\n"); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
625
2
#include <stdio.h> char map[8][8]; void bomb(int x, int y) { int i; if (x < 0 || x > 7 || y < 0 || y > 7) return; if (map[y][x] == '1') { map[y][x] = '0'; for (i = 1; i <= 3; i++) { bomb(x + i, y); bomb(x - i, y); bomb(x, y + i); bomb(x, y - i); } } return; } void print_map(int n) { int i, j; printf("data %d:\n", n); for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { printf("%c", map[i][j]); } putchar('\n'); } return; } int main(void) { int i, j, k; int n; int x, y; scanf("%d ", &n); for (i = 0; i < n; i++) { for (j = 0; j < 8; j++) { for (k = 0; k < 8; k++) { scanf(" %c ", &map[j][k]); } } scanf(" %d %d ", &x, &y); bomb(x - 1, y - 1); print_map(i + 1); } return 0; }
#include <stdio.h> char map[8][8]; void bomb(int x, int y) { int i; if (x < 0 || x > 7 || y < 0 || y > 7) return; if (map[y][x] == '1') { map[y][x] = '0'; for (i = 1; i <= 3; i++) { bomb(x + i, y); bomb(x - i, y); bomb(x, y + i); bomb(x, y - i); } } return; } void print_map(int n) { int i, j; printf("Data %d:\n", n); for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { printf("%c", map[i][j]); } putchar('\n'); } return; } int main(void) { int i, j, k; int n; int x, y; scanf("%d ", &n); for (i = 0; i < n; i++) { for (j = 0; j < 8; j++) { for (k = 0; k < 8; k++) { scanf(" %c ", &map[j][k]); } } scanf(" %d %d ", &x, &y); bomb(x - 1, y - 1); print_map(i + 1); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
330
2
#include <stdio.h> void bomb(int x, int y, int map[8][8]) { int i; map[y][x] = 0; for (i = ((x - 3 < 0) ? 0 : (x - 3)); i <= ((x + 3 > 7) ? 7 : (x + 3)); i++) { if (map[y][i] == 1) { bomb(i, y, map); break; } map[y][i] = 0; } for (i = ((y - 3 < 0) ? 0 : (y - 3)); i <= ((y + 3 > 7) ? 7 : (y + 3)); i++) { if (map[i][x] == 1) { bomb(x, i, map); break; } map[i][x] = 0; } return; } int main(int argc, char *argv[]) { int n, i, j, k; int map[8][8]; char buf[9]; scanf("%d", &n); for (i = 0; i < n; i++) { int x, y; for (j = 0; j < 8; j++) { scanf("%s", buf); for (k = 0; k < 8; k++) { map[j][k] = buf[k] - '0'; } } scanf("%d", &x); scanf("%d", &y); bomb(x - 1, y - 1, map); printf("Data %d:\n", i + 1); for (j = 0; j < 8; j++) { for (k = 0; k < 8; k++) { printf("%d", map[j][k]); } printf("\n"); } } return 0; }
#include <stdio.h> void bomb(int x, int y, int map[8][8]) { int i; map[y][x] = 0; for (i = ((x - 3 < 0) ? 0 : (x - 3)); i <= ((x + 3 > 7) ? 7 : (x + 3)); i++) { if (map[y][i] == 1) { bomb(i, y, map); } map[y][i] = 0; } for (i = ((y - 3 < 0) ? 0 : (y - 3)); i <= ((y + 3 > 7) ? 7 : (y + 3)); i++) { if (map[i][x] == 1) { bomb(x, i, map); } map[i][x] = 0; } return; } int main(int argc, char *argv[]) { int n, i, j, k; int map[8][8]; char buf[9]; scanf("%d", &n); for (i = 0; i < n; i++) { int x, y; for (j = 0; j < 8; j++) { scanf("%s", buf); for (k = 0; k < 8; k++) { map[j][k] = buf[k] - '0'; } } scanf("%d", &x); scanf("%d", &y); bomb(x - 1, y - 1, map); printf("Data %d:\n", i + 1); for (j = 0; j < 8; j++) { for (k = 0; k < 8; k++) { printf("%d", map[j][k]); } printf("\n"); } } return 0; }
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
0
425
4
#include <math.h> #include <stdio.h> int bomb[8][8]; void fire(int i, int j) { int k; bomb[i][j] = 0; for (k = (i < 3 ? 0 : i - 3); k < (i > 4 ? 8 : i + 4); k++) if (bomb[k][j]) fire(k, j); for (k = (j < 3 ? 0 : j - 3); k < (j > 4 ? 8 : j + 4); k++) if (bomb[i][k]) fire(i, k); } int main(void) { int i, j, n, x; scanf("%d", &n); for (x = 1; x <= n; x++) { printf("Data: %d\n", x); for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { scanf("%1d", &bomb[i][j]); } } scanf("%d %d", &j, &i); fire(i - 1, j - 1); for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { printf("%d", bomb[i][j]); } printf("\n"); } } return 0; }
#include <math.h> #include <stdio.h> int bomb[8][8]; void fire(int i, int j) { int k; bomb[i][j] = 0; for (k = (i < 3 ? 0 : i - 3); k < (i > 4 ? 8 : i + 4); k++) if (bomb[k][j]) fire(k, j); for (k = (j < 3 ? 0 : j - 3); k < (j > 4 ? 8 : j + 4); k++) if (bomb[i][k]) fire(i, k); } int main(void) { int i, j, n, x; scanf("%d", &n); for (x = 1; x <= n; x++) { printf("Data %d:\n", x); for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { scanf("%1d", &bomb[i][j]); } } scanf("%d %d", &j, &i); fire(i - 1, j - 1); for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { printf("%d", bomb[i][j]); } printf("\n"); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
313
2
#include <cstdio> using namespace std; char field[8][12]; void bomb(int x, int y) { field[x][y] = '0'; for (int i = -3; i <= 3; i++) { if (x + i >= 0 && x + i < 8 && field[x + i][y] == '1') { bomb(x + i, y); } if (y + i >= 0 && y + i < 8 && field[x][y + i] == '1') { bomb(x, y + i); } } } int main() { int N, X, Y; scanf("%d", &N); for (int n = 1; n <= N; n++) { for (int i = 0; i < 8; i++) { scanf(" %s", field[i]); } scanf("%d%d", &Y, &X); --X; --Y; bomb(X, Y); printf("Data:%d\n", n); for (int i = 0; i < 8; i++) { printf("%s\n", field[i]); } } return 0; }
#include <cstdio> using namespace std; char field[8][12]; void bomb(int x, int y) { field[x][y] = '0'; for (int i = -3; i <= 3; i++) { if (x + i >= 0 && x + i < 8 && field[x + i][y] == '1') { bomb(x + i, y); } if (y + i >= 0 && y + i < 8 && field[x][y + i] == '1') { bomb(x, y + i); } } } int main() { int N, X, Y; scanf("%d", &N); for (int n = 1; n <= N; n++) { for (int i = 0; i < 8; i++) { scanf(" %s", field[i]); } scanf("%d%d", &Y, &X); --X; --Y; bomb(X, Y); printf("Data %d:\n", n); for (int i = 0; i < 8; i++) { printf("%s\n", field[i]); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
267
2
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; typedef pair<int, int> P; typedef queue<P> Q; const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; int main() { int n; cin >> n; int count = 0; while (n > count) { vector<string> v(8, "00000000"); for (auto &i : v) { string t; cin >> t; i = t; } int x, y; cin >> y >> x; Q q; q.push(P(x - 1, y - 1)); while (!q.empty()) { P p = q.front(); q.pop(); x = p.first; y = p.second; v[x][y] = '0'; for (int i = 0; i < 4; i++) { for (int j = 1; j <= 3; j++) { int nx = x + dx[i] * j, ny = y + dy[i] * j; if (0 <= nx && nx < 8 && 0 <= ny && ny < 8 && v[nx][ny] == '1') { q.push(P(nx, ny)); } } } } cout << "Date " << (++count) << ":" << endl; for (auto i : v) { cout << i << endl; } } return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; typedef pair<int, int> P; typedef queue<P> Q; const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; int main() { int n; cin >> n; int count = 0; while (n > count) { vector<string> v(8, "00000000"); for (auto &i : v) { string t; cin >> t; i = t; } int x, y; cin >> y >> x; Q q; q.push(P(x - 1, y - 1)); while (!q.empty()) { P p = q.front(); q.pop(); x = p.first; y = p.second; v[x][y] = '0'; for (int i = 0; i < 4; i++) { for (int j = 1; j <= 3; j++) { int nx = x + dx[i] * j, ny = y + dy[i] * j; if (0 <= nx && nx < 8 && 0 <= ny && ny < 8 && v[nx][ny] == '1') { q.push(P(nx, ny)); } } } } cout << "Data " << (++count) << ":" << endl; for (auto i : v) { cout << i << endl; } } return 0; }
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
332
2
#include <cstdio> char bom[10][10]; int dy[] = {-1, -2, -3, 0, 0, 0, 1, 2, 3, 0, 0, 0}, dx[] = {0, 0, 0, 1, 2, 3, 0, 0, 0, -1, -2, -3}; void dfs(int y, int x) { if (y < 0 || x < 0 || y > 8 || x > 8) return; if (bom[y][x] == 0) return; if (bom[y][x] == '1') { bom[y][x] = '0'; for (int i = 0; i < 12; i++) { dfs(y + dy[i], x + dx[i]); } } } int main() { int a, b, num; scanf("%d", &num); for (int kazu = 0; kazu < num; kazu++) { for (int i = 0; i < 8; i++) { scanf("%s", bom[i]); } scanf("%d %d", &a, &b); dfs(b - 1, a - 1); printf("DATA %d:\n", kazu + 1); for (int i = 0; i < 8; i++) { printf("%s\n", bom[i]); } } }
#include <cstdio> char bom[10][10]; int dy[] = {-1, -2, -3, 0, 0, 0, 1, 2, 3, 0, 0, 0}, dx[] = {0, 0, 0, 1, 2, 3, 0, 0, 0, -1, -2, -3}; void dfs(int y, int x) { if (y < 0 || x < 0 || y > 8 || x > 8) return; if (bom[y][x] == 0) return; if (bom[y][x] == '1') { bom[y][x] = '0'; for (int i = 0; i < 12; i++) { dfs(y + dy[i], x + dx[i]); } } } int main() { int a, b, num; scanf("%d", &num); for (int kazu = 0; kazu < num; kazu++) { for (int i = 0; i < 8; i++) { scanf("%s", bom[i]); } scanf("%d %d", &a, &b); dfs(b - 1, a - 1); printf("Data %d:\n", kazu + 1); for (int i = 0; i < 8; i++) { printf("%s\n", bom[i]); } } }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
310
2
#include <bits/stdc++.h> using namespace std; int n, a, b, c; char miti[10][10]; void bobm(int x, int y) { for (int s = 1; s <= 3; s++) { if (x + s < 9) { if (miti[x + s][y] == '1') { miti[x + s][y] = '0'; bobm(x + s, y); } } if (y - s > 0) { if (miti[x][y - s] == '1') { miti[x][y - s] = '0'; bobm(x, y - s); } } if (x - s > 0) { if (miti[x - s][y] == '1') { miti[x - s][y] = '0'; bobm(x - s, y); } } if (y + s < 9) { if (miti[x][y + s] == '1') { miti[x][y + s] = '0'; bobm(x, y + s); } } } } int main() { cin >> n; for (int k = 1; k <= n; k++) { for (int i = 1; i < 9; i++) { for (int j = 1; j < 9; j++) { cin >> miti[j][i]; } } cin >> a >> b; miti[a][b] = '0'; bobm(a, b); cout << "Date " << k << ":" << endl; for (int i = 1; i < 9; i++) { for (int j = 1; j < 9; j++) { cout << miti[j][i]; } cout << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, c; char miti[10][10]; void bobm(int x, int y) { for (int s = 1; s <= 3; s++) { if (x + s < 9) { if (miti[x + s][y] == '1') { miti[x + s][y] = '0'; bobm(x + s, y); } } if (y - s > 0) { if (miti[x][y - s] == '1') { miti[x][y - s] = '0'; bobm(x, y - s); } } if (x - s > 0) { if (miti[x - s][y] == '1') { miti[x - s][y] = '0'; bobm(x - s, y); } } if (y + s < 9) { if (miti[x][y + s] == '1') { miti[x][y + s] = '0'; bobm(x, y + s); } } } } int main() { cin >> n; for (int k = 1; k <= n; k++) { for (int i = 1; i < 9; i++) { for (int j = 1; j < 9; j++) { cin >> miti[j][i]; } } cin >> a >> b; miti[a][b] = '0'; bobm(a, b); cout << "Data " << k << ":" << endl; for (int i = 1; i < 9; i++) { for (int j = 1; j < 9; j++) { cout << miti[j][i]; } cout << endl; } } return 0; }
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
411
2
#include <algorithm> #include <array> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <unordered_map> #include <unordered_set> #include <valarray> #include <vector> using namespace std; using ll = long long; using ull = unsigned long long; constexpr int TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } const int d4[4][2] = { {1, 0}, {0, 1}, {-1, 0}, {0, -1}, }; bool solve() { bool g[8][8]; for (int i = 0; i < 8; i++) { string s; cin >> s; for (int j = 0; j < 8; j++) { g[i][j] = (s[j] == '1'); } } int x, y; cin >> x >> y; x--; y--; using P = pair<int, int>; queue<P> q; q.push(P(x, y)); bool bk[8][8] = {}; while (q.size()) { int x, y; tie(x, y) = q.front(); q.pop(); if (bk[y][x] or !g[y][x]) continue; bk[y][x] = true; for (int d = 0; d < 4; d++) { int nx = x, ny = y; for (int i = 0; i < 3; i++) { nx += d4[d][0]; ny += d4[d][1]; if (!(0 <= nx and nx < 8 and 0 <= ny and ny < 8)) continue; q.push(P(nx, ny)); } } } for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (!g[i][j] or bk[i][j]) { cout << '0'; } else { cout << '1'; } } cout << endl; } return true; } int main() { int ca = 0; cin >> ca; for (int i = 0; i < ca; i++) { cout << "Data " << i << ":" << endl; if (!solve()) break; } return 0; }
#include <algorithm> #include <array> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <unordered_map> #include <unordered_set> #include <valarray> #include <vector> using namespace std; using ll = long long; using ull = unsigned long long; constexpr int TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } const int d4[4][2] = { {1, 0}, {0, 1}, {-1, 0}, {0, -1}, }; bool solve() { bool g[8][8]; for (int i = 0; i < 8; i++) { string s; cin >> s; for (int j = 0; j < 8; j++) { g[i][j] = (s[j] == '1'); } } int x, y; cin >> x >> y; x--; y--; using P = pair<int, int>; queue<P> q; q.push(P(x, y)); bool bk[8][8] = {}; while (q.size()) { int x, y; tie(x, y) = q.front(); q.pop(); if (bk[y][x] or !g[y][x]) continue; bk[y][x] = true; for (int d = 0; d < 4; d++) { int nx = x, ny = y; for (int i = 0; i < 3; i++) { nx += d4[d][0]; ny += d4[d][1]; if (!(0 <= nx and nx < 8 and 0 <= ny and ny < 8)) continue; q.push(P(nx, ny)); } } } for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (!g[i][j] or bk[i][j]) { cout << '0'; } else { cout << '1'; } } cout << endl; } return true; } int main() { int ca = 0; cin >> ca; for (int i = 0; i < ca; i++) { cout << "Data " << i + 1 << ":" << endl; if (!solve()) break; } return 0; }
[["+", 0, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 12, 13]]
1
536
2
import java.io.*; public class Main { public static void main(String... args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; double x[] = new double[20]; double y[] = new double[20]; int i = 0; while ((line = br.readLine()) != null) { String numbers[] = line.split(","); x[i] = Double.parseDouble(numbers[0]) - x[0]; y[i] = Double.parseDouble(numbers[1]) - y[0]; i++; } double area = 0; for (int k = 0; k < i; k++) { area += x[k] * y[k + 1] - x[k + 1] * y[k]; } System.out.println(Math.abs(area * 0.5)); } }
import java.io.*; public class Main { public static void main(String... args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; double x[] = new double[20]; double y[] = new double[20]; int i = 0; while ((line = br.readLine()) != null) { String numbers[] = line.split(","); x[i] = Double.parseDouble(numbers[0]) - x[0]; y[i] = Double.parseDouble(numbers[1]) - y[0]; i++; } double area = 0; for (int k = 1; k < i; k++) { area += x[k] * y[k + 1] - x[k + 1] * y[k]; } System.out.println(Math.abs(area * 0.5)); } }
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
209
2
import java.util.Scanner; // Area of Polygon public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double[][] p = new double[20][2]; int n = 0; while (sc.hasNext()) { String s[] = sc.next().split(","); p[n][0] = Double.parseDouble(s[0]); p[n][1] = Double.parseDouble(s[1]); n++; } double a = 0; for (int i = 0; i < n - 1; i++) { double x1 = p[i][0]; double y1 = p[i][1]; double x2 = p[(i + 1) % n][0]; double y2 = p[(i + 1) % n][1]; a += x1 * y2 - x2 * y1; } System.out.println(Math.abs(a / 2)); } }
import java.util.Scanner; // Area of Polygon public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double[][] p = new double[20][2]; int n = 0; while (sc.hasNext()) { String s[] = sc.next().split(","); p[n][0] = Double.parseDouble(s[0]); p[n][1] = Double.parseDouble(s[1]); n++; } double a = 0; for (int i = 0; i < n; i++) { double x1 = p[i][0]; double y1 = p[i][1]; double x2 = p[(i + 1) % n][0]; double y2 = p[(i + 1) % n][1]; a += x1 * y2 - x2 * y1; } System.out.println(Math.abs(a / 2)); } }
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
3
229
2
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; public class Main { int INF = 1 << 28; void run() { Scanner sc = new Scanner(System.in); double s = 0; double[] x = new double[3]; double[] y = new double[3]; String[] str = sc.next().split(","); x[0] = Double.parseDouble(str[0]); y[0] = Double.parseDouble(str[1]); str = sc.next().split(","); x[2] = x[1] = Double.parseDouble(str[0]); y[2] = y[1] = Double.parseDouble(str[1]); while (sc.hasNext()) { x[1] = x[2]; y[1] = y[1]; str = sc.next().split(","); x[2] = Double.parseDouble(str[0]); y[2] = Double.parseDouble(str[1]); s += area(line(x, y)); } System.out.println(s); } double[] line(double[] x, double[] y) { double[] d = new double[3]; for (int i = 0; i < 3; i++) { d[i] = sqrt((x[i] - x[(i + 1) % 3]) * (x[i] - x[(i + 1) % 3]) + (y[i] - y[(i + 1) % 3]) * (y[i] - y[(i + 1) % 3])); } return d; } double area(double[] d) { double len = d[0] + d[1] + d[2]; return sqrt(len * (len - d[0]) * (len - d[1]) * (len - d[2])); } public static void main(String[] args) { new Main().run(); } }
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; public class Main { int INF = 1 << 28; void run() { Scanner sc = new Scanner(System.in); double s = 0; double[] x = new double[3]; double[] y = new double[3]; String[] str = sc.next().split(","); x[0] = Double.parseDouble(str[0]); y[0] = Double.parseDouble(str[1]); str = sc.next().split(","); x[2] = x[1] = Double.parseDouble(str[0]); y[2] = y[1] = Double.parseDouble(str[1]); while (sc.hasNext()) { x[1] = x[2]; y[1] = y[2]; str = sc.next().split(","); x[2] = Double.parseDouble(str[0]); y[2] = Double.parseDouble(str[1]); s += area(line(x, y)); } System.out.println(s); } double[] line(double[] x, double[] y) { double[] d = new double[3]; for (int i = 0; i < 3; i++) { d[i] = sqrt((x[i] - x[(i + 1) % 3]) * (x[i] - x[(i + 1) % 3]) + (y[i] - y[(i + 1) % 3]) * (y[i] - y[(i + 1) % 3])); } return d; } double area(double[] d) { double len = (d[0] + d[1] + d[2]) / 2; return sqrt(len * (len - d[0]) * (len - d[1]) * (len - d[2])); } public static void main(String[] args) { new Main().run(); } }
[["-", 8, 196, 0, 1, 0, 11, 12, 504, 71, 499], ["+", 8, 196, 0, 1, 0, 11, 12, 504, 71, 499], ["+", 0, 503, 49, 200, 51, 16, 31, 23, 0, 24], ["+", 0, 503, 49, 200, 51, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 17, 85], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 12, 499]]
3
491
6
#include <math.h> #include <stdio.h> int main(void) { double a[20], b[20], A, B, C, Z, S; int i = 0, j; while (scanf("%lf,%lf", &a[i], &b[i]) != EOF) i++; for (j = 1; j <= i - 1; j++) { A = sqrt((a[0] - a[j]) * (a[0] - a[j]) + (b[0] - b[j]) * (b[0] - b[j])); B = sqrt((a[j] - a[j + 1]) * (a[j] - a[j + 1]) + (b[j] - b[j + 1]) * (b[j] - b[j + 1])); C = sqrt((a[0] - a[j + 1]) * (a[0] - a[j + 1]) + (b[0] - b[j + 1]) * (b[0] - b[j + 1])); Z = (A + B + C) / 2; S += sqrt(Z * (Z - A) * (Z - B) * (Z - C)); } printf("%f\n", S); return 0; }
#include <math.h> #include <stdio.h> int main(void) { double a[20], b[20], A, B, C, Z, S; int i = 0, j; while (scanf("%lf,%lf", &a[i], &b[i]) != EOF) i++; for (j = 1; j < i - 1; j++) { A = sqrt((a[0] - a[j]) * (a[0] - a[j]) + (b[0] - b[j]) * (b[0] - b[j])); B = sqrt((a[j] - a[j + 1]) * (a[j] - a[j + 1]) + (b[j] - b[j + 1]) * (b[j] - b[j + 1])); C = sqrt((a[0] - a[j + 1]) * (a[0] - a[j + 1]) + (b[0] - b[j + 1]) * (b[0] - b[j + 1])); Z = (A + B + C) / 2; S += sqrt(Z * (Z - A) * (Z - B) * (Z - C)); } printf("%f\n", S); return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
0
307
2
#include <math.h> #include <stdio.h> int main(void) { double x[21], y[21], s = 0.0; int n = 1, i; y[0] = 0; while (scanf("%lf,%lf", &x[n], &y[n]) != EOF) { n++; } x[0] = x[n]; x[n + 1] = x[1]; for (i = 1; i < n; i++) { s += (x[i - 1] - x[i + 1]) * y[i]; } s *= -0.5; printf("%f\n", fabs(s)); return 0; }
#include <math.h> #include <stdio.h> int main(void) { double x[21], y[21], s = 0.0; int n = 0, i; y[0] = 0; while (scanf("%lf,%lf", &x[n + 1], &y[n + 1]) != EOF) { n++; } x[0] = x[n]; x[n + 1] = x[1]; for (i = 1; i <= n; i++) { s += (x[i - 1] - x[i + 1]) * y[i]; } s *= -0.5; printf("%f\n", fabs(s)); return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 3, 4, 0, 66, 28, 69, 71, 16, 17, 72], ["+", 3, 4, 0, 66, 28, 69, 71, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
0
148
8
#include <math.h> #include <stdio.h> double area(double a, double b, double c); int main() { int i, n = 0; double x[20]; double y[20]; double a, b, c, s = 0; while (scanf("%f,%f", &x[n], &y[n]) != EOF) { n++; } for (i = 1; i < n - 1; i++) { a = sqrt((x[0] - x[i]) * (x[0] - x[i]) + (y[0] - y[i]) * (y[0] - y[i])); b = sqrt((x[0] - x[i + 1]) * (x[0] - x[i + 1]) + (y[0] - y[i + 1]) * (y[0] - y[i + 1])); c = sqrt((x[i + 1] - x[i]) * (x[i + 1] - x[i]) + (y[i + 1] - y[i]) * (y[i + 1] - y[i])); s += area(a, b, c); } printf("%f\n", s); } double area(double a, double b, double c) { double z = (a + b + c) / 2; return sqrt(z * (z - a) * (z - b) * (z - c)); }
#include <math.h> #include <stdio.h> double area(double a, double b, double c); int main() { int i, n = 0; double x[20]; double y[20]; double a, b, c, s = 0; while (scanf("%lf,%lf", &x[n], &y[n]) != EOF) { n++; } for (i = 1; i < n - 1; i++) { a = sqrt((x[0] - x[i]) * (x[0] - x[i]) + (y[0] - y[i]) * (y[0] - y[i])); b = sqrt((x[0] - x[i + 1]) * (x[0] - x[i + 1]) + (y[0] - y[i + 1]) * (y[0] - y[i + 1])); c = sqrt((x[i + 1] - x[i]) * (x[i + 1] - x[i]) + (y[i + 1] - y[i]) * (y[i + 1] - y[i])); s += area(a, b, c); } printf("%f\n", s); return 0; } double area(double a, double b, double c) { double z = (a + b + c) / 2; return sqrt(z * (z - a) * (z - b) * (z - c)); }
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13]]
0
345
5
#include <math.h> #include <stdio.h> int main() { int i = 0, j; double x[21], y[21], s = 0; //値の読み込み while (scanf("%lf,%lf\n", &x[i], &y[i]) != EOF) { // scanf("%lf%lf",&x[i],&y[i]); i++; } j = i; for (i = 1; i < j - 1; i++) { s += (x[i] * y[i + 1] - x[i + 1] * y[i]); } s += (x[i] * y[0] - x[0] * y[i]); printf("%.6lf\n", (fabs(s)) / 2.0); return 0; }
#include <math.h> #include <stdio.h> int main() { int i = 0, j; double x[21], y[21], s = 0; //値の読み込み while (scanf("%lf,%lf\n", &x[i], &y[i]) != EOF) { // scanf("%lf%lf",&x[i],&y[i]); i++; } j = i; for (i = 0; i < j - 1; i++) { s += (x[i] * y[i + 1] - x[i + 1] * y[i]); } s += (x[i] * y[0] - x[0] * y[i]); printf("%.6lf\n", (fabs(s)) / 2.0); return 0; }
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]]
0
156
2
#define cross(a1, b1, a2, b2) ((a1) * (b2) - (a2) * (b1)) int main() { double a[20], b[20], s, t, x; int n = 0, c = 1, i; for (; ~scanf("%lf,%lf", a + n, b + n); n++) ; for (n = i, i = s = t = 0; i < n - 1; i++) { if ((x = cross(a[i], b[i], a[i + 1], b[i + 1])) > 0) s += fabs(x) / 2.0; else t += fabs(x) / 2; } if ((x = cross(a[i], b[i], a[0], b[0])) > 0) s += fabs(x) / 2; else t += fabs(x) / 2; printf("%.6f\n", fabs(s - t)); exit(0); }
#define cross(a1, b1, a2, b2) ((a1) * (b2) - (a2) * (b1)) int main() { double a[20], b[20], s, t, x; int n = 0, c = 1, i; for (; ~scanf("%lf,%lf", a + n, b + n); n++) ; for (i = s = t = 0; i < n - 1; i++) { if ((x = cross(a[i], b[i], a[i + 1], b[i + 1])) > 0) s += fabs(x) / 2.0; else t += fabs(x) / 2; } if ((x = cross(a[i], b[i], a[0], b[0])) > 0) s += fabs(x) / 2; else t += fabs(x) / 2; printf("%.6f\n", fabs(s - t)); exit(0); }
[["-", 8, 9, 0, 7, 10, 34, 31, 11, 31, 22], ["-", 8, 9, 0, 7, 10, 34, 31, 11, 17, 32], ["-", 8, 9, 0, 7, 10, 34, 31, 11, 12, 22], ["-", 0, 14, 8, 9, 0, 7, 10, 34, 0, 21]]
0
218
4
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef unsigned int UI; typedef long long LL; typedef unsigned long long ULL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef istringstream ISS; typedef ostringstream OSS; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define EACH(v, c) for (auto &v : c) #define ITER(c) __typeof((c).begin()) #define IREP(c, it) for (ITER(c) it = c.begin(); it != c.end(); ++it) #define ALL(c) (c).begin(), (c).end() #define PB(n) push_back(n) #define MP(a, b) make_pair((a), (b)) #define EXIST(c, e) ((c).find(e) != (c).end()) #define fst first #define snd second #define DUMP(x) cerr << #x << " = " << (x) << endl #define DEBUG(x) \ cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << (x) << endl struct Point { double x, y; Point() : x(0), y(0) { return; } Point(double x, double y) : x(x), y(y) { return; } Point operator+(const Point &a) const { return Point(x + a.x, y + a.y); } Point operator-(const Point &a) const { return Point(x + (-a.x), y + (-a.y)); } Point operator*(const double &a) const { return Point(x * a, y * a); } Point operator/(const double &a) const { return Point(x / a, y / a); } bool operator<(const Point &a) const { return x == a.x ? y < a.y : x < a.x; } }; double distance(const Point &a, const Point &b) { return sqrt(pow(a.x - b.x, 2.) + pow(a.y - b.y, 2.)); } int main() { cin.tie(0); ios::sync_with_stdio(false); double x, y; char d; vector<Point> ps; while (cin >> x >> d >> y) { ps.PB(Point(x, y)); } const int N = ps.size(); double res = 0; REP(i, 1, N) { double a = distance(ps[0], ps[i]); double b = distance(ps[0], ps[i + 1]); double c = distance(ps[i], ps[i + 1]); double z = (a + b + c) / 2; res += sqrt(z * (z - a) * (z - b) * (z - c)); } cout.precision(7); cout << fixed; cout << res << endl; return 0; }
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef unsigned int UI; typedef long long LL; typedef unsigned long long ULL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef istringstream ISS; typedef ostringstream OSS; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define EACH(v, c) for (auto &v : c) #define ITER(c) __typeof((c).begin()) #define IREP(c, it) for (ITER(c) it = c.begin(); it != c.end(); ++it) #define ALL(c) (c).begin(), (c).end() #define PB(n) push_back(n) #define MP(a, b) make_pair((a), (b)) #define EXIST(c, e) ((c).find(e) != (c).end()) #define fst first #define snd second #define DUMP(x) cerr << #x << " = " << (x) << endl #define DEBUG(x) \ cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << (x) << endl struct Point { double x, y; Point() : x(0), y(0) { return; } Point(double x, double y) : x(x), y(y) { return; } Point operator+(const Point &a) const { return Point(x + a.x, y + a.y); } Point operator-(const Point &a) const { return Point(x + (-a.x), y + (-a.y)); } Point operator*(const double &a) const { return Point(x * a, y * a); } Point operator/(const double &a) const { return Point(x / a, y / a); } bool operator<(const Point &a) const { return x == a.x ? y < a.y : x < a.x; } }; double distance(const Point &a, const Point &b) { return sqrt(pow(a.x - b.x, 2.) + pow(a.y - b.y, 2.)); } int main() { cin.tie(0); ios::sync_with_stdio(false); double x, y; char d; vector<Point> ps; while (cin >> x >> d >> y) { ps.PB(Point(x, y)); } const int N = ps.size(); double res = 0; REP(i, 1, N - 1) { double a = distance(ps[0], ps[i]); double b = distance(ps[0], ps[i + 1]); double c = distance(ps[i], ps[i + 1]); double z = (a + b + c) / 2; res += sqrt(z * (z - a) * (z - b) * (z - c)); } cout.precision(7); cout << fixed; cout << res << endl; return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
606
2
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) #define X real() #define Y imag() typedef complex<double> P; double cross(P a, P b) { return a.X * b.Y - a.Y * b.X; } int main() { double a, b; vector<P> p; while (scanf("%lf,%lf", &a, &b)) { p.push_back(P(a, b)); } double sum = 0; reps(i, 1, p.size() - 1) { sum += cross(p[i] - p[0], p[i + 1] - p[0]) / 2; } printf("%.9lf\n", fabs(sum)); }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define reps(i, f, n) for (int i = f; i < int(n); i++) #define rep(i, n) reps(i, 0, n) #define X real() #define Y imag() typedef complex<double> P; double cross(P a, P b) { return a.X * b.Y - a.Y * b.X; } int main() { double a, b; vector<P> p; while (scanf("%lf,%lf", &a, &b) != EOF) { p.push_back(P(a, b)); } double sum = 0; reps(i, 1, p.size() - 1) { sum += cross(p[i] - p[0], p[i + 1] - p[0]) / 2; } printf("%.9lf\n", fabs(sum)); }
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
195
2
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const double INF = 1e12; typedef complex<double> P; namespace std { bool operator<(const P &a, const P &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } } // namespace std double cross(const P &a, const P &b) { return imag(conj(a) * b); } double dot(const P &a, const P &b) { return real(conj(a) * b); } typedef vector<P> G; double area2(const G &P) { double A = 0; for (int i = 0; i < P.size(); ++i) A += cross(P[i], P[(i + 1) % P.size()]); return A; } int main() { double x, y; G g; while (scanf("%lf,%lf", &x, &y) != EOF) { P p(y, x); g.push_back(p); } printf("%lf\n", area2(g) / 2.); }
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const double INF = 1e12; typedef complex<double> P; namespace std { bool operator<(const P &a, const P &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } } // namespace std double cross(const P &a, const P &b) { return imag(conj(a) * b); } double dot(const P &a, const P &b) { return real(conj(a) * b); } typedef vector<P> G; double area2(const G &P) { double A = 0; for (int i = 0; i < P.size(); ++i) A += cross(P[i], P[(i + 1) % P.size()]); return A; } int main() { double x, y; G g; while (scanf("%lf,%lf", &x, &y) != EOF) { P p(y, x); g.push_back(p); } printf("%lf\n", abs(area2(g) / 2.)); }
[["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
260
3
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; double goa(double xh, double yh, double xc, double yc) { double X = xc - xh; double Y = yc - yh; double a; a = sqrt((xc - xh) * (xc - xh) + (yc - yh) * (yc - yh)); return a; } double mense(double a, double b, double c) { double z; double S; z = (a + b + c) * 0.5; S = sqrt(z * (z - a) * (z - b) * (z - c)); return S; } int main() { double x, y, xh, yh, xc, yc, a = 0, b = 0, c = 0, d = 0, S = 0, s = 0; // cin>>xh>>yh; // cin>>xc>>yc; scanf("%lf,%lf", &xh, &yh); scanf("%lf,%lf", &xc, &yc); scanf("%lf,%lf", &x, &y); // cin>>x>>y; a = goa(xh, yh, xc, yc); b = goa(xc, yc, x, y); c = goa(xh, yh, x, y); S += mense(a, b, c); // cout<<a<<" "<<b<<" "<<c<<endl; xc = x; yc = y; while (scanf("%lf,%lf", &x, &y) != EOF) { a = goa(xh, yh, x, y); b = goa(xc, yc, x, y); c = goa(xh, yh, x, y); S += mense(a, b, c); xc = x; yc = y; /* goa(xh,yh,x,y,a); goa(xc,yc,x,y,b); goa(xh,yh,x,y,c); S+=mense(a,b,c); xc=x;yc=y; */ } printf("%lf\n", S); return 0; }
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; double goa(double xh, double yh, double xc, double yc) { double X = xc - xh; double Y = yc - yh; double a; a = sqrt((xc - xh) * (xc - xh) + (yc - yh) * (yc - yh)); return a; } double mense(double a, double b, double c) { double z; double S; z = (a + b + c) * 0.5; S = sqrt(z * (z - a) * (z - b) * (z - c)); return S; } int main() { double x, y, xh, yh, xc, yc, a = 0, b = 0, c = 0, d = 0, S = 0, s = 0; // cin>>xh>>yh; // cin>>xc>>yc; scanf("%lf,%lf", &xh, &yh); scanf("%lf,%lf", &xc, &yc); scanf("%lf,%lf", &x, &y); // cin>>x>>y; a = goa(xh, yh, xc, yc); b = goa(xc, yc, x, y); c = goa(xh, yh, x, y); S += mense(a, b, c); // cout<<a<<" "<<b<<" "<<c<<endl; xc = x; yc = y; while (scanf("%lf,%lf", &x, &y) != EOF) { a = goa(xh, yh, xc, yc); b = goa(xc, yc, x, y); c = goa(xh, yh, x, y); S += mense(a, b, c); xc = x; yc = y; /* goa(xh,yh,x,y,a); goa(xc,yc,x,y,b); goa(xh,yh,x,y,c); S+=mense(a,b,c); xc=x;yc=y; */ } printf("%lf\n", S); return 0; }
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
371
4
#include <algorithm> #include <cmath> #include <complex> #include <iostream> #include <stdio.h> #include <vector> using namespace std; typedef complex<double> xy_t; xy_t P[110]; int main() { int N = 0; double x, y; while (~scanf("%lf,%lf", &x, &y)) { P[N++] = xy_t(x, y); double sum = 0.0; for (int i = 0; i + 2 < N; ++i) { xy_t a = P[0], b = P[i + 1], c = P[i + 2]; sum += abs(((conj(b - a) * (c - a)).imag()) / 2.0); } printf("%.6f\n", abs(sum)); } return 0; }
#include <algorithm> #include <cmath> #include <complex> #include <iostream> #include <stdio.h> #include <vector> using namespace std; typedef complex<double> xy_t; xy_t P[110]; int main() { int N = 0; double x, y; while (~scanf("%lf,%lf", &x, &y)) { P[N++] = xy_t(x, y); } double sum = 0.0; for (int i = 0; i + 2 < N; ++i) { xy_t a = P[0], b = P[i + 1], c = P[i + 2]; sum += abs(((conj(b - a) * (c - a)).imag()) / 2.0); } printf("%.6f\n", abs(sum)); return 0; }
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
169
2
#include <cmath> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { double sum = 0; double x[21], y[21]; double hen[30]; double shen; int count = 0; double z; while (scanf("%lf,%lf", &x[count], &y[count]) != EOF) { if (count > 0) { hen[count - 1] = sqrt((x[0] - x[count]) * (x[0] - x[count]) + (y[0] - y[count]) * (y[0] - y[count])); } if (count > 1) { shen = sqrt((x[count] - x[count - 1]) * (x[count] - x[count - 1]) + (y[count] - y[count - 1]) * (y[count] - y[count - 1])); z = (hen[count - 1] + hen[count - 2] + shen) / 2; sum += sqrt(z * (z - shen) * (z - hen[count - 1]) * (z - hen[count - 2])); } count++; } printf("%l.8f\n", sum); return 0; }
#include <cmath> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { double sum = 0; double x[21], y[21]; double hen[30]; double shen; int count = 0; double z; while (scanf("%lf,%lf", &x[count], &y[count]) != EOF) { if (count > 0) { hen[count - 1] = sqrt((x[0] - x[count]) * (x[0] - x[count]) + (y[0] - y[count]) * (y[0] - y[count])); } if (count > 1) { shen = sqrt((x[count] - x[count - 1]) * (x[count] - x[count - 1]) + (y[count] - y[count - 1]) * (y[count] - y[count - 1])); z = (hen[count - 1] + hen[count - 2] + shen) / 2; // cout << sqrt(z*(z-shen)*(z-hen[count-1])*(z-hen[count-2])) << endl; sum += sqrt(z * (z - shen) * (z - hen[count - 1]) * (z - hen[count - 2])); } count++; } printf("%.8lf\n", sum); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
284
2
#include <cmath> #include <iostream> using namespace std; double Length(double x1, double y1, double x2, double y2) { return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); } double Triangle_Area(double a, double b, double c) { double z = (a + b + c) / 2.0; return sqrt(z * (z - a) * (z - b) * (z - c)); } int main() { double x[20], y[20], a, b, c, S = 0.0; int C = 0; while (cin >> x[C] >> y[C]) { C++; } for (int i = 1; i < (C - 1); i++) { a = Length(x[0], y[0], x[i], y[i]); b = Length(x[i], y[i], x[i + 1], y[i + 1]); c = Length(x[i + 1], y[i + 1], x[0], y[0]); S += Triangle_Area(a, b, c); } cout << S << endl; return 0; }
#include <cmath> #include <iostream> using namespace std; double Length(double x1, double y1, double x2, double y2) { return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); } double Triangle_Area(double a, double b, double c) { double z = (a + b + c) / 2.0; return sqrt(z * (z - a) * (z - b) * (z - c)); } int main() { double x[20], y[20], a, b, c, S = 0.0; int C = 0; char ch; while (cin >> x[C] >> ch >> y[C]) { C++; } for (int i = 1; i < (C - 1); i++) { a = Length(x[0], y[0], x[i], y[i]); b = Length(x[i], y[i], x[i + 1], y[i + 1]); c = Length(x[i + 1], y[i + 1], x[0], y[0]); S += Triangle_Area(a, b, c); } cout << S << endl; return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 152], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22]]
1
272
5
#include <bits/stdc++.h> #define rep(i, l, n) for (int i = l; i < n; i++) #define rer(i, l, n) for (int i = l; i <= n; i++) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define pb(a) push_back(a) #define mk(a, b) make_pair(a, b) #define fi first #define se second using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; int main() { int c = 0; double a, b, sum = 0.0; int x[21] = {}, y[21] = {}; while (scanf("%lf,%lf", &a, &b) != EOF) { if (c == 0) { x[c] = a; y[c] = b; } else { x[c] = a - x[0]; y[c] = b - y[0]; } c++; } rep(i, 1, c - 1) { sum += 0.5 * abs(x[i] * y[i + 1] - x[i + 1] * y[i]); } printf("%.10lf\n", sum); }
#include <bits/stdc++.h> #define rep(i, l, n) for (int i = l; i < n; i++) #define rer(i, l, n) for (int i = l; i <= n; i++) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define pb(a) push_back(a) #define mk(a, b) make_pair(a, b) #define fi first #define se second using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; int main() { int c = 0; double a, b, sum = 0.0; double x[21] = {}, y[21] = {}; while (scanf("%lf,%lf", &a, &b) != EOF) { // if(a==-1) break; if (c == 0) { x[c] = a; y[c] = b; } else { x[c] = a - x[0]; y[c] = b - y[0]; } c++; } rep(i, 1, c - 1) { sum += 0.5 * abs(x[i] * y[i + 1] - x[i + 1] * y[i]); } printf("%.10lf\n", sum); } /* double dist(double x1,double y1,double x2,double y2){ return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); } double solve(double x1,double y1,double x2,double y2,double x3,double y3){ double a,b,c,z,s; a=dist(x1,y1,x2,y2); b=dist(x2,y2,x3,y3); c=dist(x3,y3,x1,y3); z=(a+b+c)*0.5; s=sqrt(z*(z-a)*(z-b)*(z-c)); return s; } int main(){ char c; double x1,y1,x2,y2,x3,y3,sum=0; cin>>x1>>c>>y1>>x2>>c>>y2; //scanf("%lf,%lf%c%lf,%lf",&x1,&y1,&c,&x2,&y2); while(scanf("%lf,%lf",&x3,&y3)!=EOF){ sum+=solve(x1,y1,x2,y2,x3,y3); x2=x3; y2=y3; o(" "<<sum); } printf("%.10lf",sum); }*/ /* typedef complex<double> xy_t; //??????????¬?????????¢???????????? double cross_product(xy_t a,xy_t b){ return (conj(a)*b).imag(); } xy_t P[110]; int main(){ int n=0; double x,y; while(~scanf("%lf,%lf",&x,&y)){ P[n++]=xy_t(x,y); } double sum=0.0; rep(i,0,n-2){ xy_t a=P[0],b=P[i+1],c=P[i+2]; sum+=0.5*cross_product(b-a,c-a); } printf("%.6lf\n",abs(sum)); }*/
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
248
2
#include <cmath> #include <complex> #include <cstdio> #include <vector> using namespace std; typedef complex<double> xy_t; double cross_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } int main() { double x, y; double s = 0; vector<xy_t> vertex; while (scanf("%lf,%lf", &x, &y) != EOF) { vertex.push_back(xy_t(x, y)); } for (int i = 1; i < vertex.size() - 1; i++) { s += cross_product(vertex[i] - vertex[0], vertex[i + 1] - vertex[0]) / 2; } printf("%.6f", abs(s)); }
#include <cmath> #include <complex> #include <cstdio> #include <vector> using namespace std; typedef complex<double> xy_t; double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } int main() { double x, y; double s = 0; vector<xy_t> vertex; while (scanf("%lf,%lf", &x, &y) != EOF) { vertex.push_back(xy_t(x, y)); } for (int i = 1; i < vertex.size() - 1; i++) { s += cross_product(vertex[i] - vertex[0], vertex[i + 1] - vertex[0]) / 2; } printf("%.6f", abs(s)); }
[["-", 8, 9, 0, 37, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 37, 0, 2, 63, 118, 119, 120]]
1
160
2
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <utility> #include <vector> using namespace std; typedef long long ll; int main() { double v[128][2]; double x, y; int n = 0; while (scanf("%lf,%lf", &x, &y) != EOF) { v[n][0] = x; v[n][1] = y; ++n; } double s = 0; for (int i = 1; i < n - 1; ++i) { double ts = fabs((v[i][0] - v[0][0]) * (v[i + 1][1] - v[0][1]) + (v[i + 1][0] - v[0][0]) * (v[i][1] - v[0][1])) / 2; s += ts; } printf("%.7f\n", s); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <utility> #include <vector> using namespace std; typedef long long ll; int main() { double v[128][2]; double x, y; int n = 0; while (scanf("%lf,%lf", &x, &y) != EOF) { v[n][0] = x; v[n][1] = y; ++n; } double s = 0; for (int i = 1; i < n - 1; ++i) { double ts = fabs((v[i][0] - v[0][0]) * (v[i + 1][1] - v[0][1]) - (v[i + 1][0] - v[0][0]) * (v[i][1] - v[0][1])) / 2; s += ts; } printf("%.7f\n", s); return 0; }
[["-", 51, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 17, 33]]
1
218
2
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; typedef complex<double> xy_t; char c; double x, y; xy_t P[20]; const int MAX = 10000000; double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } int main(void) { int k = 0; while (cin >> x >> c >> y) { P[k] = xy_t(x, y); k++; } double ans = 0; for (int i = 1; i < k; i++) { ans += abs(0.5 * cross_product(xy_t(P[i] - P[0]), xy_t(P[i + 1] - P[0]))); } printf("%.6f\n", ans); return 0; }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; typedef complex<double> xy_t; char c; double x, y; xy_t P[20]; const int MAX = 10000000; double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } int main(void) { int k = 0; while (cin >> x >> c >> y) { P[k] = xy_t(x, y); k++; } double ans = 0; for (int i = 1; i < k - 1; i++) { ans += abs(0.5 * cross_product(xy_t(P[i] - P[0]), xy_t(P[i + 1] - P[0]))); } printf("%.6f\n", ans); return 0; }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
191
2
#include <cmath> #include <complex> #include <iostream> #include <stdio.h> using namespace std; typedef complex<double> xy_t; double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } int main() { xy_t o, a, b; double sum = 0, x, y; scanf("%lf,%lf", &x, &y); o = xy_t(x, y); scanf("%lf,%lf", &x, &y); a = xy_t(x, y); b = a; while (~scanf("%lf,%lf", &x, &y)) { a = xy_t(x, y); sum += cross_product(a, b) / 2.0; b = a; } printf("%.6f\n", abs(sum)); return 0; }
#include <cmath> #include <complex> #include <iostream> #include <stdio.h> using namespace std; typedef complex<double> xy_t; double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } int main() { xy_t o, a, b; double sum = 0, x, y; scanf("%lf,%lf", &x, &y); o = xy_t(x, y); scanf("%lf,%lf", &x, &y); a = xy_t(x, y) - o; b = a; while (~scanf("%lf,%lf", &x, &y)) { a = xy_t(x, y) - o; sum += cross_product(a, b) / 2.0; b = a; } printf("%.6f\n", abs(sum)); return 0; }
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
197
4
#include <cmath> #include <complex> #include <cstdio> #include <iostream> using namespace std; typedef complex<double> xy_t; int main() { xy_t P[110]; int N = 0; double x, y; while (scanf("%lf,%lf", &x, &y)) { P[N++] = xy_t(x, y); } double sum = 0.0; for (int i = 0; i + 2 < N; ++i) { xy_t a = P[0], b = P[i + 1], c = P[i + 2]; sum += (conj(b - a) * (c - a)).imag(); } sum /= 2; printf("%.6f\n", abs(sum)); }
#include <cmath> #include <complex> #include <cstdio> #include <iostream> using namespace std; typedef complex<double> xy_t; int main() { xy_t P[110]; int N = 0; double x, y; while (~scanf("%lf,%lf", &x, &y)) { P[N++] = xy_t(x, y); } double sum = 0.0; for (int i = 0; i + 2 < N; ++i) { xy_t a = P[0], b = P[i + 1], c = P[i + 2]; sum += (conj(b - a) * (c - a)).imag(); } sum /= 2; printf("%.6f\n", abs(sum)); }
[["+", 8, 9, 0, 52, 15, 339, 51, 91, 17, 92]]
1
158
1
#include <algorithm> #include <cctype> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespace std; int size(string x) { string::size_type size = x.size(); return size; } #define fu(l, k) for (int i = l; i < k; i++) #define fd(l, k) for (int i = l; i > k; i--) #define sort(ss) sort(ss.begin(), ss.end()) #define rsort(ss) sort(ss.rbegin(), ss.rend()) typedef vector<string> vs; typedef vector<int> vi; double pi() { return acos(-1.0); } typedef set<int> set_i; typedef set<string> set_s; int INF = 1000000; double x[30] = {}, y[30] = {}, ans, ss; double abs(double i, double e) { if (e - i >= 0) return e - i; return i - e; } double leng(double xx, double yy) { sqrt(pow(xx, 2.0) + pow(yy, 2.0)); } int main() { int i = 0; char sr; while (cin >> x[i] >> sr >> y[i]) { i++; } // cout<<i<<endl; double a, b, c, ans = 0, g, f, d; for (int e = 1; e <= i - 2; e++) { a = leng(abs(x[0], x[e]), abs(y[0], y[e])); b = leng(abs(x[0], x[e + 1]), abs(y[0], y[e + 1])); c = leng(abs(x[e], x[e + 1]), abs(y[e], y[e + 1])); // cout<<a<<" "<<b<<" "<<c<<endl; double z = (a + b + c) / 2.0; // cout<<sqrt(z*(z-a)*(z-b)*(z-c))<<endl; ans += sqrt(z * (z - a) * (z - b) * (z - c)); } printf("%lf\n", ans); }
#include <algorithm> #include <cctype> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespace std; int size(string x) { string::size_type size = x.size(); return size; } #define fu(l, k) for (int i = l; i < k; i++) #define fd(l, k) for (int i = l; i > k; i--) #define sort(ss) sort(ss.begin(), ss.end()) #define rsort(ss) sort(ss.rbegin(), ss.rend()) typedef vector<string> vs; typedef vector<int> vi; double pi() { return acos(-1.0); } typedef set<int> set_i; typedef set<string> set_s; int INF = 1000000; double x[30] = {}, y[30] = {}, ans, ss; double abs(double i, double e) { if (e - i >= 0) return e - i; return i - e; } double leng(double xx, double yy) { return sqrt(pow(xx, 2.0) + pow(yy, 2.0)); } int main() { int i = 0; char sr; while (cin >> x[i] >> sr >> y[i]) { i++; } // cout<<i<<endl; double a, b, c, ans = 0, g, f, d; for (int e = 1; e <= i - 2; e++) { a = leng(abs(x[0], x[e]), abs(y[0], y[e])); b = leng(abs(x[0], x[e + 1]), abs(y[0], y[e + 1])); c = leng(abs(x[e], x[e + 1]), abs(y[e], y[e + 1])); // cout<<a<<" "<<b<<" "<<c<<endl; double z = (a + b + c) / 2.0; // cout<<sqrt(z*(z-a)*(z-b)*(z-c))<<endl; ans += sqrt(z * (z - a) * (z - b) * (z - c)); } printf("%lf\n", ans); }
[["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38]]
1
421
1
#include <cmath> #include <complex> #include <stdio.h> using namespace std; typedef complex<double> xy_t; xy_t p[110]; double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } int main() { int N = 0; double x, y; while (scanf("%lf,%lf", &x, &y) != EOF) { p[N++] = xy_t(x, y); } double sum = 0.0; for (int i = 0; i + 2 < N; i++) { xy_t a = p[0], b = p[i + 1], c = p[i + 2]; sum += cross_product(b - a, c - a) / 2.0; } printf("%.6f?\n", abs(sum)); }
#include <cmath> #include <complex> #include <stdio.h> using namespace std; typedef complex<double> xy_t; xy_t p[110]; double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } int main() { int N = 0; double x, y; while (scanf("%lf,%lf", &x, &y) != EOF) { p[N++] = xy_t(x, y); } double sum = 0.0; for (int i = 0; i + 2 < N; i++) { xy_t a = p[0], b = p[i + 1], c = p[i + 2]; sum += cross_product(b - a, c - a) / 2.0; } printf("%.6f\n", abs(sum)); }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
173
2
// 32 #include <cmath> #include <complex> #include <cstdio> using namespace std; int main() { double x, y, px, py; scanf("%lf,%lf,%lf,%lf", &x, &y, &px, &py); double s = 0; complex<double> p(x, y), pp(px, py); for (double cx, cy; scanf("%lf,%lf", &cx, &cy) != EOF;) { complex<double> cp(cx, cy); double a = abs(pp - p), b = abs(cp - p), c = abs(cp - pp); double z = (a + b + c) / 2; s += sqrt(z * (z - a) * (z - b) * (z - c)); pp = cp; } printf("%.6f\n", s); return 0; }
// 32 #include <cmath> #include <complex> #include <cstdio> using namespace std; int main() { double x, y, px, py; scanf("%lf,%lf%lf,%lf", &x, &y, &px, &py); double s = 0; complex<double> p(x, y), pp(px, py); for (double cx, cy; scanf("%lf,%lf", &cx, &cy) != EOF;) { complex<double> cp(cx, cy); double a = abs(pp - p), b = abs(cp - p), c = abs(cp - pp); double z = (a + b + c) / 2; s += sqrt(z * (z - a) * (z - b) * (z - c)); pp = cp; } printf("%.6f\n", s); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
187
2
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; struct rec { double x, y; }; int main() { int n; struct rec dot[21] = {0}; double ans = 0, a, b, c, z; for (int i = 0; i < 20; i++) { if (scanf("%lf,%lf", &dot[i].x, &dot[i].y) == EOF) { n = i; break; } } for (int i = 0; i < n; i++) { a = sqrt(pow(dot[0].x - dot[i + 1].x, 2) + pow(dot[0].y - dot[i + 1].y, 2)); b = sqrt(pow(dot[i + 1].x - dot[i + 2].x, 2) + pow(dot[i + 1].y - dot[i + 2].y, 2)); c = sqrt(pow(dot[i + 2].x - dot[0].x, 2) + pow(dot[i + 2].y - dot[0].y, 2)); z = (a + b + c) / 2; ans = ans + sqrt(z * (z - a) * (z - b) * (z - c)); } printf("%0.6lf\n", ans); return 0; }
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; struct rec { double x, y; }; int main() { int n; struct rec dot[21] = {0}; double ans = 0, a, b, c, z; for (int i = 0; i < 20; i++) { if (scanf("%lf,%lf", &dot[i].x, &dot[i].y) == EOF) { n = i; break; } } for (int i = 0; i < n - 2; i++) { a = sqrt(pow(dot[0].x - dot[i + 1].x, 2) + pow(dot[0].y - dot[i + 1].y, 2)); b = sqrt(pow(dot[i + 1].x - dot[i + 2].x, 2) + pow(dot[i + 1].y - dot[i + 2].y, 2)); c = sqrt(pow(dot[i + 2].x - dot[0].x, 2) + pow(dot[i + 2].y - dot[0].y, 2)); z = (a + b + c) / 2; ans = ans + sqrt(z * (z - a) * (z - b) * (z - c)); } printf("%.6lf\n", ans); return 0; }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
317
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> using namespace std; double check(double x1, double y1, double x2, double y2, double x3, double y3); int main(void) { double ans = 0; double xa, ya, xb, yb, xc, yc; scanf("%lf,%lf", &xa, &xb); scanf("%lf,%lf", &xb, &yb); scanf("%lf,%lf", &xc, &yc); ans += check(xa, ya, xb, yb, xc, yc); xb = xc, yb = yc; while (scanf("%lf,%lf", &xc, &yc) != EOF) { ans += check(xa, ya, xb, yb, xc, yc); xb = xc, yb = yc; } printf("%.8lf\n", ans); return 0; } double check(double x1, double y1, double x2, double y2, double x3, double y3) { double ab, bc, ca; double S, s; ab = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); bc = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)); ca = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)); s = 0.5 * (ab + bc + ca); S = sqrt(s * (s - ab) * (s - bc) * (s - ca)); return S; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> using namespace std; double check(double x1, double y1, double x2, double y2, double x3, double y3); int main(void) { double ans = 0; double xa, ya, xb, yb, xc, yc; scanf("%lf,%lf", &xa, &ya); scanf("%lf,%lf", &xb, &yb); scanf("%lf,%lf", &xc, &yc); ans += check(xa, ya, xb, yb, xc, yc); xb = xc, yb = yc; while (scanf("%lf,%lf", &xc, &yc) != EOF) { ans += check(xa, ya, xb, yb, xc, yc); xb = xc, yb = yc; } printf("%.8lf\n", ans); return 0; } double check(double x1, double y1, double x2, double y2, double x3, double y3) { double ab, bc, ca; double S, s; ab = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); bc = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)); ca = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)); s = 0.5 * (ab + bc + ca); S = sqrt(s * (s - ab) * (s - bc) * (s - ca)); return S; }
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22]]
1
344
2
// start: 23:15 #include <cmath> #include <cstdio> #include <iostream> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) using namespace std; typedef pair<int, int> xy; double triangle(double x1, double y1, double x2, double y2, double x3, double y3) { // 正規化(ベクトルに変換) // 掛け算 // 1/2 double v1x = x3 - x1, v1y = y3 - y1, v2x = x2 - x1, v2y = y2 - y1; return 0.500000 * abs(v1x * v2y - v1y * v2x); } double polygon(int edge, vector<xy> points) { double sum = 0.0; xy base = points[0]; for (int i = 1; i < edge - 1; i++) { xy p1 = points[i], p2 = points[i + 1]; sum += triangle(base.first, base.second, p1.first, p1.second, p2.first, p2.second); } return sum; } int main() { vector<xy> ps(21); int i = 0; double x, y; while (scanf("%lf,%lf", &x, &y) != EOF) ps[i++] = make_pair(x, y); printf("%.6f\n", polygon(i, ps)); return 0; }
// start: 23:15 #include <cmath> #include <cstdio> #include <iostream> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) using namespace std; typedef pair<double, double> xy; // 三角形の面積を求める double triangle(double x1, double y1, double x2, double y2, double x3, double y3) { // 正規化(ベクトルに変換) // 掛け算 // 1/2 double v1x = x3 - x1, v1y = y3 - y1, v2x = x2 - x1, v2y = y2 - y1; return 0.5 * abs(v1x * v2y - v1y * v2x); } // 多角形の面積を求める double polygon(int edge, vector<xy> points) { double sum = 0.0; xy base = points[0]; for (int i = 1; i < edge - 1; i++) { xy p1 = points[i], p2 = points[i + 1]; sum += triangle(base.first, base.second, p1.first, p1.second, p2.first, p2.second); } return sum; } int main() { vector<xy> ps(21); int i = 0; double x, y; // EOFまで入力 while (scanf("%lf,%lf", &x, &y) != EOF) ps[i++] = make_pair(x, y); // 小数点6桁まで出力 printf("%.6f\n", polygon(i, ps)); return 0; }
[["-", 0, 134, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 134, 39, 344, 3, 347, 0, 77, 39, 40], ["-", 0, 14, 8, 9, 0, 37, 0, 16, 31, 13], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 31, 13]]
1
262
6
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { vector<int> x, y; double a, b, c, s; while (~scanf("%lf,%lf", &a, &b)) { x.push_back(a); y.push_back(b); } for (int i = 1; i <= x.size(); i++) { x[i % x.size()] -= x[0]; y[i % x.size()] -= y[0]; } double res = 0; for (int i = 1; i < x.size() - 1; i++) { res += abs(x[i] * y[i + 1] - y[i] * x[i + 1]); } printf("%.9lf\n", res / 2); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { vector<double> x, y; double a, b, c, s; while (~scanf("%lf,%lf", &a, &b)) { x.push_back(a); y.push_back(b); } for (int i = 1; i <= x.size(); i++) { x[i % x.size()] -= x[0]; y[i % x.size()] -= y[0]; } double res = 0; for (int i = 1; i < x.size() - 1; i++) { res += fabs(x[i] * y[i + 1] - y[i] * x[i + 1]); } printf("%.9lf\n", res / 2); return 0; }
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22]]
1
192
4
#include <cstdio> #include <cstdlib> #include <iostream> int main() { double x0, y0, x1, y1, x, y, s = 0; char c; std::cin >> x0 >> c >> y0; x1 = x0; y1 = y0; while (std::cin >> x >> c >> y) { s += x1 * y - y1 * x; x1 = x; y1 = y; } s += x1 * y0 - y1 * x0; printf("%.6f\n", abs(s / 2)); }
#include <cmath> #include <cstdio> #include <iostream> int main() { double x0, y0, x1, y1, x, y, s = 0; char c; std::cin >> x0 >> c >> y0; x1 = x0; y1 = y0; while (std::cin >> x >> c >> y) { s += x1 * y - y1 * x; x1 = x; y1 = y; } s += x1 * y0 - y1 * x0; printf("%.6f\n", fabs(s / 2)); }
[["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22]]
1
107
6
#include <cstdlib> #include <iostream> int main() { double x0, y0, x1, y1, x, y, s = 0; char c; std::cin >> x0 >> c >> y0; x1 = x0; y1 = y0; while (std::cin >> x >> c >> y) { s += x1 * y - y1 * x; x1 = x; y1 = y; } s += x1 * y0 - y1 * x0; std::cout << abs(s / 2) << "\n"; }
#include <cmath> #include <iostream> int main() { double x0, y0, x1, y1, x, y, s = 0; char c; std::cin >> x0 >> c >> y0; x1 = x0; y1 = y0; while (std::cin >> x >> c >> y) { s += x1 * y - y1 * x; x1 = x; y1 = y; } s += x1 * y0 - y1 * x0; std::cout << fabs(s / 2) << "\n"; }
[["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22]]
1
105
12
def area(p) x, y = p[0] s = 0.0 oldV = [p[1][0]-x, p[1][1]-y] p[2..-1].each do |x1, y1| va = [x1-x, y1-y] s += triangleArea(va, oldV) oldV = va end s end def triangleArea(a, b) (a[0] * b[1] - a[1] * b[0])/2.0 end if __FILE__ == $0 points = [] loop do input = gets break if input.nil? points << input.split(',').map(&:to_f) end p area(points) end
def area(p) x, y = p[0] s = 0.0 oldV = [p[1][0]-x, p[1][1]-y] p[2..-1].each do |x1, y1| va = [x1-x, y1-y] s += triangleArea(va, oldV) oldV = va end s end def triangleArea(a, b) ((a[0] * b[1] - a[1] * b[0])/2.0).abs end if __FILE__ == $0 points = [] loop do input = gets break if input.nil? points << input.split(',').map(&:to_f) end p area(points) end
[["+", 0, 652, 486, 739, 0, 738, 31, 739, 0, 24], ["+", 0, 735, 8, 736, 0, 652, 486, 739, 0, 25], ["+", 0, 493, 0, 735, 8, 736, 0, 652, 17, 131], ["+", 0, 493, 0, 735, 8, 736, 0, 652, 735, 22]]
4
151
4