日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

2019牛客暑期多校训练营(第七场)A String(暴力)

發(fā)布時(shí)間:2024/4/15 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2019牛客暑期多校训练营(第七场)A String(暴力) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

鏈接:https://ac.nowcoder.com/acm/contest/887/A
來(lái)源:牛客網(wǎng)

題目描述

A string is perfect if it has the smallest lexicographical ordering among its cyclic rotations.
For example: "0101" is perfect as it is the smallest string among ("0101", "1010", "0101", "1010").

Given a 01 string, you need to split it into the least parts and all parts are perfect.

輸入描述:

The first line of the input gives the number of test cases, T?(T≤300)T\ (T \leq 300)T?(T300). test cases follow.

For each test case, the only line contains one non-empty 01 string. The length of string is not exceed 200.

輸出描述:

For each test case, output one string separated by a space. 示例1

輸入

復(fù)制 4 0 0001 0010 111011110

輸出

復(fù)制 0 0001 001 0 111 01111 0 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <cstdlib> #include <queue> #include <stack> #include <vector> using namespace std; #define MAXN 100010 #define ll long longint t; string s;bool minma(string x) {int len = x.size();for(int i = 1; i < len; i++)for(int j = 0; j < len; j++){if(x[j] < x[(j + i) % len])break;else if(x[j] > x[(j + i) % len])return false;}return true; }int main() {cin>>t;while(t--){cin>>s;int len = s.size();int i = 0;while(i < len){for(int j = len - i; j > 0; j--){if(minma(s.substr(i, j))){cout<<s.substr(i, j);i += j;if(i < len)printf(" ");break;}}}printf("\n");}return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/RootVount/p/11355976.html

總結(jié)

以上是生活随笔為你收集整理的2019牛客暑期多校训练营(第七场)A String(暴力)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。