답안 #25814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25814 2017-06-24T08:07:28 Z 김동현(#1079) 별자리 2 (JOI14_constellation2) C++14
15 / 100
163 ms 2020 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, x[33], y[33], c[33], ans;
vector<int> v[3];

int ccw(int a, int b, int c){
	ll x1 = x[b] - x[a], y1 = y[b] - y[a];
	ll x2 = x[c] - x[b], y2 = y[c] - y[b];
	ll t = x1 * y2 - y1 * x2;
	return (t < 0) ? -1 : (t > 0) ? 1 : 0;
}

int in(int x, int a, int b, int c){
	int c1 = ccw(a, b, x), c2 = ccw(b, c, x), c3 = ccw(c, a, x);
	return (c1 <= 0 && c2 <= 0 && c3 <= 0) ||
		   (c1 >= 0 && c2 >= 0 && c3 >= 0);
}

int ncr(int a, int b, int c, int d){
	int c1 = ccw(a, b, c), c2 = ccw(a, b, d);
	int d1 = ccw(c, d, a), d2 = ccw(c, d, b);
	return (c1 * c2 > 0) || (d1 * d2 > 0);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d%d%d", x + i, y + i, c + i);
		v[c[i]].push_back(i);
	}
	for(auto &i1 : v[0]){
		for(auto &j1 : v[1]){
			for(auto &k1 : v[2]){
				for(auto &i2 : v[0]){
					for(auto &j2 : v[1]){
						for(auto &k2 : v[2]){
							if(!in(i2, i1, j1, k1) && !in(j2, i1, j1, k1) && !in(k2, i1, j1, k1) &&
							   !in(i1, i2, j2, k2) && !in(j1, i2, j2, k2) && !in(k1, i2, j2, k2) &&
							   ncr(i1, j1, i2, j2) && ncr(i1, j1, j2, k2) && ncr(i1, j1, k2, i2) &&
							   ncr(j1, k1, i2, j2) && ncr(j1, k1, j2, k2) && ncr(j1, k1, k2, i2) &&
							   ncr(k1, i1, i2, j2) && ncr(k1, i1, j2, k2) && ncr(k1, i1, k2, i2)) ans++;
						}
					}
				}
			}
		}
	}
	printf("%d\n", ans / 2);
}

Compilation message

constellation2.cpp: In function 'int main()':
constellation2.cpp:28:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
constellation2.cpp:30:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", x + i, y + i, c + i);
                                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 29 ms 2020 KB Output is correct
7 Correct 83 ms 2020 KB Output is correct
8 Correct 53 ms 2020 KB Output is correct
9 Correct 76 ms 2020 KB Output is correct
10 Correct 33 ms 2020 KB Output is correct
11 Correct 83 ms 2020 KB Output is correct
12 Correct 93 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 2020 KB Output is correct
2 Runtime error 0 ms 2020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 163 ms 2020 KB Output isn't correct
2 Halted 0 ms 0 KB -