Submission #128821

#TimeUsernameProblemLanguageResultExecution timeMemory
128821baluteshihDragon 2 (JOI17_dragon2)C++14
0 / 100
3135 ms2168 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define ET cout << "\n" #define ALL(v) v.begin(),v.end() #define MP make_pair #define F first #define S second #define MEM(i,j) memset(i,j,sizeof i) #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; const int B=200; int bit[30005]; vector<pii> v[30005]; int Q(pii x) { if(x.F<=0&&x.S<0) return 1; if(x.F>0&&x.S<=0) return 2; if(x.F>=0&&x.S>0) return 3; return 4; } bool yee(pii a,pii b) { if(Q(a)!=Q(b)) return Q(a)<Q(b); return (ll)a.S*b.F<(ll)b.S*a.F; } bool yee2(pair<pii,pii> a,pair<pii,pii> b) { return yee(a.F,b.F); } bool yee3(pii a,pii b) { return !yee(a,b)&&!yee(b,a); } vector<pii> tb[30005]; pii operator-(const pii &a,const pii &b){return MP(a.F-b.F,a.S-b.S);} ll cross(pii a,pii b){return (ll)a.F*b.S-(ll)b.F*a.S;} ll dot(pii a,pii b){return (ll)a.F*b.F+(ll)a.S*b.S;} int ori(pii a,pii b,pii c) { int rt=cross(b-a,c-a); if(rt==0) return rt; return rt>0?1:-1; } ll ans[100005],m; int main() {jizz int n,q,x,y,c; pii a,b; cin >> n >> m; for(int i=0;i<n;++i) cin >> x >> y >> c,tb[c].pb(MP(x,y)); cin >> a.F >> a.S >> b.F >> b.S >> q; if(a>b) swap(a,b); for(int i=0;i<q;++i) { cin >> x >> y; int as=0; for(auto j:tb[x]) for(auto k:tb[y]) if(ori(j,a,k)==ori(j,k,b)&&ori(j,a,k)==ori(j,a,b)) ++as; cout << as << "\n"; } } /* 4 2 0 1 1 0 -1 1 1 2 2 -6 1 2 -2 0 2 0 2 1 2 2 1 3 2 -1000000000 -1 1 -999999998 -1 1 0 0 2 999999997 1 999999999 1 1 1 2 6 3 2 -1 1 1 0 1 0 3 2 2 4 2 5 4 3 3 9 3 0 0 3 3 6 1 2 1 3 2 1 2 3 3 1 3 2 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...