Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

洪水

Posted by KatrineYang at 2016-07-16 10:19:59 on Problem 1107
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
	int k1, k2, k3;
	string s;
	while(cin >> k1 >> k2 >> k3){
		vector<int> v1, v2, v3;
		if(k1 + k2 + k3 == 0) break;
		cin >> s;
		int len = s.length();
		for(int i = 0; i < len; i++){
			if(s[i] >= 'a' && s[i] <= 'i') v1.push_back(i);
			else if(s[i] >= 'j' && s[i] <= 'r') v2.push_back(i);
			else v3.push_back(i);
		}
		int z1 = v1.size(), z2 = v2.size(), z3 = v3.size();
		char c[200];
		for(int i = 0; i < z1; i++) c[v1[(i+k1)%z1]] = s[v1[i]];
		for(int i = 0; i < z2; i++) c[v2[(i+k2)%z2]] = s[v2[i]];
		for(int i = 0; i < z3; i++) c[v3[(i+k3)%z3]] = s[v3[i]];
		for(int i = 0; i < len; i++) cout << c[i];
		cout << endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator