# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
380892 |
2021-03-23T13:58:09 Z |
fl0rian |
Tri (CEOI09_tri) |
C++14 |
|
2000 ms |
8708 KB |
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000+10
#define rep(i,N) for(int i=0;i<N;i++)
int N,K;
typedef struct point{
int x;
int y;
point(int x1,int y1){
x=x1;
y=y1;
}
point(){
}
//pre : no points exactly on the line
bool isover(point * a,point * b){
//cout << "da ("<<a->x<<","<<a->y<<") " << "a ("<<b->x<<","<<b->y<<") \n";
int v1[2] = {b->x - a->x, b->y - a->y};
int v2[2] = {b->x - x, b->y - y};
int xp = v1[0]*v2[1] - v1[1]*v2[0];
return xp>0;
}
bool isunder(point * a,point * b){
return !isover(a,b);
}
} * P;
point origin(0,0);
typedef struct triangle{
point a;
point b;
bool isInside(point x){
return x.isover(&b,&origin) && x.isunder(&a,&origin) && x.isunder(&b,&a);
}
triangle(){
}
} * T;
vector<point> points(MAXN);
vector<triangle> triangles(MAXN);
bool solve(int t){
rep(i,N)
if(triangles[t].isInside(points[i]))
return true;
return false;
}
int ma2in(){
point a(0,0);
point b(1,1);
cout << "da ("<<a.x<<","<<a.y<<") " << "a ("<<b.x<<","<<b.y<<") \n";
point a3(1,2);
if(a3.isover(&b,&a))
cout<<"sopra";
else
cout<<"sotto";
}
int main(){
//freopen("in2.txt","r",stdin);
cin>>N>>K;
rep(i,N){
cin >> points[i].x>> points[i].y;
//cout << "("<<points[i].x<<","<<points[i].y<<") = " <<atan2(points[i].x,-points[i].y) << "\n";
}
rep(i,K){
int q,w,e,r;
cin>>q>>w>>e>>r;
triangles[i].a.x=q;
triangles[i].a.y=w;
triangles[i].b.x=e;
triangles[i].b.y=r;
}
rep(i,K)
cout<<(solve(i)?"Y":"N")<<"\n";
return 0;
}
Compilation message
tri.cpp: In function 'int ma2in()':
tri.cpp:73:1: warning: no return statement in function returning non-void [-Wreturn-type]
73 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
364 KB |
Output is correct |
2 |
Incorrect |
3 ms |
492 KB |
Output isn't correct |
3 |
Incorrect |
60 ms |
2412 KB |
Output isn't correct |
4 |
Incorrect |
111 ms |
3692 KB |
Output isn't correct |
5 |
Incorrect |
222 ms |
7140 KB |
Output isn't correct |
6 |
Execution timed out |
2086 ms |
6684 KB |
Time limit exceeded |
7 |
Execution timed out |
2070 ms |
8708 KB |
Time limit exceeded |
8 |
Incorrect |
223 ms |
7020 KB |
Output isn't correct |
9 |
Incorrect |
242 ms |
7916 KB |
Output isn't correct |
10 |
Incorrect |
269 ms |
8684 KB |
Output isn't correct |