-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa-10978.cpp
More file actions
39 lines (32 loc) · 1010 Bytes
/
UVa-10978.cpp
File metadata and controls
39 lines (32 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h> // here we have all the STL we need, including istringstream and ostringstream
#define ALL(x) x.begin(), x.end()
#define FAST std::cin.tie(0); ios::sync_with_stdio(false); std::cout.tie(0);
using namespace std;
#define endl "\n"
int main () {
FAST
int N;
string str1, str2;
while (cin >> N && N) {
vector<pair<string, string>> pairs;
string arr[N];
for (int i = 0; i < N; i++) {
cin >> str1 >> str2;
pairs.push_back(make_pair(str1, str2));
}
int currIndex = -1;
for (int i = 0; i < N; i++) {
string word = pairs[i].first;
int len = pairs[i].second.length();
while (len) {
currIndex = (1+currIndex) % N;
if (arr[currIndex] == "") len--;
}
arr[currIndex] = word;
}
for (int i = 0; i < N-1; i++) {
cout << arr[i] << " ";
}
cout << arr[N-1] << endl;
}
}