Task: | Pallo |
Sender: | Anniiiz |
Submission time: | 2022-01-22 16:09:09 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream> #include <vector> #include<algorithm> #include <map> using namespace std; using ll = long long; vector<pair<ll,ll>> reitti; map<pair<ll,ll>, ll> ma; int main() { ll t; cin >> t; for (int h = 0; h < t; ++h) { ll n, m, k; ll p = 0; ll mutkat = 0; cin >> n >> m >> k; ll suunta = 0; pair<ll,ll> me = {1,1}; while (p <= k) { //cout << me.first << " " << me.second << endl; reitti.push_back(me); mutkat++; if (suunta == 1) { ll ab = m - me.second; if (ab == 0) { break; } p += ab; ma[me] += p; me = {me.first - ab, me.second + ab}; } else if (suunta == 3) { ll ab = me.second - 1; if (ab == 0) break; p += ab; ma[me] += p; me = {me.first + ab, me.second - ab}; } else if (suunta == 2) { ll ab = me.first - 1; if (ab == 0) break; p += ab; ma[me] += p; me = {me.first - ab, me.second - ab}; } else if (suunta == 0) { ll ab = n - me.first; if (ab == 0) break; p += ab; ma[me] += p; me = {me.first + ab, me.second + ab}; } suunta ++; suunta = suunta%4; //cout << ma[reitti.back()] << " l " << mutkat << endl; } ll vastaus = 0; //cout << me.first << " loppu " << me.second << endl; if (k < p || (!(me.first == 1 && me.second == m) && !(me.first == n && me.second == 1) && !(me.first == n && me.second == m))) { //cout << "lol" << endl; vastaus = mutkat - 1; } else { //cout << k << " " << p << " " << k / p << " " << mutkat << " " << (k / p) * mutkat << endl; if (k % p == 0) vastaus = (k / p) * mutkat - 1; else { ll ka = k % p; vastaus = (k / p) * mutkat - 1; if (k / p % 2 == 0) { int x = -1; for (int b = reitti.size()-1; b >= 1; b/=2) { while (ka < ma[reitti[x+b]]) x += b; } vastaus += x+1; } } } cout << vastaus << endl; } for (auto x : ma) { ma[x.first] = 0; } for (int i = reitti.size() - 1; i >= 0; i--) reitti.pop_back(); }
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 10 5 76 9 8 78 8 6 49 3 3 94 ... |
correct output |
---|
25 19 15 47 8 ... |
user output |
---|
16 18 14 93 11 ... Truncated |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 7 5 99033171167123849 6 8 472883555390027162 9 10 258937093512465880 10 6 691774305483997493 ... |
correct output |
---|
33011057055707949 148620545979722822 57541576336103529 199845910473154830 52151060432923288 ... |
user output |
---|
(empty) |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 816332614 86098803 33572721929... |
correct output |
---|
4310587870 45982113074 1550250683 717639357 3282221941 ... |
user output |
---|
(empty) |