이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Be name khoda //
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<ll> point;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
const int maxn5 = 4e3 + 10;
const int maxnt = 4e5 + 10;
point p[maxn5];
int cnt[maxn5][maxn5], ty[maxn5];
inline bool pari(ll a){
return a > 0;
}
inline ll crossz(point a, point b){
return real(a) * imag(b) - imag(a) * real(b);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, m, q; cin >> n >> m;
for(int i = 0; i < n; i++){
int x, y; cin >> x >> y >> ty[i];
p[i] = {x, y};
}
int x, y; cin >> x >> y;
point a = {x, y};
cin >> x >> y;
point b = {x, y};
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(ty[i] != ty[j]){
ll salp = crossz(p[i] - a, p[j] - p[i]), m = crossz(b - a, p[j] - p[i]);
ll sbet = crossz(p[i] - a, b - a);
//cout << i << ' ' << j << ' ' << salp << ' ' << sbet << ' ' << m << endl;
if(m == 0)
continue;
if((pari(salp) == pari(m) || salp == 0) && (pari(m) ? salp <= m : salp >= m) && (pari(sbet) == pari(m) || sbet == 0)){
cnt[ty[i]][ty[j]]++;
//cout << "we found " << i << ' ' << j << endl;
}
}
cin >> q;
for(int i = 0; i < q; i++){
int a, b; cin >> a >> b;
cout << cnt[a][b] << '\n';
}
}
/*
3 3 1
3 2 6
1 4 5
3 3
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |