-
Notifications
You must be signed in to change notification settings - Fork 1
/
flavius.cpp
72 lines (59 loc) · 1.51 KB
/
flavius.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// Created by arkezar on 26.07.15.
//
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[]) {
ifstream stream(argv[1]);
// ifstream stream("/home/arkezar/flavius");
string line;
string token;
vector<int> nums;
vector<int> people;
vector<int> executedOrder;
int n, m;
while (getline(stream, line)) {
istringstream ss(line);
while(getline(ss,token,',')){
nums.push_back(stoi(token));
}
n = nums[0];
m = nums[1];
for(int i = 0; i < n; i++){
people.push_back(i);
}
// for(auto a : people){
// cout << a << endl;
// }
int counter = 0;
int cur = 0;
while(executedOrder.size() != n) {
counter++;
if(counter % m == 0){
counter = 0;
executedOrder.push_back(people[cur]);
}
cur++;
if(cur % people.size() == 0) {
cur = 0;
for (const auto &e : executedOrder) {
auto it = find(people.begin(), people.end(), e);
if (it != people.end())
people.erase(it);
}
}
}
nums.clear();
people.clear();
for(const auto& e : executedOrder){
cout << e << " ";
}
cout << endl;
executedOrder.clear();
}
return 0;
}