Submission #72277

#TimeUsernameProblemLanguageResultExecution timeMemory
72277신딩없는 신딩팀 (#118)Hill Reconstruction (FXCUP3_hill)C++17
32 / 100
642 ms37496 KiB
#include <stdio.h> #include <queue> #include <set> #include <algorithm> #define LL long long #define pll pair<LL,LL> #define x first #define y second using namespace std; pll cor[333333]; struct tani{ LL idx1,idx2; bool operator<(const tani A)const{ return (cor[idx2].y-cor[idx1].y)*(cor[A.idx2].x-cor[A.idx1].x)>(cor[A.idx2].y-cor[A.idx1].y)*(cor[idx2].x-cor[idx1].x); } }; set<tani> stt; set<LL> sti; LL gcd(LL x,LL y){ return y?gcd(y,x%y):x; } LL tri(LL i,LL j,LL k){ return abs(cor[i].x*cor[j].y+cor[j].x*cor[k].y+cor[k].x*cor[i].y-cor[j].x*cor[i].y-cor[k].x*cor[j].y-cor[i].x*cor[k].y); } int main(){ LL n,c; scanf("%lld %lld",&n,&c); c<<=1; for(LL i=1;i<=n;i++) scanf("%lld",&cor[i].x); for(LL i=1;i<=n;i++) scanf("%lld",&cor[i].y); for(LL i=1;i<n;i++) stt.insert({i,i+1}); for(LL i=1;i<=n;i++) sti.insert(i); while(1){ LL idx1=(stt.begin())->idx1; LL idx2=(stt.begin())->idx2; set<LL>::iterator it=sti.find(idx1); // printf("%d %d %lld\n",idx1,idx2,c); if(it==sti.begin()){ LL g=gcd(cor[idx2].y-cor[idx1].y,cor[idx2].x-cor[idx1].x); printf("%lld/%lld",(cor[idx2].y-cor[idx1].y)/g,(cor[idx2].x-cor[idx1].x)/g); return 0; } LL idx0=*(--it); LL siz=tri(idx0,idx1,idx2); // printf("%d %d %d %lld %lld\n",idx0,idx1,idx2,c,siz); if(c>=siz) c-=siz; else{ LL g=gcd(cor[idx2].y-cor[idx1].y,cor[idx2].x-cor[idx1].x); printf("%lld/%lld",(cor[idx2].y-cor[idx1].y)/g,(cor[idx2].x-cor[idx1].x)/g); return 0; } stt.erase({idx0,idx1}); stt.erase({idx1,idx2}); sti.erase(idx1); stt.insert({idx0,idx2}); } return 0; }

Compilation message (stderr)

hill.cpp: In function 'int main()':
hill.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&n,&c); c<<=1;
     ~~~~~^~~~~~~~~~~~~~~~~~~
hill.cpp:36:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(LL i=1;i<=n;i++) scanf("%lld",&cor[i].x);
                          ~~~~~^~~~~~~~~~~~~~~~~~
hill.cpp:37:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(LL i=1;i<=n;i++) scanf("%lld",&cor[i].y);
                          ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...