This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define LINF 1023456789123456789
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,int> li;
typedef long double ld;
#define maxn 3005
int n,m,a[maxn],b[maxn],c[maxn],ans[maxn][maxn];
int d1,e1,d2,e2;
ld get(ll a1,ll b1,ll a2,ll b2,ll d1,ll e1,ll d2,ll e2){
return (ld)((a2-a1)*(b1-e1)+(b2-b1)*(d1-a1))/((e2-e1)*(a2-a1)-(b2-b1)*(d2-d1));
}
int main(){
sf("%d%d",&n,&m);
for(int i=1;i<=n;++i){
sf("%d%d%d",&a[i],&b[i],&c[i]);
}
sf("%d%d%d%d",&d1,&e1,&d2,&e2);
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j){
if(i==j)continue;
ld mu=get(a[i],b[i],a[j],b[j],d1,e1,d2,e2);
ld la=get(d1,e1,d2,e2,a[i],b[i],a[j],b[j]);
if(0<=mu&&mu<=1&&la>0)++ans[c[i]][c[j]];
}
}
int q;sf("%d",&q);
for(int i=0;i<q;++i){
int f,g;sf("%d%d",&f,&g);
pf("%d\n",ans[f][g]);
}
}
Compilation message (stderr)
dragon2.cpp: In function 'int main()':
dragon2.cpp:27:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | sf("%d%d",&n,&m);
| ^
dragon2.cpp:29:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
29 | sf("%d%d%d",&a[i],&b[i],&c[i]);
| ^
dragon2.cpp:31:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | sf("%d%d%d%d",&d1,&e1,&d2,&e2);
| ^
dragon2.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | int q;sf("%d",&q);
| ^
dragon2.cpp:42:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | int f,g;sf("%d%d",&f,&g);
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |