Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #define LL long long
- using namespace std;
- ifstream f("episodul2.in");
- ofstream g("episodul2.out");
- typedef struct
- {
- int x,y;
- } PUNCT;
- PUNCT p[200001];
- int vf;
- bool cp(PUNCT A,PUNCT B,PUNCT C)
- {
- LL v=1LL*(B.y-A.y)*(C.x-A.x)-1LL*(B.x-A.x)*(C.y-A.y);
- return v<0;
- }
- int main()
- {
- int m,ev;
- PUNCT pc;
- LL aria;
- f>>m;
- while(m--)
- {
- f>>ev;
- if(ev==1)
- {
- f>>pc.x>>pc.y;
- while(cp(p[vf-1],p[vf],pc))
- --vf;
- ++vf,p[vf].x=pc.x,p[vf].y=pc.y;
- }
- else
- {
- /*
- for(int i=1;i<=vf;++i)
- g<<p[i].x<<" "<<p[i].y<<endl;
- */
- aria=0;
- for(int i=2;i<=vf;++i)
- aria+=(unsigned long long)(p[i].y+p[i-1].y)*(unsigned long long)(p[i].x-p[i-1].x);
- int rest=aria%2;
- g<<aria/2;
- if(rest==1)
- g<<".5\n";
- else
- g<<'\n';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement