Submission #3424841
Source Code Expand
#include <iostream> #include <string.h> #include <stdio.h> #include <map> #include <vector> #include <math.h> #include <algorithm> #include <queue> #include <set> #include <tuple> using namespace std; #define rep(i,a) for(int i=0; i<a; i++) #define rrep(i,a) for(int i=a; i>=0; i--) #define rep1(i,a) for(int i=1; i<=a; i++) #define cout1(a) cout << a << endl; #define cout2(a,b) cout << a << " " << b << endl; #define cout3(a,b,c) cout << a << " " << b << " " << c << endl; #define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl; #define mem(a,n) memset( a, n, sizeof(a)) #define all(a) a.begin(),a.end() typedef long long ll; typedef pair<int,int> pii; typedef vector<int> V; typedef vector<V> VV; typedef vector<VV> VVV; const int INF = 1e9; const int MOD = 1e9+7; const ll LLINF = 1e18; static const double pi = 3.141592653589793; class Types_triangles{ public: int n; vector<int> y,x; const double EPS = 1e-10; ll cnt_chokaku=0, cnt_donkaku=0, cnt_eikaku=0; Types_triangles(const vector<int> &ty, const vector<int> &tx, int size):y(ty),x(tx),n(size){count();} private: void count(){ rep(i,n){ vector<double> angle; rep(j,n){ if(j==i) continue; angle.push_back(atan2(y[j] - y[i], x[j] - x[i])); } sort(all(angle)); rep(j,n-1){ angle.push_back(angle[j] + M_PI*2); } rep(j,n-1){ cnt_chokaku += upper_bound(angle.begin(), angle.end(), angle[j] + M_PI/2.0 + EPS) - lower_bound(angle.begin(), angle.end(), angle[j] + M_PI/2.0 - EPS); cnt_donkaku += lower_bound(angle.begin(), angle.end(), angle[j] + M_PI) - upper_bound(angle.begin(), angle.end(), angle[j] + M_PI/2.0 + EPS); } } cnt_eikaku = (ll)n * (n-1) * (n-2)/6 - cnt_chokaku - cnt_donkaku; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin>>N; vector<int> Y(N), X(N); rep(i,N) cin>>X[i]>>Y[i]; Types_triangles t(Y,X,N); cout3(t.cnt_eikaku, t.cnt_chokaku, t.cnt_donkaku); }
Submission Info
Submission Time | |
---|---|
Task | D - 三角形の分類 |
User | mensan_fukuhara |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 2314 Byte |
Status | AC |
Exec Time | 880 ms |
Memory | 512 KB |
Judge Result
Set Name | sample | subtask01 | subtask02 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 30 / 30 | 70 / 70 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
subtask01 | 01-00.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-handmade00.txt, 01-handmade01.txt, 01-handmade02.txt, 01-handmade03.txt, 01-handmade04.txt, 01-handmade05.txt, sample-01.txt, sample-02.txt |
subtask02 | 01-00.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-handmade00.txt, 01-handmade01.txt, 01-handmade02.txt, 01-handmade03.txt, 01-handmade04.txt, 01-handmade05.txt, 02-00.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt, 02-handmade00.txt, 02-handmade01.txt, 02-handmade02.txt, 02-handmade03.txt, 02-handmade04.txt, 02-handmade05.txt, sample-01.txt, sample-02.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-00.txt | AC | 2 ms | 512 KB |
01-01.txt | AC | 2 ms | 512 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 1 ms | 256 KB |
01-06.txt | AC | 1 ms | 256 KB |
01-07.txt | AC | 3 ms | 256 KB |
01-08.txt | AC | 3 ms | 256 KB |
01-09.txt | AC | 3 ms | 256 KB |
01-10.txt | AC | 3 ms | 256 KB |
01-11.txt | AC | 3 ms | 256 KB |
01-12.txt | AC | 3 ms | 256 KB |
01-13.txt | AC | 3 ms | 256 KB |
01-14.txt | AC | 3 ms | 256 KB |
01-15.txt | AC | 3 ms | 256 KB |
01-16.txt | AC | 3 ms | 256 KB |
01-17.txt | AC | 3 ms | 256 KB |
01-18.txt | AC | 3 ms | 256 KB |
01-19.txt | AC | 3 ms | 256 KB |
01-handmade00.txt | AC | 2 ms | 256 KB |
01-handmade01.txt | AC | 3 ms | 256 KB |
01-handmade02.txt | AC | 2 ms | 256 KB |
01-handmade03.txt | AC | 3 ms | 256 KB |
01-handmade04.txt | AC | 3 ms | 256 KB |
01-handmade05.txt | AC | 3 ms | 256 KB |
02-00.txt | AC | 9 ms | 256 KB |
02-01.txt | AC | 33 ms | 256 KB |
02-02.txt | AC | 33 ms | 256 KB |
02-03.txt | AC | 103 ms | 256 KB |
02-04.txt | AC | 103 ms | 256 KB |
02-05.txt | AC | 103 ms | 256 KB |
02-06.txt | AC | 213 ms | 256 KB |
02-07.txt | AC | 213 ms | 256 KB |
02-08.txt | AC | 213 ms | 256 KB |
02-09.txt | AC | 212 ms | 256 KB |
02-10.txt | AC | 213 ms | 256 KB |
02-11.txt | AC | 213 ms | 256 KB |
02-12.txt | AC | 214 ms | 256 KB |
02-13.txt | AC | 876 ms | 384 KB |
02-14.txt | AC | 878 ms | 384 KB |
02-15.txt | AC | 877 ms | 384 KB |
02-16.txt | AC | 879 ms | 384 KB |
02-17.txt | AC | 876 ms | 384 KB |
02-18.txt | AC | 878 ms | 384 KB |
02-19.txt | AC | 875 ms | 384 KB |
02-handmade00.txt | AC | 410 ms | 384 KB |
02-handmade01.txt | AC | 877 ms | 384 KB |
02-handmade02.txt | AC | 485 ms | 384 KB |
02-handmade03.txt | AC | 877 ms | 384 KB |
02-handmade04.txt | AC | 880 ms | 384 KB |
02-handmade05.txt | AC | 878 ms | 384 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |