Submission #112183
Source Code Expand
#include <iostream>//{{{
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <utility>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <memory>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cfloat>
#include <cassert>
#include <ctime>
#include <cctype>//}}}
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)//{{{
#define rep(i,n) REP(i,0,n)
#define repsz(i,v) rep(i,sz(v))
#define let(v, x) __typeof(x) v = (x)
#define foreach(i,v) for(let(i, (v).begin());i!=(v).end();i++)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size()) //}}}
using namespace std;//{{{
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;//}}}
template<typename T> ostream& out(T b, T e, ostream& os=cout){ //{{{
for(; b != e; ++b != e && os << ", ")os << *b; return os;
}
template<class T> T mineq(T &a, const T &b){ return a = min(a, b); }
template<class T> T maxeq(T &a, const T &b){ return a = max(a, b); } //}}}
// 幾何.//{{{
typedef long double R;
const R INF = 1E40;
const R EPS = 1E-11;
const R PI = acos(R(-1));
//typedef complex<R> P;
#define X real()
#define Y imag()
// for c++0x
struct P : complex<R>{
P(const R& a=0, const R& b=0){ this->X = a; this->Y = b; }
P(const complex<R>& p){ this->X = p.X; this->Y = p.Y; }
R& real(){ return reinterpret_cast<R(&)[2]>(*this)[0]; }
R& imag(){ return reinterpret_cast<R(&)[2]>(*this)[1]; }
R real()const{ return real(); }
R imag()const{ return imag(); }
};
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS); }
namespace std {//{{{
bool operator < (const P& a, const P& b) {
return sgn(a.X - b.X) ? a.Y < b.Y : a.X < b.X;
}
istream& operator >> (istream& is, P& p) {
is >> p.X >> p.Y;
return is;
}
}//}}}
typedef pair<P, P> L;
//}}}
// 基本.//{{{
inline R dot(const P& a, const P& b) { return real(conj(a)*b); }
inline R cross(const P& a, const P& b) { return imag(conj(a)*b); }
inline P vec(const L& l){ return l.snd - l.fst; }
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16, };
inline int rev_ccw(const P& a, P b, P c){//{{{
b -= a; c -= a;
R cr = cross(c, b);
if(sgn(cr)) return cr > 0 ? RIGHT : LEFT;
if(sgn(dot(c, b)) < 0) return BACK;
if(sgn(norm(c) - norm(b)) < 0) return FRONT;
return ON;
}//}}}
inline int ccw(const L& l, const P& p){//{{{
int res = rev_ccw(l.fst, p, l.snd);
if(res & RIGHT) return LEFT;
if(res & LEFT) return RIGHT;
return res;
}//}}}
//}}}
// 点, 直線, 線分.//{{{
// 平行, 同一直線判定.//{{{
inline bool sameL(const L& l, const L& m){
return sgn(cross(vec(l), vec(m))) == 0 && sgn(cross(vec(l), m.fst-l.fst)) == 0;
}
// AOJ 0021
inline bool paraL(const L& l, const L& m){
return sgn(cross(vec(l), vec(m))) == 0;
}
//}}}
// 交差判定.//{{{
// iLS は <= を < にすれば strict に.
// iSS は ON 判定を消せば strict に.
inline bool iLL(const L& l, const L& m){
return sameL(l, m) || sgn(cross(vec(l), vec(m))) != 0;
}
inline bool iLS(const L& l, const L& s){
return sgn(cross(vec(l), s.fst-l.fst)) * sgn(cross(vec(l), s.snd-l.fst)) <= 0;
}
inline bool iLSs(const L& l, const L& s){
return sgn(cross(vec(l), s.fst-l.fst)) * sgn(cross(vec(l), s.snd-l.fst)) < 0;
}
inline bool iLP(const L& l, const P& p){ return ccw(l, p) & (FRONT | BACK | ON); }
inline bool iSP(const L& s, const P& p){ return ccw(s, p) & ON; }
// AOJ 2402, AOJ 1157, AOJ 1183, AOJ 1171
inline bool iSS(const L& s, const L& t){
int cw1 = ccw(s, t.fst) | ccw(s, t.snd);
int cw2 = ccw(t, s.fst) | ccw(t, s.snd);
return ((cw1 | cw2) & ON) || ((cw1 & cw2) == (LEFT | RIGHT));
}
// AOJ 2009, AOJ 1171, AOJ 2514
inline bool iSSs(const L& s, const L& t){
int cw1 = ccw(s, t.fst) | ccw(s, t.snd);
int cw2 = ccw(t, s.fst) | ccw(t, s.snd);
return ((cw1 & cw2) == (LEFT | RIGHT));
}
//}}}
// 距離.//{{{
// AOJ 0153, AOJ 2402, AOJ 1157, AOJ 2009
inline R dPP(const P& p, const P& q){ return abs(p - q); }
// AOJ 2402
inline R dLP(const L& l, const P& p){
if(!(ccw(l, p) & (LEFT | RIGHT))) return 0; // for "-0"
return abs(cross(vec(l), p - l.fst)) / abs(vec(l));
}
// AOJ 0153, AOJ 2402, AOJ 1157
inline R dSP(const L& s, const P& p){
if(sgn(dot( vec(s), p - s.fst)) <= 0) return dPP(p, s.fst);
if(sgn(dot(-vec(s), p - s.snd)) <= 0) return dPP(p, s.snd);
return dLP(s, p);
}
inline R dLL(const L& l, const L& m){
return iLL(l, m) ? 0 : dLP(l, m.fst);
}
inline R dLS(const L& l, const L& s){
return iLS(l, s) ? 0 : min(dLP(l, s.fst), dLP(l, s.snd));
}
// AOJ 2402, AOJ 1157, AOJ 2514
inline R dSS(const L& s, const L& t){
return iSS(s, t) ? 0 :
min( min(dSP(s, t.fst), dSP(s, t.snd)),
min(dSP(t, s.fst), dSP(t, s.snd)));
}
//}}}
// 交点, 射影, 反射.//{{{
// AOJ 2009
inline P pLL(const L& l, const L& m){
if(sameL(l, m)) return l.fst;
// if(paraL(l, m)) assert(false);
R A = cross(vec(m), vec(l));
R B = cross(vec(m), m.snd - l.fst);
return l.fst + B / A * vec(l);
}
// p から l に下ろした垂線の足.
inline P hLP(const L& l, const P& p){
return l.fst + dot(p - l.fst, vec(l)) / norm(vec(l)) * vec(l);
}
// p の l で対称な点.
// AOJ 0081, AOJ 1171, AOJ 2514
inline P refLP(const L& l, const P& p){
return R(2) * hLP(l, p) - p;
}
//}}}
//}}}
// ccw 多角形.//{{{
// 全て counter clock wise で扱う. ccw か不明なら, sgn(area) >= 0 で check.
typedef vector<P> Poly;
#define Mod(a, m) ((a%m+m)%m)
#define prev(P, i) P[Mod(i-1, P.size())]
#define curr(P, i) P[Mod( i , P.size())]
#define next(P, i) P[Mod(i+1, P.size())]
// ccw 符号付き面積.//{{{
// AOJ 1100, AOJ 2160, AOJ 0079
R area(const Poly& pol){
R res(0);
repsz(i, pol) res += cross(curr(pol, i), next(pol, i));
return res / 2.0;
}
//}}}
//}}}
bool solve(){
Poly pol(3);
rep(i, 3) cin >> pol[i];
cout << area(pol) << endl;
return true;
}
int main(){
//cin.tie(0);
//ios_base::sync_with_stdio(0);
cout.setf(ios::fixed); cout.precision(10);
solve();
return 0;
}
// vim:set foldmethod=marker commentstring=//%s:
Submission Info
Submission Time |
|
Task |
C - 直訴 |
User |
MiSawa |
Language |
C++ (G++ 4.6.4) |
Score |
0 |
Code Size |
6767 Byte |
Status |
WA |
Exec Time |
24 ms |
Memory |
936 KB |
Judge Result
Set Name |
all |
Score / Max Score |
0 / 100 |
Status |
|
Set Name |
Test Cases |
all |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt, test_61.txt, test_62.txt, test_63.txt, test_64.txt, test_65.txt, test_66.txt, test_67.txt, test_68.txt, test_69.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_01.txt |
AC |
22 ms |
804 KB |
00_sample_02.txt |
WA |
20 ms |
800 KB |
00_sample_03.txt |
AC |
20 ms |
800 KB |
test_01.txt |
WA |
21 ms |
796 KB |
test_02.txt |
AC |
22 ms |
740 KB |
test_03.txt |
WA |
20 ms |
804 KB |
test_04.txt |
AC |
22 ms |
800 KB |
test_05.txt |
AC |
24 ms |
928 KB |
test_06.txt |
AC |
22 ms |
736 KB |
test_07.txt |
AC |
22 ms |
928 KB |
test_08.txt |
WA |
22 ms |
928 KB |
test_09.txt |
WA |
22 ms |
732 KB |
test_10.txt |
WA |
21 ms |
676 KB |
test_11.txt |
WA |
23 ms |
808 KB |
test_12.txt |
AC |
22 ms |
804 KB |
test_13.txt |
AC |
21 ms |
804 KB |
test_14.txt |
WA |
21 ms |
796 KB |
test_15.txt |
WA |
22 ms |
804 KB |
test_16.txt |
WA |
22 ms |
808 KB |
test_17.txt |
AC |
20 ms |
800 KB |
test_18.txt |
AC |
24 ms |
756 KB |
test_19.txt |
WA |
22 ms |
928 KB |
test_20.txt |
AC |
21 ms |
920 KB |
test_21.txt |
AC |
22 ms |
800 KB |
test_22.txt |
AC |
21 ms |
932 KB |
test_23.txt |
WA |
23 ms |
928 KB |
test_24.txt |
WA |
21 ms |
800 KB |
test_25.txt |
WA |
21 ms |
804 KB |
test_26.txt |
WA |
20 ms |
928 KB |
test_27.txt |
WA |
20 ms |
796 KB |
test_28.txt |
AC |
23 ms |
756 KB |
test_29.txt |
WA |
22 ms |
800 KB |
test_30.txt |
AC |
22 ms |
804 KB |
test_31.txt |
AC |
21 ms |
932 KB |
test_32.txt |
AC |
21 ms |
804 KB |
test_33.txt |
AC |
21 ms |
800 KB |
test_34.txt |
WA |
21 ms |
800 KB |
test_35.txt |
AC |
21 ms |
924 KB |
test_36.txt |
AC |
21 ms |
800 KB |
test_37.txt |
AC |
22 ms |
932 KB |
test_38.txt |
WA |
20 ms |
800 KB |
test_39.txt |
AC |
21 ms |
804 KB |
test_40.txt |
AC |
22 ms |
932 KB |
test_41.txt |
WA |
22 ms |
800 KB |
test_42.txt |
WA |
21 ms |
796 KB |
test_43.txt |
WA |
22 ms |
800 KB |
test_44.txt |
WA |
21 ms |
804 KB |
test_45.txt |
AC |
20 ms |
796 KB |
test_46.txt |
AC |
22 ms |
808 KB |
test_47.txt |
WA |
21 ms |
800 KB |
test_48.txt |
WA |
20 ms |
800 KB |
test_49.txt |
AC |
21 ms |
796 KB |
test_50.txt |
WA |
22 ms |
932 KB |
test_51.txt |
AC |
22 ms |
804 KB |
test_52.txt |
WA |
22 ms |
800 KB |
test_53.txt |
AC |
21 ms |
800 KB |
test_54.txt |
AC |
24 ms |
864 KB |
test_55.txt |
WA |
21 ms |
804 KB |
test_56.txt |
AC |
21 ms |
804 KB |
test_57.txt |
AC |
21 ms |
936 KB |
test_58.txt |
WA |
21 ms |
800 KB |
test_59.txt |
WA |
22 ms |
804 KB |
test_60.txt |
WA |
20 ms |
804 KB |
test_61.txt |
WA |
21 ms |
848 KB |
test_62.txt |
WA |
22 ms |
928 KB |
test_63.txt |
AC |
21 ms |
932 KB |
test_64.txt |
WA |
21 ms |
800 KB |
test_65.txt |
AC |
22 ms |
808 KB |
test_66.txt |
AC |
22 ms |
924 KB |
test_67.txt |
WA |
21 ms |
804 KB |
test_68.txt |
AC |
20 ms |
804 KB |
test_69.txt |
AC |
21 ms |
740 KB |