I dont know how to use Template for multiple input. Can you help me ?
Fast Input Code
Sorry for my bad English. Correct me if I am wrong.
Thanks for reading <3
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
I dont know how to use Template for multiple input. Can you help me ?
template <typename T>
bool read_int(T &x) {
bool start = false , neg = false;
T ret = 0;
for (char r; r = getchar(); ) {
if (r == '-') neg = true;
else if ((r < '0' || r > '9'))
if (start) return false; else continue;
else
ret += r - '0';
if (start) ret *=10;
start = true;
}
return x = (neg ? -ret : ret), true;
}
template <typename T, typename... Tnext>
bool read_int(T &x, Tnext... next)
{
read_int(next...);
}
Sorry for my bad English. Correct me if I am wrong.
Thanks for reading <3
| Name |
|---|



Int the first template:
Int the second template:
What happened ;-; ? I use vscode
Run code in
CUSTOM TESTdoesnt work tooThe bug is in your original
read_intBoth of these work fine.
Yes they are <3 Thanks
But how can I
detectif there is no valid input ?You're welcome!
I don't know how to manipulate that function, I believe cin/cout with sync is enough.
If you meant how to read until the input ends, it's done like this:
Yes I know about it, but I mean to the template of custom cin >> operator
well... actually I have just meet a problem where cin_with_sync is not enough :) And this is the first problem I need to use FastInput, I was surprised
How can I check if there is no more arguments in parametter ?