-
Notifications
You must be signed in to change notification settings - Fork 1
/
problem_guider.cpp
297 lines (287 loc) · 8.13 KB
/
problem_guider.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// #define MULTI_TEST
#ifdef LOCAL
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
out << '[' << p.first << ", " << p.second << ']';
return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
while (*name == ',' || *name == ' ')
name++;
std::cerr << name << " { ";
for (const auto &v : arg)
cerr << v << ' ';
cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
while (*names == ',' || *names == ' ')
names++;
const char *comma = strchr(names, ',');
std::cerr.write(names, comma - names) << " { ";
for (const auto &v : arg1)
cerr << v << ' ';
cerr << " }\n";
PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
const char *comma = strchr(names + 1, ',');
std::cerr.write(names, comma - names) << " = " << arg1;
ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
template <typename T>
using Random = std::uniform_int_distribution<T>;
const int NAX = 2e5 + 5, MOD = 1000000007;
class Solution
{
ifstream inFile;
ofstream outFile;
int belowCurr, belowTotal, belowLim;
int aboveCurr, aboveTotal, aboveLim;
int A2OJCurr, A2OJTotal, A2OJLim;
int AtCurr, AtTotal, AtLim;
int TcCurr, TcTotal, TcLim;
int myRating, cycleCount;
private:
void read()
{
// cout << "Read\n";
inFile.open("problem_status");
inFile >> myRating >> cycleCount;
inFile >> belowCurr >> belowTotal >> belowLim;
inFile >> aboveCurr >> aboveTotal >> aboveLim;
inFile >> A2OJCurr >> A2OJTotal >> A2OJLim;
inFile >> AtCurr >> AtTotal >> AtLim;
inFile >> TcCurr >> TcTotal >> TcLim;
inFile.close();
}
void write()
{
// cout << "Write\n";
inFile.close();
outFile.open("problem_status");
outFile << myRating << ' ' << cycleCount << '\n';
outFile << belowCurr << ' ' << belowTotal << ' ' << belowLim << '\n';
outFile << aboveCurr << ' ' << aboveTotal << ' ' << aboveLim << '\n';
outFile << A2OJCurr << ' ' << A2OJTotal << ' ' << A2OJLim << '\n';
outFile << AtCurr << ' ' << AtTotal << ' ' << AtLim << '\n';
outFile << TcCurr << ' ' << TcTotal << ' ' << TcLim << '\n';
outFile.close();
}
void printDetails()
{
cout << "Details\n";
db(myRating, cycleCount);
db(belowCurr, belowTotal, belowLim);
db(aboveCurr, aboveTotal, aboveLim);
db(A2OJCurr, A2OJTotal, A2OJLim);
db(AtCurr, AtTotal, AtLim);
db(TcCurr, TcTotal, TcLim);
cout << '\n';
}
void refactor()
{
cout << "Start Refactor\n";
if (belowCurr >= belowLim && aboveCurr >= aboveLim && A2OJCurr >= A2OJLim)
{
if (AtCurr >= AtLim && TcCurr >= TcLim)
{
cout << "Congrats you have finished a cycle\n";
cout << "Congrats you have finished a cycle\n";
cout << "Congrats you have finished a cycle\n";
cout << "Congrats you have finished a cycle\n";
cycleCount++;
belowCurr -= belowLim;
aboveCurr -= aboveLim;
A2OJCurr -= A2OJLim;
AtCurr -= AtLim;
TcCurr -= TcLim;
}
}
cout << "End Refactor\n\n";
}
void printMenu()
{
cout << "What rating Problem have you solved?(give -1 if you want to update your rating, 0 exit)" << '\n';
int rating;
cin >> rating;
if(rating == 0)
exit(0);
if (rating == -1)
{
cout << "Enter your new rating!\n";
cin >> rating;
if (rating > myRating)
{
cout << "Congrats on leveling up\n";
cout << "Congrats on leveling up\n";
cout << "Congrats on leveling up\n";
cout << "Congrats on leveling up\n";
}
else
{
cout << "Congrats on finding more of your weaksnesses\n";
cout << "Congrats on finding more of your weaksnesses\n";
cout << "Congrats on finding more of your weaksnesses\n";
cout << "Congrats on finding more of your weaksnesses\n";
}
this->myRating = rating;
cout << "Rating updated!\n\n";
return;
}
cout << "Is it from A2oj(1/0)" << '\n';
bool isA2oj;
cin >> isA2oj;
if (isA2oj)
{
A2OJCurr++;
A2OJTotal++;
// if (rating <= myRating)
// {
// // belowCurr++;
// // belowTotal++;
// }
// else
// {
// aboveCurr++;
// aboveTotal++;
// }
}
else
{
// cout << "Is it from TCoder(1/0)" << '\n';
bool TCoder = false;
// cin >> TCoder;
if (TCoder)
{
TcCurr++;
TcTotal++;
}
else
{
cout << "Is it from AtCoder(1/0)" << '\n';
bool AtCoder;
cin >> AtCoder;
if (AtCoder)
{
AtCurr++;
AtTotal++;
}
else
{
cout << "Is it from TopCoder(1/0)" << '\n';
bool tc;
cin >> tc;
if (tc)
{
TcCurr++;
TcTotal++;
}
else
{
if (rating <= myRating)
{
belowCurr++;
belowTotal++;
}
else
{
aboveCurr++;
aboveTotal++;
}
}
}
}
}
}
void recommendation()
{
cout << "Recommendatons\n";
if (belowCurr < belowLim)
cout << "Try Solving a belowRating\n";
if (A2OJCurr < A2OJLim)
cout << "Try Solving an A2oj Problem\n";
if (aboveCurr < aboveLim)
cout << "Try Solving an aboveRating\n";
if (AtCurr < AtLim)
cout << "Try Solving a Atcoder Problem\n";
if (TcCurr < TcLim)
cout << "Try Solving a topcode Problem\n";
cout << '\n';
}
public:
Solution()
{
}
~Solution()
{
write();
}
void Solve();
};
void Solution::Solve()
{
while (true)
{
read();
printDetails();
recommendation();
printMenu();
refactor();
write();
}
}
int32_t main()
{
#ifndef LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif
int t = 1;
#ifdef MULTI_TEST
cin >> t;
#endif
Solution mySolver;
for (int i = 1; i <= t; ++i)
{
mySolver.Solve();
#ifdef TIME
cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
TimeStart = chrono::steady_clock::now();
#endif
}
return 0;
}