Submission #34389363
Source Code Expand
Copy
#include <bits/stdc++.h>#define P pair<int, int>#define fi first#define se second#define pb push_back#define all(v) v.begin(), v.end()using namespace std;template <typename T> void rd(T &x) {x = 0; T 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();}x *= f;}template <typename T> void write(T x) {if (x < 0) {putchar('-'); x = -x;}if (x >= 10) write(x / 10);putchar(x % 10 + 48);}typedef long long ll;const int N = 1e5 + 10;
#include <bits/stdc++.h> #define P pair<int, int> #define fi first #define se second #define pb push_back #define all(v) v.begin(), v.end() using namespace std; template <typename T> void rd(T &x) { x = 0; T 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();} x *= f; } template <typename T> void write(T x) { if (x < 0) {putchar('-'); x = -x;} if (x >= 10) write(x / 10); putchar(x % 10 + 48); } typedef long long ll; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; const int Mod = 1e9 + 7; double x[10], y[10]; int main() { for (int i = 1; i <= 4; i++) { cin >> x[i] >> y[i]; } bool f = 0, f2 = 0; double k1, b1; if (x[1] == x[3]) { f = 1; } else { f = 0; k1 = (y[1] - y[3]) / (x[1] - x[3]); b1 = y[1] - x[1] * k1; } if (f) { if ((x[2] - x[1]) * (x[4] - x[1]) > 0) { puts("No"); return 0; } } else { double X = k1 * x[2] + b1, Y = k1 * x[4] + b1; if ((y[2] - X) * (y[4] - Y) > 0) { puts("No"); return 0; } } swap(x[1], x[2]); swap(x[3], x[4]); swap(y[1], y[2]); swap(y[3], y[4]); if (x[1] == x[3]) { f = 1; } else { f = 0; k1 = (y[1] - y[3]) / (x[1] - x[3]); b1 = y[1] - x[1] * k1; } if (f) { if ((x[2] - x[1]) * (x[4] - x[1]) > 0) { puts("No"); return 0; } } else { double X = k1 * x[2] + b1, Y = k1 * x[4] + b1; if ((y[2] - X) * (y[4] - Y) > 0) { puts("No"); return 0; } } puts("Yes"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Convex Quadrilateral |
User | LYR_ |
Language | C++ (GCC 9.2.1) |
Score | 300 |
Code Size | 1883 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 3636 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:29:17: warning: unused variable ‘f2’ [-Wunused-variable] 29 | bool f = 0, f2 = 0; | ^~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, sample_01.txt, sample_02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
random_01.txt | AC | 8 ms | 3604 KB |
random_02.txt | AC | 2 ms | 3556 KB |
random_03.txt | AC | 2 ms | 3580 KB |
random_04.txt | AC | 2 ms | 3552 KB |
random_05.txt | AC | 2 ms | 3592 KB |
random_06.txt | AC | 2 ms | 3524 KB |
random_07.txt | AC | 2 ms | 3628 KB |
random_08.txt | AC | 2 ms | 3516 KB |
random_09.txt | AC | 3 ms | 3556 KB |
random_10.txt | AC | 2 ms | 3524 KB |
random_11.txt | AC | 2 ms | 3556 KB |
random_12.txt | AC | 2 ms | 3624 KB |
random_13.txt | AC | 3 ms | 3520 KB |
random_14.txt | AC | 2 ms | 3576 KB |
random_15.txt | AC | 2 ms | 3524 KB |
random_16.txt | AC | 2 ms | 3588 KB |
random_17.txt | AC | 2 ms | 3604 KB |
random_18.txt | AC | 2 ms | 3556 KB |
random_19.txt | AC | 2 ms | 3524 KB |
random_20.txt | AC | 2 ms | 3608 KB |
random_21.txt | AC | 2 ms | 3628 KB |
random_22.txt | AC | 1 ms | 3528 KB |
random_23.txt | AC | 2 ms | 3632 KB |
random_24.txt | AC | 2 ms | 3636 KB |
random_25.txt | AC | 2 ms | 3636 KB |
random_26.txt | AC | 2 ms | 3616 KB |
random_27.txt | AC | 2 ms | 3576 KB |
random_28.txt | AC | 3 ms | 3556 KB |
random_29.txt | AC | 2 ms | 3608 KB |
random_30.txt | AC | 2 ms | 3544 KB |
random_31.txt | AC | 1 ms | 3616 KB |
random_32.txt | AC | 2 ms | 3588 KB |
sample_01.txt | AC | 2 ms | 3540 KB |
sample_02.txt | AC | 2 ms | 3592 KB |