日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

POJ - 1509 Glass Beads

發布時間:2025/6/17 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 POJ - 1509 Glass Beads 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

傳送門

最小表示法模板

//Achen #include<algorithm> #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #include<vector> #include<queue> #include<cmath> #include<ctime> const int N=100007; typedef long long LL; using namespace std; int T,n; char s[N]; template<typename T> void read(T &x) {T f=1; x=0; char ch=getchar();while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();if(ch=='-') f=-1,ch=getchar();for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f; }int solve() {int i=0,j=1,k=0;for(;i<n&&j<n&&k<n;) {int t=s[(i+k)%n]-s[(j+k)%n];if(!t) k++;else {if(t>0) i=i+k+1; else j=j+k+1;if(i==j) j++;k=0;}} return min(i,j); }int main() {read(T);while(T--) {scanf("%s",s);n=strlen(s);printf("%d\n",solve()+1);}return 0; } View Code

?

轉載于:https://www.cnblogs.com/Achenchen/p/8270413.html

總結

以上是生活随笔為你收集整理的POJ - 1509 Glass Beads的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。