zju2006Glass Beads(最小表示法)
//2142707 2010-04-06 09:45:21 Accepted 2006 C++ 0 184 Xredman #include <iostream> #include <string> using namespace std; /* 用最小表示法求字符串S的最小字典序 */ int MinRepresstation(string S) { int i = 0, j = 1, k = 0; int len = S.length(); S += S; while(i < len && j < len) { k = 0; while(k < len && S[i + k] == S[j + k]) k++; if(k >= len) break; if(S[i + k] > S[j + k]) i = max(i + k + 1, j + 1); else j = max(i + 1, j + k + 1); } return min(i ,j); } int main() { int T; string S; int beg, k, len; cin>>T; while(T--) { cin>>S; beg = MinRepresstation(S); cout<<beg + 1<<endl; } return 0; }
Sep 01, 2023 11:34:59 PM
West Bengal Board of Secondary Education is Going to Conduct the Formative (FA) and Summative Assessment (SA) in 6th, 7th, 8th, 9th class Examination. WBBSE is Responsible for Conducting Examinations for High Schools in the State. at Present more than thousands of Schools are affiliated with the Board, The Board headquarters is located in Kolkata Students appear every year in Examinations West Bengal 8th Class Model Paper 2024 conducted by the Board, WBBSE is a Board of Education for Public and Private Schools under the State Government of West Bengal, WBBSE Board will announce its High School Education 6th, 7th, 8th, 9th SA, FA Exam Scheduled Announced soon. West Bengal 6th, 7th, 8th, 9th Sample Paper 2024 are a blueprint of that appear in the main West Bengal Board High School Board Exam. These Exam Papers are Created by Subject matter experts and are based on the West Bengal 6th, 7th, 8th, 9th Question Paper 2024,