QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226165 | #77. Dazzling Stars | 4k2kok | WA | 1ms | 3464kb | C++20 | 2.1kb | 2023-10-25 17:18:31 | 2023-10-25 17:18:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(a,b) memset((a),(b),sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
#define int long long
#define db long double
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
struct node {
int x, y, w;
};
struct point{
int x, y;
};
int cross(int x1, int y1, int x2, int y2)//计算叉积
{
return (x1*y2-x2*y1);
}
bool compare(point a,point b)//计算极角
{
if (cross((b.x-a.x),(b.y-a.y),(-a.x),(-a.y)) == 0) return a.x < b.x;
return (cross((b.x-a.x),(b.y-a.y),(-a.x),(-a.y)) > 0);
}
void solve() {
int n;
vector<node>p;
cin >> n;
for(int i = 1; i <= n; i++) {
int a, b, c;
cin >> a >> b >> c;
p.push_back({a, b, c});
}
vector<point>v;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(i == j) continue;
if(p[i].w > p[j].w) {
int a = p[j].x - p[i].x;
int b = p[j].y - p[i].y;
if(a == 0) b = 1;
else if(b == 0) a = 1;
else {
int g = __gcd(a, b);
a /= g;
b /= g;
}
v.push_back({a, b});
}
}
}
int flag = 0;
// for(int i = 0; i < v.size(); i++) {
// cout << v[i].x << " " << v[i].y << '\n';
// }
sort(v.begin(), v.end(), compare);
// for(int i = 0; i < v.size(); i++) {
// cout << v[i].x << " " << v[i].y << '\n';
// }
if(v.size() <= 2) {
cout << "Y\n";
return;
}
for(int i = 0; i < v.size(); i++) {
if(v[i].x == v[0].x && v[i].y == v[0].y) continue;
if(cross(v[0].x, v[0].y, v[i].x, v[i].y) <= 0) flag = 1;
}
if(flag) cout << "Y\n";
else cout << "N\n";
}
signed main(){
io;
int T = 1;
//cin >> T;
while(T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3464kb
input:
4 2 2 1 2 5 2 5 5 3 5 2 4
output:
N
result:
wrong answer 1st lines differ - expected: 'Y', found: 'N'