牛客 - Dance with a stick(大风车模型)
生活随笔
收集整理的這篇文章主要介紹了
牛客 - Dance with a stick(大风车模型)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接:點擊查看
題目大意:二維平面給出 nnn 個點,滿足任意三個點不在一條直線上。需要選出一條經過某個點的有向直線,滿足執行 “大風車” 后直線的角度反轉到 180180180 度時,回到初始的起點
“大風車” 指的是直線順時針旋轉,若碰到了某個點 ppp,則以點 ppp 為新的軸心繼續旋轉,持續這個過程
題目分析:解析該模型的視頻:https://www.bilibili.com/video/BV164411k7e3
省流結論:找到一條經過某個點的直線,使得左右兩側的點個數相同
代碼:
// Problem: Dance with a stick // Contest: NowCoder // URL: https://ac.nowcoder.com/acm/contest/17148/E // Memory Limit: 1048576 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org)// #pragma GCC optimize(2) // #pragma GCC optimize("Ofast","inline","-ffast-math") // #pragma GCC target("avx,sse2,sse3,sse4,mmx") #include<iostream> #include<cstdio> #include<string> #include<ctime> #include<cmath> #include<cstring> #include<algorithm> #include<stack> #include<climits> #include<queue> #include<map> #include<set> #include<sstream> #include<cassert> #include<bitset> #include<list> #include<unordered_map> #define lowbit(x) x&-x using namespace std; typedef long long LL; typedef unsigned long long ull; template<typename T> inline void read(T &x) {T f=1;x=0;char ch=getchar();while(0==isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(0!=isdigit(ch)) x=(x<<1)+(x<<3)+ch-'0',ch=getchar();x*=f; } template<typename T> inline void write(T x) {if(x<0){x=~(x-1);putchar('-');}if(x>9)write(x/10);putchar(x%10+'0'); } const int inf=0x3f3f3f3f; const int N=1e6+100; pair<int,int>node[N]; int main() { #ifndef ONLINE_JUDGE // freopen("data.in.txt","r",stdin); // freopen("data.out.txt","w",stdout); #endif // ios::sync_with_stdio(false);int n;read(n);for(int i=1;i<=n;i++) {read(node[i].first),read(node[i].second);}if(n&1) {puts("Yes");} else {return 0*puts("No");}sort(node+1,node+1+n);cout<<node[(n+1)/2].first<<' '<<node[(n+1)/2].second<<' '<<-1<<' '<<(int)1e9<<endl;return 0; }總結
以上是生活随笔為你收集整理的牛客 - Dance with a stick(大风车模型)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 牛客 - Alice and Bob(尺
- 下一篇: 牛客 - Connie(AC自动机+dp