Submission #551894

#TimeUsernameProblemLanguageResultExecution timeMemory
551894LucaDantasDragon 2 (JOI17_dragon2)C++17
60 / 100
4054 ms3644 KiB
#include <bits/stdc++.h>
using namespace std;

constexpr int maxn = 30010;

struct Pt {
	int x, y;
	Pt(int _x = 0, int _y = 0) : x(_x), y(_y) {}
	long long operator/(const Pt& o) const { return 1ll * x * o.y - 1ll * y * o.x; }
	Pt operator-(const Pt& o) const { return Pt(x-o.x, y-o.y); }
};

bool cw(Pt a, Pt b, Pt c) { return (b-a)/(c-a) < 0; }
bool ccw(Pt a, Pt b, Pt c) { return (b-a)/(c-a) > 0; }

vector<Pt> tribe[maxn];

Pt v[2];

int main() {
	int n, m; scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++) {
		int a, b, t; scanf("%d %d %d", &a, &b, &t);
		tribe[t].push_back(Pt(a, b));
	}
	for(int i = 0; i < 2; i++) {
		int a, b; scanf("%d %d", &a, &b);
		v[i] = Pt(a, b);
	}
	int q; scanf("%d", &q);
	while(q--) {
		int a, b; scanf("%d %d", &a, &b);
		int ans = 0;
		for(Pt p1 : tribe[a]) {
			if(ccw(p1, v[0], v[1]))
				swap(v[0], v[1]);
			for(Pt p2 : tribe[b]) {
				ans += cw(p1, v[0], p2) && ccw(p1, v[1], p2);
			}
		}
		printf("%d\n", ans);
	}
}

Compilation message (stderr)

dragon2.cpp: In function 'int main()':
dragon2.cpp:21:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  int n, m; scanf("%d %d", &n, &m);
      |            ~~~~~^~~~~~~~~~~~~~~~~
dragon2.cpp:23:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   int a, b, t; scanf("%d %d %d", &a, &b, &t);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dragon2.cpp:27:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   int a, b; scanf("%d %d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~~
dragon2.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  int q; scanf("%d", &q);
      |         ~~~~~^~~~~~~~~~
dragon2.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   int a, b; scanf("%d %d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...