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> #define MAX 100000 int parent(int); int left(int); int right(int); int main() { int i, n; int arr[MAX + 1]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &arr[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d,", i, arr[i]); if (parent(i) >= 1) ...
#include <stdio.h> #define MAX 100000 int parent(int); int left(int); int right(int); int main() { int i, n; int arr[MAX + 1]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &arr[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, arr[i]); if (parent(i) >= 1) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 8, 9, 0, 37, 0, 16, 31, 23, 0, 24], ["-", 8, 9, 0, 37, 0, 16, 31, 23, 0, 25]]
0
234
6
#include <stdio.h> typedef struct node { int id; int key; } NODE; int main() { NODE heap[250]; int i, n; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &heap[i].key); heap[i].id = i; } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", heap[i].id, heap[i].key); if (i...
#include <stdio.h> typedef struct node { int id; int key; } NODE; int main() { NODE heap[250]; int i, n; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &heap[i].key); heap[i].id = i; } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", heap[i].id, heap[i].key); if (i...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
201
6
#include <stdio.h> #define MAX 100000 int parent(int); int left(int); int right(int); int main() { int i, H, A[MAX]; scanf("%d", &H); for (i = 1; i <= H; i++) { scanf("%d", &A[i]); } for (i = 1; i <= H; i++) { printf("node %d: key = %d, ", i, A[i]); if (parent(i) >= 0) printf("parent...
#include <stdio.h> #define MAX 100000 int parent(int); int left(int); int right(int); int main() { int i, H, A[MAX]; scanf("%d", &H); for (i = 1; i <= H; i++) { scanf("%d", &A[i]); } for (i = 1; i <= H; i++) { printf("node %d: key = %d, ", i, A[i]); if (parent(i) > 0) printf("parent ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
229
4
#include <stdio.h> int main() { int n, i, size[1000]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &size[i]); } for (i = 1; i < n; i++) { printf("node %d: key = %d, ", i, size[i]); if (i != 1) { printf("parent key = %d, ", size[i / 2]); } if (2 * i < n) { print...
#include <stdio.h> int main() { int n, i, size[1000]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &size[i]); } n++; for (i = 1; i < n; i++) { printf("node %d: key = %d, ", i, size[i]); if (i != 1) { printf("parent key = %d, ", size[i / 2]); } if (2 * i < n) { ...
[["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
0
169
3
#include <stdio.h> #define MAX 251 int main() { int n, i; int array[MAX]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &array[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, array[i]); if (array[i / 2] >= 1) printf("parent key = %d, ", array[i / 2]); i...
#include <stdio.h> #define MAX 251 int main() { int n, i; int array[MAX]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &array[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, array[i]); if (i / 2 >= 1) printf("parent key = %d, ", array[i / 2]); if (2 * ...
[["-", 0, 57, 15, 23, 0, 16, 31, 69, 28, 22], ["-", 0, 57, 15, 23, 0, 16, 31, 69, 0, 70], ["-", 0, 57, 15, 23, 0, 16, 31, 69, 0, 73]]
0
172
3
#include <stdio.h> int main() { int n, i, node[250]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &node[i]); } for (i = 1; i < n; i++) { printf("node %d: key = %d, ", i, node[i]); if (i / 2 > 0) { printf("parent key = %d, ", node[i / 2]); } if (2 * i <= n) { prin...
#include <stdio.h> int main() { int n, i, node[250]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &node[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, node[i]); if (i / 2 > 0) { printf("parent key = %d, ", node[i / 2]); } if (2 * i <= n) { pri...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
0
171
2
#include <stdio.h> #define N 250 typedef struct { int key; } node; int main() { int n, i; node H[N]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &H[i].key); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, H[i].key); if (i != 1) printf("parent kay = %d, ", H[i /...
#include <stdio.h> #define N 250 typedef struct { int key; } node; int main() { int n, i; node H[N]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &H[i].key); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, H[i].key); if (i != 1) printf("parent key = %d, ", H[i /...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
190
2
#include <stdio.h> #define H 250 int parent(int); int left(int); int right(int); int main() { int i, n, heaps[H + 1]; int lk, rk; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &heaps[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d,", i, heaps[i]); if (i > 1) { pr...
#include <stdio.h> #define H 250 int parent(int); int left(int); int right(int); int main() { int i, n, heaps[H + 1]; int lk, rk; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &heaps[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, heaps[i]); if (i > 1) { p...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
241
2
#include <stdio.h> int parent(int); int left(int); int right(int); int main() { int H, i; int A[250]; scanf("%d", &H); for (i = 1; i <= H; i++) { scanf("%d", &A[i]); } for (i = 1; i <= H; i++) { printf("node %d:", i); printf("key = %d, ", A[i]); if (parent(i) > 0 && parent(i) <= H) ...
#include <stdio.h> int parent(int); int left(int); int right(int); int main() { int H, i; int A[250]; scanf("%d", &H); for (i = 1; i <= H; i++) { scanf("%d", &A[i]); } for (i = 1; i <= H; i++) { printf("node %d: ", i); printf("key = %d, ", A[i]); if (parent(i) > 0 && parent(i) <= H) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
255
2
#include <stdio.h> #define MAX 100000 int main() { int H, i, A[MAX + 1]; scanf("%d", &H); for (i = 1; i <= H; i++) scanf("%d", &A[i]); for (i = 1; i <= H; i++) { printf("node %d: key = %d, ", i, A[i]); if (i / 2 >= 1) printf("parent key = %d,", A[i / 2]); if (2 * i <= H) printf("le...
#include <stdio.h> #define MAX 100000 int main() { int H, i, A[MAX + 1]; scanf("%d", &H); for (i = 1; i <= H; i++) scanf("%d", &A[i]); for (i = 1; i <= H; i++) { printf("node %d: key = %d, ", i, A[i]); if (i / 2 >= 1) printf("parent key = %d, ", A[i / 2]); if (2 * i <= H) printf("l...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
168
6
#include <stdio.h> #include <stdlib.h> int main() { int *a; int n, i; scanf("%d", &n); a = (int *)malloc(sizeof(int) * n + 1); for (i = 1; i <= n; i++) scanf("%d", &a[i]); for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i + 1, a[i]); if (i / 2 > 0) printf("parent key = %d, ", a[...
#include <stdio.h> #include <stdlib.h> int main() { int *a; int n, i; scanf("%d", &n); a = (int *)malloc(sizeof(int) * n + 1); for (i = 1; i <= n; i++) scanf("%d", &a[i]); for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, a[i]); if (i / 2 > 0) printf("parent key = %d, ", a[i / ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
184
4
#include <stdio.h> #include <stdlib.h> #define NIL -1 int main() { int n, i; scanf("%d", &n); int m[500]; for (i = 1; i <= n; i++) scanf("%d", &m[i]); for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, m[i]); if (i / 2 <= n && i / 2 > 0) printf("parent key = %d, ", m[i / 2]...
#include <stdio.h> #include <stdlib.h> #define NIL -1 int main() { int n, i; scanf("%d", &n); int m[500]; for (i = 1; i <= n; i++) scanf("%d", &m[i]); for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, m[i]); if (i / 2 <= n && i / 2 > 0) printf("parent key = %d, ", m[i / 2]...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
175
2
#include <stdio.h> int parent(int); int left(int); int right(int); int main() { int i, H, A[251]; scanf("%d", &H); for (i = 1; i <= H; i++) scanf("%d", &A[i]); for (i = 1; i <= H; i++) { printf("node %d: key = %d, ", i, A[i]); if (parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]); ...
#include <stdio.h> int parent(int); int left(int); int right(int); int main() { int i, H, A[251]; scanf("%d", &H); for (i = 1; i <= H; i++) scanf("%d", &A[i]); for (i = 1; i <= H; i++) { printf("node %d: key = %d, ", i, A[i]); if (parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]); ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
224
2
#include <stdio.h> #define N 250 int main() { int A[N]; int count, i; scanf("%d", &count); for (i = 0; i < count; i++) scanf("%d", &A[i]); for (i = 0; i < count; i++) { printf("node %d: key = %d, ", i + 1, A[i]); if (i != 0 && i % 2 == 1) printf("parent key = %d,", A[(i - 1) / 2]); if (...
#include <stdio.h> #define N 250 int main() { int A[N]; int count, i; scanf("%d", &count); for (i = 0; i < count; i++) scanf("%d", &A[i]); for (i = 0; i < count; i++) { printf("node %d: key = %d, ", i + 1, A[i]); if (i != 0 && i % 2 == 1) printf("parent key = %d, ", A[(i - 1) / 2]); if ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
211
6
#include <stdio.h> #include <stdlib.h> int main() { int i; int n; int *a; scanf("%d", &n); a = (int *)malloc(sizeof(int) * n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } for (i = 0; i < n; i++) { printf("node %d: key = %d, ", i + 1, a[i]); if (i != 0) { if ((i + 1) % 2 == 0) ...
#include <stdio.h> #include <stdlib.h> int main() { int i; int n; int *a; scanf("%d", &n); a = (int *)malloc(sizeof(int) * n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } for (i = 0; i < n; i++) { printf("node %d: key = %d, ", i + 1, a[i]); if (i != 0) { if ((i + 1) % 2 == 0) ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
241
2
#include <stdio.h> int main() { int n, H[251], p, l, r, i; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &H[i]); } for (i = 1; i <= n; i++) { p = i / 2; l = 2 * i; r = 2 * i + 1; printf("node %d: key = %d,", i, H[i]); if (i != 1) printf("parent key = %d,", H[p]); i...
#include <stdio.h> int main() { int n, H[251], p, l, r, i; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &H[i]); } for (i = 1; i <= n; i++) { p = i / 2; l = 2 * i; r = 2 * i + 1; printf("node %d: key = %d, ", i, H[i]); if (i != 1) printf("parent key = %d, ", H[p]); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
181
8
#include <stdio.h> int parent(int); int left(int); int right(int); int main() { int i, n, A[251], p, r, l; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &A[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d ", i, A[i]); if (i > 1) { p = parent(i); printf("parent...
#include <stdio.h> int parent(int); int left(int); int right(int); int main() { int i, n, A[251], p, r, l; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &A[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, A[i]); if (i > 1) { p = parent(i); printf("paren...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
251
8
#include <stdio.h> #include <stdlib.h> int parent(int i) { return i / 2; } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } int main() { int H[251]; int i, j, k, Hsiz; scanf("%d", &Hsiz); for (i = 1; i <= Hsiz; i++) { scanf("%d", &H[i]); } for (i = 1; i <= Hsiz; i++) { pr...
#include <stdio.h> #include <stdlib.h> int parent(int i) { return i / 2; } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } int main() { int H[251]; int i, j, k, Hsiz; scanf("%d", &Hsiz); for (i = 1; i <= Hsiz; i++) { scanf("%d", &H[i]); } for (i = 1; i <= Hsiz; i++) { pr...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
242
2
#include <stdio.h> #include <stdlib.h> int main(void) { int i, n, *A; scanf("%d", &n); A = malloc((n + 1) * sizeof(int)); for (i = 1; i <= n; i++) { scanf("%d", &A[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, A[i]); if (i / 2 > 0) printf("parent = %d, ", A[i / 2]); ...
#include <stdio.h> #include <stdlib.h> int main(void) { int i, n, *A; scanf("%d", &n); A = malloc((n + 1) * sizeof(int)); for (i = 1; i <= n; i++) { scanf("%d", &A[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, A[i]); if (i / 2 > 0) printf("parent key = %d, ", A[i / 2]...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
182
2
#include <stdio.h> void parent(int); void left(int); void right(int); int n; int a[251]; int main() { scanf("%d", &n); int i; for (i = 1; i <= n; i++) scanf("%d", &a[i]); for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, a[i]); parent(i); left(i); right(i); printf("\n"); }...
#include <stdio.h> void parent(int); void left(int); void right(int); int n; int a[251]; int main() { scanf("%d", &n); int i; for (i = 1; i <= n; i++) scanf("%d", &a[i]); for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, a[i]); parent(i); left(i); right(i); printf("\n"); ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
225
2
#include <stdio.h> #define MAX 100000 int parent(int i) { return i / 2; } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } int main() { int H, i, A[MAX + 1]; scanf("%d\n", &H); for (i = 1; i <= H; i++) { scanf("%d\n", &A[i]); } for (i = 1; i <= H; i++) { printf("node%d: key...
#include <stdio.h> #define MAX 100000 int parent(int i) { return i / 2; } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } int main() { int H, i, A[MAX + 1]; scanf("%d\n", &H); for (i = 1; i <= H; i++) { scanf("%d\n", &A[i]); } for (i = 1; i <= H; i++) { printf("node %d: ke...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
215
2
#include <stdio.h> int main() { int H, i; int A[250 + 1]; scanf("%d", &H); for (i = 1; i <= H; i++) scanf("%d", &A[i]); for (i = 1; i <= H; i++) { printf("mode %d: key = %d, ", i, A[i]); if (i / 2 > 0) printf("parent key = %d, ", A[i / 2]); if (2 * i <= H) printf("left key = %d,...
#include <stdio.h> int main() { int H, i; int A[250 + 1]; scanf("%d", &H); for (i = 1; i <= H; i++) scanf("%d", &A[i]); for (i = 1; i <= H; i++) { printf("node %d: key = %d, ", i, A[i]); if (i / 2 > 0) printf("parent key = %d, ", A[i / 2]); if (2 * i <= H) printf("left key = %d,...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
168
2
#include <stdio.h> #define H 250 int parent(int i) { return i / 2; } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } int main() { int i, n; int A[H]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &A[i]); } for (i = 1; i <= n; i++) { printf("node %d; key = %d, ",...
#include <stdio.h> #define H 250 int parent(int i) { return i / 2; } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } int main() { int i, n; int A[H + 1]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &A[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d...
[["+", 8, 9, 0, 43, 49, 80, 81, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
211
4
#include <stdio.h> #define H_size 250 int main() { int size, i; int H[H_size + 1]; scanf("%d", &size); for (i = 1; i <= size; i++) scanf("%d", &H[i]); for (i = 1; i <= size; i++) { printf("node %d: key %d ", i, H[i]); if (i != 1) printf("parent key = %d, ", H[i / 2]); if (2 * i <= siz...
#include <stdio.h> #define H_size 250 int main() { int size, i; int H[H_size + 1]; scanf("%d", &size); for (i = 1; i <= size; i++) scanf("%d", &H[i]); for (i = 1; i <= size; i++) { printf("node %d: key = %d, ", i, H[i]); if (i != 1) printf("parent key = %d, ", H[i / 2]); if (2 * i <= ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
166
4
#include <stdio.h> void Heap(int, int); int H, A[100000]; int main() { int i; scanf("%d", &H); for (i = 1; i <= H; i++) { scanf("%d", &A[i]); } Heap(1, H); return 0; } void Heap(int j, int M) { A[0] = 0; for (j = 1; j <= M; j++) { printf("node %d:key = %d,", j, A[j]); if (j / 2 >= 1) ...
#include <stdio.h> void Heap(int, int); int H, A[251]; int main() { int i; scanf("%d", &H); for (i = 1; i <= H; i++) { scanf("%d", &A[i]); } Heap(1, H); return 0; } void Heap(int j, int M) { A[0] = 0; for (j = 1; j <= M; j++) { printf("node %d: key = %d, ", j, A[j]); if (j / 2 >= 1) ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
200
10
#include <stdio.h> #define N 250 int parent(int); int left(int); int right(int); void maxHeapify(int *, int); int x[N]; int n; int main() { int i; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &x[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i + 1, x[i]); if (i != ...
#include <stdio.h> #define N 250 int parent(int); int left(int); int right(int); void maxHeapify(int *, int); int x[N]; int n; int main() { int i; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &x[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, x[i]); if (i != 1) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
0
239
2
#include <stdio.h> int main() { int n, i, a; int S[100001]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &S[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, S[i]); if (i / 2 >= 1) { printf("parent key = %d, ", S[i / 2]); } if (2 * i <= n) { p...
#include <stdio.h> int main() { int n, i, a; int S[100001]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &S[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, S[i]); if (i / 2 >= 1) { printf("parent key = %d, ", S[i / 2]); } if (2 * i <= n) { p...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
174
2
#include <stdio.h> int parent(int); int left(int); int right(int); int parent(int i) { return (i / 2); } int left(int i) { return 2 * i; } int right(int i) { return (2 * i + 1); } int main() { int i, n, pk, lk, rk; int T[250]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &T[i]); } for (i ...
#include <stdio.h> int parent(int); int left(int); int right(int); int parent(int i) { return (i / 2); } int left(int i) { return 2 * i; } int right(int i) { return (2 * i + 1); } int main() { int i, n, pk, lk, rk; int T[250]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &T[i]); } for (i ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
240
6
#include <stdio.h> #define MAX 250 typedef struct { int parent; int right; int left; } Roll; int main() { int n, i; int Heap[MAX]; Roll Tree[MAX]; scanf("%d", &n); for (i = 1; i <= n; i++) scanf("%d", &Heap[i]); for (i = 1; i <= n; i++) { if (i != 1) Tree[i].parent = Heap[i / 2]; ...
#include <stdio.h> #define MAX 250 typedef struct { int parent; int right; int left; } Roll; int main() { int n, i; int Heap[MAX]; Roll Tree[MAX]; scanf("%d", &n); for (i = 1; i <= n; i++) scanf("%d", &Heap[i]); for (i = 1; i <= n; i++) { if (i != 1) Tree[i].parent = Heap[i / 2]; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
306
8
#include <stdio.h> #define MAX 100000 int parent(int); int left(int); int right(int); int main() { int H, i, A[MAX + 1]; scanf("%d", &H); for (i = 0; i < H; i++) scanf("%d", &A[i]); for (i = 0; i < H; i++) { printf("node %d: key = %d, ", i, A[i]); if (parent(i) >= 1) printf("parent key = %...
#include <stdio.h> #define MAX 100000 int parent(int); int left(int); int right(int); int main() { int H, i, A[MAX + 1]; scanf("%d", &H); for (i = 1; i <= H; i++) scanf("%d", &A[i]); for (i = 1; i <= H; i++) { printf("node %d: key = %d, ", i, A[i]); if (parent(i) >= 1) printf("parent key =...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
230
9
#include <stdio.h> int main() { int n, i; int a[1000]; scanf("%d", &n); for (i = 0; i <= n; i++) { scanf("%d", &a[i]); } for (i = 0; i <= n; i++) { printf("node %d: key = %d, ", i, a[i]); if (i / 2 != 0) { printf("parent key = %d, ", a[i / 2]); } if (2 * i <= n) { printf("le...
#include <stdio.h> int main() { int n, i; int a[1000]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } for (i = 1; i <= n; i++) { printf("node %d: key = %d, ", i, a[i]); if (i / 2 != 0) { printf("parent key = %d, ", a[i / 2]); } if (2 * i <= n) { printf("le...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]]
0
172
4
require 'matrix' p1x, p1y, p2x, p2y = gets.split.map &:to_i p1 = Vector[ p1x, p1y ] p1p2 = Vector[ p2x - p1x, p2y - p1y ] q = gets.to_i q.times do px, py = gets.split.map &:to_i p1p = Vector[ px - p1x, py - p1y ] p1t_norm = p1p.innter_product(p1p2) / p1p2.norm t = p1 + p1p2 * ( p1t_norm / p1p2.norm ) puts "%....
require 'matrix' p1x, p1y, p2x, p2y = gets.split.map &:to_i p1 = Vector[ p1x, p1y ] p1p2 = Vector[ p2x - p1x, p2y - p1y ] q = gets.to_i q.times do px, py = gets.split.map &:to_i p1p = Vector[ px - p1x, py - p1y ] p1t_norm = p1p.inner_product(p1p2) / p1p2.norm t = p1 + p1p2 * ( p1t_norm / p1p2.norm ) puts "%.8...
[["-", 8, 736, 0, 662, 12, 738, 31, 652, 735, 22], ["+", 8, 736, 0, 662, 12, 738, 31, 652, 735, 22]]
4
113
2
x1, y1, x2, y2 = gets.split.map(&:to_f) vx = x2 - x1 vy = y2 - y1 rv = Math.sqrt(vx*vx+vy*vy) #normarize vx /= rv vy /= rv q = gets.to_i q.times{ x, y = gets.split.map(&:to_f) rp1x = (x-x1)*vx+(y-y1)*vy puts "%.12f %.12f" % [rp1x*vx, rp1x*vy] }
x1, y1, x2, y2 = gets.split.map(&:to_f) vx = x2 - x1 vy = y2 - y1 rv = Math.sqrt(vx*vx+vy*vy) #normarize vx /= rv vy /= rv q = gets.to_i q.times{ x, y = gets.split.map(&:to_f) rp1x = (x-x1)*vx+(y-y1)*vy puts "%.12f %.12f" % [rp1x*vx + x1, rp1x*vy + y1] }
[["+", 3, 4, 0, 738, 12, 516, 0, 738, 17, 72], ["+", 3, 4, 0, 738, 12, 516, 0, 738, 12, 22]]
4
102
4
def dot(a, b): return a.real * b.real + a.imag * b.imag def projection(a, b): return a * dot(a, b) / (abs(a) ** 2) #複素平面の座標はクラスだから直接加算できる def solve(p0,p1,p2): a=p1-p0 b=p2-p0 pro=projection(a,b) t=p0+pro return t def main(): x0,y0,x1,y1=map(float,input().split()) p0=complex(x0,y0) p1=complex(x1,y...
def dot(a, b): return a.real * b.real + a.imag * b.imag def projection(a, b): return a * dot(a, b) / (abs(a) ** 2) #複素平面の座標はクラスだから直接加算できr def solve(p0,p1,p2): a=p1-p0 b=p2-p0 pro=projection(a,b) t=p0+pro return t def main(): x0,y0,x1,y1=map(float,input().split()) p0=complex(x0,y0) p1=complex(x1,y...
[["-", 3, 4, 0, 652, 63, 319, 500, 557, 0, 654], ["-", 3, 4, 0, 652, 63, 319, 500, 557, 0, 6], ["-", 3, 4, 0, 652, 63, 319, 500, 557, 0, 655], ["+", 3, 4, 0, 652, 63, 319, 500, 557, 0, 654], ["+", 3, 4, 0, 652, 63, 319, 500, 557, 0, 6], ["+", 3, 4, 0, 652, 63, 319, 500, 557, 0, 655]]
5
191
6
xp0,yp0,xp1,yp1 = list(map(float,input().split())) q = int(input()) for i in range(q): xp2,yp2 = list(map(float,input().split())) p0p2 = (xp2-xp0,yp2-xp0) p0p1 = (xp1-xp0,yp1-yp0) k = ((p0p2[0]*p0p1[0]+p0p2[1]*p0p1[1])/(p0p1[0]**2 + p0p1[1]**2)) p0T = (k*p0p1[0],k*p0p1[1]) OT = (xp0+p0T[0],yp0+p...
# coding: utf-8 xp0,yp0,xp1,yp1 = list(map(float,input().split())) q = int(input()) for i in range(q): xp2,yp2 = list(map(float,input().split())) p0p2 = (xp2-xp0,yp2-yp0) p0p1 = (xp1-xp0,yp1-yp0) k = ((p0p2[0]*p0p1[0]+p0p2[1]*p0p1[1])/(p0p1[0]**2 + p0p1[1]**2)) p0T = (k*p0p1[0],k*p0p1[1]) OT = (...
[["-", 0, 1, 0, 662, 12, 660, 0, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 660, 0, 657, 12, 22]]
5
173
2
def dot(a,b): return a[0]*b[0] + a[1]*b[1] x1,y1,x2,y2 = [int(i) for i in input().split()] q = int(input()) for i in range(q): x,y = [int(i) for i in input().split()] a = [x2-x1,y2-y1] b = [x-x1,y-y1] co = dot(a,b) / dot(a,a) print(a[0]*co,a[1]*co)
def dot(a,b): return a[0]*b[0] + a[1]*b[1] x1,y1,x2,y2 = [int(i) for i in input().split()] q = int(input()) for i in range(q): x,y = [int(i) for i in input().split()] a = [x2-x1,y2-y1] b = [x-x1,y-y1] co = dot(a,b) / dot(a,a) print(a[0]*co+x1,a[1]*co+y1)
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
141
4
import java.util.Scanner; public class Main { static double EPS = 0.0000000001; public static void main(String[] args) { Scanner sc = new Scanner(System.in); Segment seg = new Segment(new Point(sc.nextInt(), sc.nextInt()), new Point(sc.nextInt(), sc.nextInt())); int q = ...
import java.util.Scanner; public class Main { static double EPS = 0.0000000001; public static void main(String[] args) { Scanner sc = new Scanner(System.in); Segment seg = new Segment(new Point(sc.nextInt(), sc.nextInt()), new Point(sc.nextInt(), sc.nextInt())); int q = ...
[["+", 0, 492, 3, 4, 0, 492, 500, 492, 141, 22], ["+", 3, 4, 0, 492, 500, 492, 3, 4, 0, 24], ["+", 3, 4, 0, 492, 500, 492, 3, 4, 0, 22], ["+", 3, 4, 0, 492, 500, 492, 3, 4, 0, 25], ["+", 0, 37, 0, 492, 3, 4, 0, 492, 0, 131]]
3
722
5
#include <math.h> #include <stdio.h> typedef struct point { double x, y; } point; double segment(point p1, point p2); double inclination(point p1, point p2); point reflection(point p1, point p2, point p3); int main(void) { point p1, p2, p; int n, i; scanf("%lf%lf%lf%lf", &p1.x, &p1.y, &p2.x, &p2.y); // ax...
#include <math.h> #include <stdio.h> typedef struct point { double x, y; } point; double segment(point p1, point p2); double inclination(point p1, point p2); point reflection(point p1, point p2, point p3); int main(void) { point p1, p2, p; int n, i; scanf("%lf%lf%lf%lf", &p1.x, &p1.y, &p2.x, &p2.y); // ax...
[["-", 0, 1, 0, 11, 12, 16, 12, 118, 119, 120], ["+", 0, 1, 0, 11, 12, 16, 12, 118, 119, 120]]
0
513
2
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> pt; #define X real() #define Y imag() void pin(pt &p) { ld x, y; cin >> x >> y; p = {x, y}; } ostream &operator<<(ostream &os, pt p) { return os << p.X << " " << p.Y << endl; } ld dot(pt p, pt q) { re...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> pt; #define X real() #define Y imag() void pin(pt &p) { ld x, y; cin >> x >> y; p = {x, y}; } ostream &operator<<(ostream &os, pt p) { return os << p.X << " " << p.Y << endl; } ld dot(pt p, pt q) { re...
[["+", 0, 118, 28, 23, 0, 16, 31, 2, 63, 22], ["+", 28, 23, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 28, 23, 0, 16, 31, 2, 3, 4, 0, 25]]
1
248
3
#include <bits/stdc++.h> using namespace std; typedef complex<double> Point; struct Segment { Point p1, p2; Segment(const Point &p1 = Point(), const Point &p2 = Point()) : p1(p1), p2(p2) {} }; struct Circle { Point p; double r; Circle(const Point &p = Point(), double r = 0.0) : p(p), r(r) {} }; type...
#include <bits/stdc++.h> using namespace std; typedef complex<double> Point; struct Segment { Point p1, p2; Segment(const Point &p1 = Point(), const Point &p2 = Point()) : p1(p1), p2(p2) {} }; struct Circle { Point p; double r; Circle(const Point &p = Point(), double r = 0.0) : p(p), r(r) {} }; type...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
638
1
#include <complex> #include <iomanip> #include <iostream> using namespace std; typedef complex<double> Point; Point reflection(Point a, Point b) { return conj(b / a) * a; } int main() { double x, y; cin >> x >> y; complex<double> p1(x, y); cin >> x >> y; complex<double> p2(x, y); int q; cin >> q; fo...
#include <complex> #include <iomanip> #include <iostream> using namespace std; typedef complex<double> Point; Point reflection(Point a, Point b) { return conj(b / a) * a; } int main() { double x, y; cin >> x >> y; complex<double> p1(x, y); cin >> x >> y; complex<double> p2(x, y); int q; cin >> q; fo...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["-", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
164
4
#ifndef ___Class_Point #define ___Class_Point class Point { private: double x_; double y_; public: Point() : x_(0), y_(0) {} explicit Point(double x, double y) : x_(x), y_(y) {} explicit Point(double x1, double y1, double x2, double y2) : x_(x2 - x1), y_(y2 - y1) {} double x() const { return x_; ...
#ifndef ___Class_Point #define ___Class_Point class Point { private: double x_; double y_; public: Point() : x_(0), y_(0) {} explicit Point(double x, double y) : x_(x), y_(y) {} explicit Point(double x1, double y1, double x2, double y2) : x_(x2 - x1), y_(y2 - y1) {} double x() const { return x_; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72]]
1
1,203
4
#include <iomanip> #include <iostream> #include <cmath> #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) using namespace std; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Poi...
#include <iomanip> #include <iostream> #include <cmath> #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) using namespace std; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Poi...
[["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22]]
1
749
2
#include <fstream> #include <iomanip> #include <iostream> #include <math.h> #include <stdio.h> using namespace std; template <class T> class _Point { public: T x; T y; _Point() {} _Point(T _x, T _y) : x(_x), y(_y) {} _Point(const _Point &v) : x(v.x), y(v.y) {} const _Point operator+(const _Point &v) { ret...
#include <fstream> #include <iomanip> #include <iostream> #include <math.h> #include <stdio.h> using namespace std; template <class T> class _Point { public: T x; T y; _Point() {} _Point(T _x, T _y) : x(_x), y(_y) {} _Point(const _Point &v) : x(v.x), y(v.y) {} const _Point operator+(const _Point &v) { ret...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22]]
1
422
5
#include <cstdlib> #include <iostream> #include <list> #include <math.h> #include <queue> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <vector> using namespace std; class c_main { private: public: c_main(); void f_input(); }; c_main::c_main() {} void c_main::f_input() { ...
#include <cstdlib> #include <iostream> #include <list> #include <math.h> #include <queue> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <vector> using namespace std; class c_main { private: public: c_main(); void f_input(); }; c_main::c_main() {} void c_main::f_input() { ...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72]]
1
530
8
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef complex<double> V; typedef vector<P> vecP; typedef pair<P, P> L; typedef pair<P, P> S; typedef pair<P, double> C; const double eps = 1e-8; const double PI = acos(-1); const double PI2 = PI * 2.0; namespace std { bool operator<(const P &a,...
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef complex<double> V; typedef vector<P> vecP; typedef pair<P, P> L; typedef pair<P, P> S; typedef pair<P, double> C; const double eps = 1e-8; const double PI = acos(-1); const double PI2 = PI * 2.0; namespace std { bool operator<(const P &a,...
[["-", 0, 37, 0, 16, 12, 16, 12, 2, 63, 22], ["+", 0, 37, 0, 16, 12, 16, 12, 2, 63, 22]]
1
3,443
2
#include <bits/stdc++.h> #ifndef LOCAL_ #define fprintf \ if (false) \ fprintf #endif // LOCAL_ // #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__); #define dumpl(x1) ...
#include <bits/stdc++.h> #ifndef LOCAL_ #define fprintf \ if (false) \ fprintf #endif // LOCAL_ // #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__); #define dumpl(x1) ...
[["+", 0, 14, 8, 9, 0, 37, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72]]
1
468
2
#include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; // 2次元ベクトルクラス class Vector { public: double x, y; Vector() { x = 0.0; y = 0.0; } Vector(double nx, double ny) { x = nx; y = ny; } void set(double nx, double ny) { x = nx; y = ny; } ...
#include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; // 2次元ベクトルクラス class Vector { public: double x, y; Vector() { x = 0.0; y = 0.0; } Vector(double nx, double ny) { x = nx; y = ny; } void set(double nx, double ny) { x = nx; y = ny; } ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 4, 0, 16, 31, 2, 63, 22], ["+", 51, 4, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 51, 4, 0, 16, 31, 2, 3, 4, 0, 22], ["+", 51, 4, 0, 16, 31, 2, 3, 4, 0, 21], ["+", 51, 4, 0, 16, 31, 2, 3, 4, 0, 25]]
1
902
7
#include <complex> #include <iostream> #include <string> #include <vector> enum INDICES { COUNTER_CLOCKWISE = 0, CLOCKWISE, ONLINE_BACK, ON_SEGMENT, ONLINE_FRONT }; const std::vector<std::string> strLst = {"COUNTER_CLOCKWISE", "CLOCKWISE", "ONLINE_BACK", "ON_SEGMENT"...
#include <complex> #include <iostream> #include <string> #include <vector> enum INDICES { COUNTER_CLOCKWISE = 0, CLOCKWISE, ONLINE_BACK, ON_SEGMENT, ONLINE_FRONT }; const std::vector<std::string> strLst = {"COUNTER_CLOCKWISE", "CLOCKWISE", "ONLINE_BACK", "ON_SEGMENT"...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
369
2
x1, y1, x2, y2 = gets.split.map(&:to_i) u = (x2 - x1) + (y2 - y1) * 1i gets.to_i.times do x, y = gets.split.map(&:to_i) v = x - x1 + (y - y1) * 1i d = (u.conj * v).imag case when d > 0 puts 'COUNTER_CLOCKWISE' when d < 0 puts 'CLOCKWISE' else d = (v / u).real case when d < 0 puts...
x1, y1, x2, y2 = gets.split.map(&:to_i) u = (x2 - x1) + (y2 - y1) * 1i gets.to_i.times do x, y = gets.split.map(&:to_i) v = x - x1 + (y - y1) * 1i d = (u.conj * v).imag case when d > 0 puts 'COUNTER_CLOCKWISE' when d < 0 puts 'CLOCKWISE' else d = (v / u).real case when d < 0 puts...
[["-", 0, 173, 0, 763, 374, 374, 0, 738, 17, 18], ["+", 0, 173, 0, 763, 374, 374, 0, 738, 17, 19]]
4
129
2
from math import sqrt xp0, yp0, xp1, yp1 = map(int, input().split()) a = [xp0, yp0] b = [xp1, yp1] q = int(input()) CCW = {1: 'COUNTER_CLOCKWISE', 2: 'CLOCKWISE', 3: 'ONLINE_BACK', 4: 'ONLINE_FRONT', 5: 'ON_SEGMENT',} def dot(a, b): return sum([i * j for i,j in zip(a, b)]) def sub(a, ...
from math import sqrt xp0, yp0, xp1, yp1 = map(int, input().split()) a = [xp0, yp0] b = [xp1, yp1] q = int(input()) CCW = {1: 'COUNTER_CLOCKWISE', 2: 'CLOCKWISE', 3: 'ONLINE_BACK', 4: 'ONLINE_FRONT', 5: 'ON_SEGMENT',} def dot(a, b): return sum([i * j for i,j in zip(a, b)]) def sub(a, ...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
305
2
# -*- coding: utf-8 -*- import collections import math class Vector2(collections.namedtuple("Vector2", ["x", "y"])): def __add__(self, other): return Vector2(self.x + other.x, self.y + other.y) def __sub__(self, other): return Vector2(self.x - other.x, self.y - other.y) def __mul__(se...
# -*- coding: utf-8 -*- import collections import math class Vector2(collections.namedtuple("Vector2", ["x", "y"])): def __add__(self, other): return Vector2(self.x + other.x, self.y + other.y) def __sub__(self, other): return Vector2(self.x - other.x, self.y - other.y) def __mul__(se...
[["-", 0, 662, 12, 680, 0, 569, 51, 557, 0, 6], ["+", 0, 662, 12, 680, 0, 569, 51, 557, 0, 6]]
5
586
2
public class Main { public void run(java.io.InputStream in, java.io.PrintStream out) { java.util.Scanner sc = new java.util.Scanner(in); /*answer*/ int q; double[] xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3; int i; double s1x, s1y, s2x, s2y; q = sc.nextInt(); xp0 = new double[q]; yp0 ...
public class Main { public void run(java.io.InputStream in, java.io.PrintStream out) { java.util.Scanner sc = new java.util.Scanner(in); /*answer*/ int q; double[] xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3; int i; double s1x, s1y, s2x, s2y; q = sc.nextInt(); xp0 = new double[q]; yp0 ...
[["-", 15, 15, 0, 16, 31, 23, 0, 16, 17, 85], ["-", 15, 15, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 15, 15, 0, 16, 31, 23, 0, 16, 17, 48], ["+", 15, 15, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 15, 15, 0, 16, 12, 23, 0, 16, 17, 85], ["-", 15, 15, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 15, 15, 0, 16, 12, 23, 0, 16, 17, 48], ["+"...
3
420
8
import java.util.ArrayList; import java.util.Scanner; class Point { double EPS = 0.0000000001; double x; double y; public Point(double ax, double ay) { x = ax; y = ay; } public Point sum(Point p) { return new Point(x + p.x, y + y); } public Point diff(Point p) { return new Point(x - p.x, y - p.y)...
import java.util.ArrayList; import java.util.Scanner; class Point { double EPS = 0.0000000001; double x; double y; public Point(double ax, double ay) { x = ax; y = ay; } public Point sum(Point p) { return new Point(x + p.x, y + y); } public Point diff(Point p) { return new Point(x - p.x, y - p.y)...
[["-", 12, 16, 31, 23, 0, 16, 31, 509, 119, 22], ["+", 12, 16, 31, 23, 0, 16, 31, 509, 119, 22], ["-", 12, 16, 31, 23, 0, 16, 12, 509, 119, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 509, 119, 22], ["-", 12, 16, 12, 23, 0, 16, 31, 509, 119, 22], ["+", 12, 16, 12, 23, 0, 16, 31, 509, 119, 22], ["-", 12, 16, 12, 23, 0, 16, 12...
3
864
8
#include <stdio.h> int main(void) { int i, n, x0, y0, x1, y1, x2, y2, x3, y3, l0x, l0y, l1x, l1y; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d %d %d %d %d %d %d", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3); l0x = x1 - x0; l0y = y1 - y0; l1x = x3 - x2; l1y = y3 - y2; if (l0x == 0 &&...
#include <stdio.h> int main(void) { int i, n, x0, y0, x1, y1, x2, y2, x3, y3, l0x, l0y, l1x, l1y; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d %d %d %d %d %d %d", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3); l0x = x1 - x0; l0y = y1 - y0; l1x = x3 - x2; l1y = y3 - y2; if (l0x == 0 &&...
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 85], ["-", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 48], ["+"...
0
253
8
#include <math.h> #include <stdio.h> #include <stdlib.h> #define max(a, b) a < b ? b : a #define min(a, b) a < b ? b : a #define POW2(a) a *a #define ROOP(i, n) for (i = 0; i < n; i++) #define _USE_MATH_DEFINES typedef struct POINT { double x; double y; } POINT; typedef struct LINE { POINT s; // start point PO...
#include <math.h> #include <stdio.h> #include <stdlib.h> #define max(a, b) a < b ? b : a #define min(a, b) a < b ? b : a #define POW2(a) a *a #define ROOP(i, n) for (i = 0; i < n; i++) #define _USE_MATH_DEFINES typedef struct POINT { double x; double y; } POINT; typedef struct LINE { POINT s; // start point PO...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
1,250
2
#include <math.h> #include <stdio.h> int main() { int t, x1, x2, x3, x4, y1, y2, y3, y4; double m1, m2, temp; scanf("%d", &t); while (t--) { scanf("%d %d %d %d %d %d %d %d", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4); if (((x2 - x1) * (x4 - x3)) + ((y2 - y1) * (y4 - y3)) == 0) { printf("1\n"); ...
#include <math.h> #include <stdio.h> int main() { int t, x1, x2, x3, x4, y1, y2, y3, y4; double m1, m2, temp; scanf("%d", &t); while (t--) { scanf("%d %d %d %d %d %d %d %d", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4); if (((x2 - x1) * (x4 - x3)) + ((y2 - y1) * (y4 - y3)) == 0) { printf("1\n"); ...
[["-", 31, 23, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 31, 22], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 12, 22], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 31, 22], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 22], ["+"...
0
178
8
#include <stdio.h> int main() { int q, i, x1, y1, x2, y2, x3, y3, x4, y4; scanf("%d", &q); for (i = 1; i <= q; i++) { scanf("%d%d%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4); if ((x2 - x1) == 0 && (x4 - x3) == 0) { printf("2\n"); } else if (((x2 - x1) == 0 && (y4 - y3) == 0) || ...
#include <stdio.h> int main() { int q, i, x1, y1, x2, y2, x3, y3, x4, y4; scanf("%d", &q); for (i = 1; i <= q; i++) { scanf("%d%d%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4); if ((x2 - x1) == 0 && (x4 - x3) == 0) { printf("2\n"); } else if (((x2 - x1) == 0 && (y4 - y3) == 0) || ...
[["+", 0, 9, 0, 57, 15, 23, 0, 16, 17, 60], ["+", 0, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
291
2
#include <cmath> #include <iostream> #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b) < EPS)) class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); }...
#include <cmath> #include <iostream> #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); }...
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59]]
1
548
2
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define EPS (1e-10) struct Point { Point(double _x = 0, doubl...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define EPS (1e-10) struct Point { Point(double _x = 0, doubl...
[["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["+", 31, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["-", 51, 16, 31, 23, 0, 16, 12, 2, 63, 22]]
1
492
3
#include <bits/stdc++.h> using namespace std; #define int lint typedef long long lint; typedef pair<int, int> P; const int INF = (int)1e9; const int MOD = (int)1e9 + 7; const double EPS = (double)1e-10; #define equals(a, b) (fabs((a) - (b)) < EPS) struct Accelerate_Cin { Accelerate_Cin() { cin.tie(0); ios::sy...
#include <bits/stdc++.h> using namespace std; #define int lint typedef long long lint; typedef pair<int, int> P; const int INF = (int)1e9; const int MOD = (int)1e9 + 7; const double EPS = (double)1e-10; #define equals(a, b) (fabs((a) - (b)) < EPS) struct Accelerate_Cin { Accelerate_Cin() { cin.tie(0); ios::sy...
[["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["+", 8, 9, 0, 37, 0, 16, 12, 16, 17, 48]]
1
865
2
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4267) // "int n = (unsigned)size" using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using ll = long long int; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vd = vector<double>; using v...
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4267) // "int n = (unsigned)size" using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using ll = long long int; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vd = vector<double>; using v...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 14, 8, 9, 0...
1
1,422
8
#include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define fs first #define sc second #define pb push_back using namespace std; typedef double D; typedef complex<D> P; typedef pair<P, P> L; // fs->sc typedef vector...
#include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define fs first #define sc second #define pb push_back using namespace std; typedef double D; typedef complex<D> P; typedef pair<P, P> L; // fs->sc typedef vector...
[["-", 15, 339, 51, 2, 3, 4, 0, 2, 63, 22], ["+", 15, 339, 51, 2, 3, 4, 0, 2, 63, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 118, 17, 131], ["+", 3, 4, 0, 2, 3, 4, 0, 118, 119, 120], ["-", 3, 4, 0, 2, 3, 4, 0, 118, 119, 120]]
1
1,864
6
#include <bits/stdc++.h> /* #include<algolithm> #include<array> #include<vector> */ using namespace std; typedef double Real; constexpr Real EPS = 1e-8; int sign(Real d) { if (d > EPS) { return 1; } if (d < -EPS) { return -1; } return 0; } struct Point { Real x, y; Point(Real x_ = 0, Real y_ =...
#include <bits/stdc++.h> /* #include<algolithm> #include<array> #include<vector> */ using namespace std; typedef double Real; constexpr Real EPS = 1e-8; int sign(Real d) { if (d > EPS) { return 1; } if (d < -EPS) { return -1; } return 0; } struct Point { Real x, y; Point(Real x_ = 0, Real y_ =...
[["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 33]]
1
805
2
#include <complex> #include <cstdio> #include <iostream> using namespace std; typedef long long lli; typedef complex<lli> point; lli dot(point a, point b) { return (a * conj(b)).real(); } lli cross(point a, point b) { return (a * conj(b)).imag(); } int main(void) { double x, y; int q; cin >> q; while (q--) ...
#include <complex> #include <cstdio> #include <iostream> using namespace std; typedef long long lli; typedef complex<lli> point; lli dot(point a, point b) { return (a * conj(b)).real(); } lli cross(point a, point b) { return (a * conj(b)).imag(); } int main(void) { lli x, y; int q; cin >> q; while (q--) { ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
219
4
#include <bits/stdc++.h> using namespace std; struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; #define P(x) cout << (x) << "\n" #define p(x) cout << (x) #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define vv(type, c, m, n, i) vector<vector<type>> c(m...
#include <bits/stdc++.h> using namespace std; struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; #define P(x) cout << (x) << "\n" #define p(x) cout << (x) #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define vv(type, c, m, n, i) vector<vector<type>> c(m...
[["+", 8, 9, 0, 37, 0, 16, 31, 2, 63, 22], ["+", 0, 37, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 0, 37, 0, 16, 31, 2, 3, 4, 0, 25]]
1
378
3
#include <bits/stdc++.h> using namespace std; #define pb(n) push_back(n) #define fi first #define se second #define all(r) begin(r), end(r) #define vmax(ary) *max_element(all(ary)) #define vmin(ary) *min_element(all(ary)) #define debug(x) cout << #x << ": " << x << endl #define fcout(n) cout << fixed << setprecision((...
#include <bits/stdc++.h> using namespace std; #define pb(n) push_back(n) #define fi first #define se second #define all(r) begin(r), end(r) #define vmax(ary) *max_element(all(ary)) #define vmin(ary) *min_element(all(ary)) #define debug(x) cout << #x << ": " << x << endl #define fcout(n) cout << fixed << setprecision((...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 2, 3, 4, 0, 2, 3, 4, 0, 25], ["+", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24]]
1
636
6
import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.util.*; public class Main { Scanner in = new Scanner(System.in); public static void main(String[] args) { new Main(); } public Main() { new AOJCGL_1C().doIt(); } class AOJCGL_1C { private Point2D projection(Line2D l, Point2D p2) { ...
import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.util.*; public class Main { Scanner in = new Scanner(System.in); public static void main(String[] args) { new Main(); } public Main() { new AOJCGL_1C().doIt(); } class AOJCGL_1C { private Point2D projection(Line2D l, Point2D p2) { ...
[["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 44]]
3
441
1
#include <math.h> #include <stdio.h> struct points { double x; double y; }; int main(void) { struct points eigenvector; int p1x, p1y, p2x, p2y, px, py; double length; int q; int i; scanf("%d%d%d%d", &p1x, &p1y, &p2x, &p2y); struct points p1, p2; p1.x = p1x; p1.y = p1y; p2.x = p2x; p2.y = p2y...
#include <math.h> #include <stdio.h> struct points { double x; double y; }; int main(void) { struct points eigenvector; int p1x, p1y, p2x, p2y, px, py; double length; int q; int i; scanf("%d%d%d%d", &p1x, &p1y, &p2x, &p2y); struct points p1, p2; p1.x = p1x; p1.y = p1y; p2.x = p2x; p2.y = p2y...
[["-", 12, 16, 31, 23, 0, 16, 31, 118, 28, 22], ["+", 12, 16, 31, 23, 0, 16, 31, 118, 28, 22], ["-", 12, 16, 31, 23, 0, 16, 12, 118, 28, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 118, 28, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
271
10
#include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define fs first #define sc second #define pb push_back using namespace std; typedef double D; typedef complex<D> P; typedef pair<P, P> L; // fs->sc typedef vector...
#include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define fs first #define sc second #define pb push_back using namespace std; typedef double D; typedef complex<D> P; typedef pair<P, P> L; // fs->sc typedef vector...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
1,792
4
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <ctype.h> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #includ...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <ctype.h> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #includ...
[["+", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
602
4
#include <iostream> #include <math.h> #include <stdio.h> #define EPS 0.00000001 using namespace std; int main(void) { double x1, y1, x2, y2; double x0, y0; double dx, dy; double m; double X, Y; int q; cin >> x1 >> y1 >> x2 >> y2; dx = x1 - x2; dy = y1 - y2; cin >> q; while (q--) { cin >> x0 >...
#include <iostream> #include <math.h> #include <stdio.h> #define EPS 0.00000001 using namespace std; int main(void) { double x1, y1, x2, y2; double x0, y0; double dx, dy; double m; double X, Y; int q; cin >> x1 >> y1 >> x2 >> y2; dx = x1 - x2; dy = y1 - y2; cin >> q; while (q--) { cin >> x0 >...
[["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 0, 57, 15, 339, 51, 91, 28, 23, 0, 24], ["+", 0, 57, 15, 339, 51, 91, 28, 23, 0, 25]]
1
174
3
#include <complex> #include <cstdio> #include <iostream> using namespace std; int main(void) { double x, y; int q; cin >> x >> y; complex<double> p1(x, y); cin >> x >> y; complex<double> p2(x, y); cin >> q; while (q--) { cin >> x >> y; complex<double> p(x, y); complex<double> p1p = p - p1; ...
#include <complex> #include <cstdio> #include <iostream> using namespace std; int main(void) { double x, y; int q; cin >> x >> y; complex<double> p1(x, y); cin >> x >> y; complex<double> p2(x, y); cin >> q; while (q--) { cin >> x >> y; complex<double> p(x, y); complex<double> p1p = p - p1; ...
[["-", 49, 50, 51, 16, 12, 2, 3, 4, 0, 22], ["+", 49, 50, 51, 16, 12, 2, 3, 4, 0, 22]]
1
176
2
#include <cmath> #include <iostream> #include <stdio.h> #include <utility> using namespace std; int main(void) { pair<double, double> p0, p1, p; pair<double, double> ans; int n; cin >> p0.first >> p0.second >> p1.first >> p1.second; cin >> n; while (n--) { cin >> p.first >> p.second; double a; ...
#include <cmath> #include <iostream> #include <stdio.h> #include <utility> using namespace std; int main(void) { pair<double, double> p0, p1, p; pair<double, double> ans; int n; cin >> p0.first >> p0.second >> p1.first >> p1.second; cin >> n; while (n--) { cin >> p.first >> p.second; double a; ...
[["-", 64, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 11, 12, 118, 119, 120]]
1
262
2
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define REP(i, k, n) for (int i = k; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1 << 30 #define pb push_back #define mp make_pair ...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> #define REP(i, k, n) for (int i = k; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1 << 30 #define pb push_back #define mp make_pair ...
[["-", 0, 1, 0, 16, 31, 16, 12, 118, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 118, 28, 22]]
1
1,644
2
#include <cmath> #include <cstdio> #include <iostream> using namespace std; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x + p.x, y + p.y); } Point operator*(double k)...
#include <cmath> #include <cstdio> #include <iostream> using namespace std; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double k)...
[["-", 0, 37, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 17, 33]]
1
425
4
#include <cmath> #include <complex> #include <cstdio> #include <utility> #include <vector> using namespace std; static const double EPS = 1e-12; static const double INF = 1e24; using Point = complex<double>; using Plane = vector<Point>; bool operator<(const Point &a, const Point &b) { return real(a) != real(b) ? ...
#include <cmath> #include <complex> #include <cstdio> #include <utility> #include <vector> using namespace std; static const double EPS = 1e-12; static const double INF = 1e24; using Point = complex<double>; using Plane = vector<Point>; bool operator<(const Point &a, const Point &b) { return real(a) != real(b) ? ...
[["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 22]]
1
401
2
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point opera...
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point opera...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
546
1
#include <cmath> #include <iomanip> #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) for (int i = 0; i < (n); i++) #define PII pair<int, int> #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: double x, y; Point(doub...
#include <cmath> #include <iomanip> #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) for (int i = 0; i < (n); i++) #define PII pair<int, int> #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: double x, y; Point(doub...
[["+", 0, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 22]]
1
632
2
#include <complex> #include <cstdio> #define N 1000 typedef std::complex<double> point; double InnerProd(point x, point y); point Projection(point x, point y); int main() { point ans, p1, p2, tmp; int q; double x1, x2, y1, y2; scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2); p1 = point(x1, y1); p2 = point(x2, y2)...
#include <complex> #include <cstdio> #define N 1000 typedef std::complex<double> point; double InnerProd(point x, point y); point Projection(point x, point y); int main() { point ans, p1, p2; int q; double x1, x2, y1, y2; scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2); p1 = point(x1, y1); p2 = point(x2, y2); s...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 12, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 12, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
240
4
//#define __USE_MINGW_ANSI_STDIO 0 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #defi...
//#define __USE_MINGW_ANSI_STDIO 0 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #defi...
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22]]
1
387
2
#include <bits/stdc++.h> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) #define SQR(n) ((n) * (n)) //??? struct Point { double x, y; Point() {} Point(double x, double y) : x(x), y(y) {} Point operator+(Point p) { return (Point(x + p.x, y + p.y)); } Point operator-(Po...
#include <bits/stdc++.h> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) #define SQR(n) ((n) * (n)) //??? struct Point { double x, y; Point() {} Point(double x, double y) : x(x), y(y) {} Point operator+(Point p) { return (Point(x + p.x, y + p.y)); } Point operator-(Po...
[["+", 0, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 2, 3, 4, 0, 16, 12, 118, 28, 22], ["+", 31, 2, 3, 4, 0, 16, 12, 118, 17, 131], ["+", 31, 2, 3, 4, 0, 16, 12, 118, 119, 120]]
1
586
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <queue> #include <vector> using namespace std; #define f(i, n) for (int i = 0; i < (int)n; i++) #define MOD 1000000009 #define MIN (1e-10) typedef complex<long double> P; bool ...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <queue> #include <vector> using namespace std; #define f(i, n) for (int i = 0; i < (int)n; i++) #define MOD 1000000009 #define MIN (1e-10) typedef complex<double> P; bool EQ(P ...
[["-", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["-", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
515
4
#include <iomanip> #include <iostream> using namespace std; struct Point { double x; double y; Point(double x, double y) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator*(double d) { return Point(x * d, y * d); } }; typedef Point Vector; double dot(Vector v1, Vecto...
#include <iomanip> #include <iostream> using namespace std; struct Point { double x; double y; Point(double x, double y) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator*(double d) { return Point(x * d, y * d); } }; typedef Point Vector; double dot(Vector v1, Vecto...
[["-", 0, 43, 49, 50, 51, 16, 12, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 16, 31, 22]]
1
279
2
#include <algorithm> #include <array> #include <cstdio> #include <functional> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define INF 200000...
#include <algorithm> #include <array> #include <cstdio> #include <functional> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define INF 200000...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72]]
1
273
4
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <type_traits> ...
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <type_traits> ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
1,771
1
#include <cstdio> #include <iostream> using namespace std; typedef long long ll; ll read() { ll x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return ...
#include <cstdio> #include <iostream> using namespace std; typedef long long ll; ll read() { ll x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return ...
[["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 33], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["-", 49, 50, 51, 16, 31, 2, 3, 4, 0, 22], ["-", 49, 50, 51, 16, 31, 2, 3, 4, 0, 21], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 21], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 22]]
1
420
6
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; using D = double; const D PI = acos(D(-1)), E...
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; using D = double; const D PI = acos(D(-1)), E...
[["+", 8, 9, 0, 37, 0, 16, 31, 118, 28, 22], ["+", 8, 9, 0, 37, 0, 16, 31, 118, 17, 131], ["+", 8, 9, 0, 37, 0, 16, 31, 118, 119, 120], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72]]
1
2,026
4
#include <iostream> #include <math.h> #include <vector> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) #define FOR(k, m, n) for (int(k) = (m); (k) < (n); (k)++) #define REP(i, n) FOR((i), 0, (n)) //??? //??? class Point { public: double x, y; //????????????????????? Point...
#include <iostream> #include <math.h> #include <vector> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) #define FOR(k, m, n) for (int(k) = (m); (k) < (n); (k)++) #define REP(i, n) FOR((i), 0, (n)) //??? //??? class Point { public: double x, y; //????????????????????? Point...
[["-", 31, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 31, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 118, 28, 69, 341, 342, 0, 22]]
1
714
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef sta...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef sta...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
410
4
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; using ll = long long; const double EPS = 1e-10; inline bool equals(double a, double b) { return fabs(a - b) < EPS; } class Point { public: double x, y; Point(int x, int y) : x(x), y(y) {} Point() {} Point operator+(Point &p) { return...
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; using ll = long long; const double EPS = 1e-10; inline bool equals(double a, double b) { return fabs(a - b) < EPS; } class Point { public: double x, y; Point(int x, int y) : x(x), y(y) {} Point() {} Point operator+(Point &p) { return...
[["-", 0, 37, 0, 16, 12, 16, 12, 118, 119, 120], ["+", 0, 37, 0, 16, 12, 16, 12, 118, 119, 120]]
1
492
2
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8, PI = acos(-1); inline bool eq(double a, double b) { return fabs(b - a) < EPS; } using Point = complex<double>; istream &operator>>(istream &is, Point &p) { double a, b; is >> a >> b; p = Point(a, b); return is; } ostream &operator<<(os...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8, PI = acos(-1); inline bool eq(double a, double b) { return fabs(b - a) < EPS; } using Point = complex<double>; istream &operator>>(istream &is, Point &p) { double a, b; is >> a >> b; p = Point(a, b); return is; } ostream &operator<<(os...
[["-", 0, 16, 31, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 16, 31, 2, 3, 4, 0, 2, 63, 22]]
1
4,590
2
#include <algorithm> #include <cmath> #include <iostream> #include <set> #include <vector> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, ...
#include <algorithm> #include <cmath> #include <iostream> #include <set> #include <vector> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, ...
[["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 33]]
1
2,591
2
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs(a - b) < EPS) class Point { public: double x, y; Point(double x_ = 0, double y_ = 0) { x = x_; y = y_; } Point operator+(Point p) { return Point(x + p.x, y + p.y); }; Point...
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs(a - b) < EPS) class Point { public: double x, y; Point(double x_ = 0, double y_ = 0) { x = x_; y = y_; } Point operator+(Point p) { return Point(x + p.x, y + p.y); }; Point...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
537
3
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define Rep(b, e, i) for...
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define Rep(b, e, i) for...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
286
4
#include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cctype> // require tolower, toupper #include <cfloat> #include <climits> #include <cmath> // require fabs #include <cstdio> // require scanf printf #include <cstdlib> // require abs exit atof atoi #include <cstring> // requir...
#include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cctype> // require tolower, toupper #include <cfloat> #include <climits> #include <cmath> // require fabs #include <cstdio> // require scanf printf #include <cstdlib> // require abs exit atof atoi #include <cstring> // requir...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24]]
1
692
6
require 'matrix' q = gets.to_i x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i s1 = Vector[ x1 - x0, y1 - y0, 0 ] s2 = Vector[ x3 - x2, y3 - y2, 0 ] if s1.inner_product(s1) == 0 puts 1 elsif s1.cross_product(s2).norm == 0 puts 2 else puts 0 end
require 'matrix' q = gets.to_i q.times do x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i s1 = Vector[ x1 - x0, y1 - y0, 0 ] s2 = Vector[ x3 - x2, y3 - y2, 0 ] if s1.inner_product(s2) == 0 puts 1 elsif s1.cross_product(s2).norm == 0 puts 2 else puts 0 end end
[["+", 36, 36, 36, 36, 0, 493, 0, 652, 486, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 17, 131], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 0, 493, 0, 652, 196, 737, 0, 170], ["-", 0, 121, 15, 738, 31, 652, 3, 4, 0, 22], ["+", 0, 121, 15, 738, 31, 652, 3, 4, 0, 22], ["+", 0, 652, 196, 737, 8, 736, 0,...
4
88
7
eps = 1e-12 q = gets.to_i q.times{ x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f) v0x = x1 - x0 v0y = y1 - y0 v1x = x3 - x2 v1y = y3 - y2 ct = (v0x*v1x+v0y*v1y)/Math.sqrt(v0x**2+v0y**2)/Math.sqrt(v1x**2+v1y**2) p ct if (ct.abs - 1.0).abs < eps puts 2 elsif ct.abs < eps puts 1 else ...
eps = 1e-12 q = gets.to_i q.times{ x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f) v0x = x1 - x0 v0y = y1 - y0 v1x = x3 - x2 v1y = y3 - y2 ct = (v0x*v1x+v0y*v1y)/Math.sqrt(v0x**2+v0y**2)/Math.sqrt(v1x**2+v1y**2) if (ct.abs - 1.0).abs < eps puts 2 elsif ct.abs < eps puts 1 else put...
[["-", 0, 652, 196, 196, 8, 734, 0, 652, 735, 22], ["-", 196, 196, 8, 734, 0, 652, 3, 4, 0, 22]]
4
123
2
def dot(a,b):return a[0]*b[0] + a[1]*b[1] def cross(a,b):return a[0]*b[1] - a[1]*b[0] q = int(input()) for i in range(q): x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()] a = [x1-x0,y1-y0] b = [x3-x2,y3-y1] if dot(a,b) == 0 : print(1) elif cross(a,b) == 0 : print(2) else : print(0)
def dot(a,b):return a[0]*b[0] + a[1]*b[1] def cross(a,b):return a[0]*b[1] - a[1]*b[0] q = int(input()) for i in range(q): x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()] a = [x1-x0,y1-y0] b = [x3-x2,y3-y2] if dot(a,b) == 0 : print(1) elif cross(a,b) == 0 : print(2) else : print(0)
[["-", 0, 1, 0, 662, 12, 634, 0, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 634, 0, 657, 12, 22]]
5
160
2
n = int(input()) def dot(a,b): return a[0] * b[0] + a[1] * b[1] from math import sqrt def s(a): return sqrt(a[0]**2 + a[1]**2) for i in range(n): points = [int(j) for j in input().split()] p0 = points[:2] p1 = points[2:4] a = [p0[0]-p1[0],p0[1]-p1[1]] p2 = points[4:6] p3 = points[6:8]...
n = int(input()) def dot(a,b): return a[0] * b[0] + a[1] * b[1] from math import sqrt def s(a): return a[0]**2 + a[1]**2 for i in range(n): points = [int(j) for j in input().split()] p0 = points[:2] p1 = points[2:4] a = [p0[0]-p1[0],p0[1]-p1[1]] p2 = points[4:6] p3 = points[6:8] b ...
[["-", 0, 14, 8, 196, 0, 37, 0, 652, 63, 22], ["-", 8, 196, 0, 37, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 37, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 17, 578], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 612]]
5
210
5