View Code of Problem 3309

#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<string> res;
	queue<string> q;
	for(int i = 0;i < n;i ++) 
	{
		string s1;
		cin >> s1;
		res.push_back(s1);
	}
	int w, s;
	scanf("%d,%d",&w,&s);
	for(int i = w-1;i < res.size();i ++) q.push(res[i]);
	for(int i = 0;i < w-1;i ++) q.push(res[i]);
	int cnt = 1;
	while(1)
	{
		string str = q.front();
		q.pop();
		if(cnt == s)
		{
			cnt = 1;
			if(q.empty())
			{
				cout << str;
				break;
			} 
			else
			{
				cout << str << endl;
			}
		}
		else
		{
			cnt ++;
			q.push(str);
		}
	}
	return 0;
}
/*
Main.cc: In function 'int main()':
Main.cc:19: error: 'scanf' was not declared in this scope
*/

Double click to view unformatted code.


Back to problem 3309