| Task: | Pallo |
| Sender: | andreibe |
| Submission time: | 2022-01-22 15:32:39 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 45 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 10 |
| #2 | ACCEPTED | 35 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.01 s | 2, 3 | details |
| #3 | WRONG ANSWER | 0.01 s | 3 | details |
Code
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <algorithm>
#include <vector>
#include <fstream>
#include <set>
#include <unordered_map>
#include <queue>
#include <climits>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define LOOP(i,a,l) for (int i = a; i < l; i++)
#define LUO_VERKKO LOOP(i,0,m) {int a,b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a);}
#define COLLECT for (int i = 0; i < n; i++) cin >> s[i]
#define PRINT_LIST(l) for (int i = 0; i < l.size(); i++) cout << l[i] << " "
#define S second
#define F first
#define A 999999999999999999LL
#define M 1000000007
//https://cses.fi/dt/
int n;
int t;
pair<int, int> d[11][11][5];
#define N (1<<17)
int main() {
cin >> t;
for (int i = 0; i < t; i++)
{
int n, m; cin >> n >> m;
ll k; cin >> k;
k--;
int x = 1;
int y = 1;
ull c = 0;
int dir = 3;
ull moves = 0;
for (int o = 0; o < 11; o++)
{
for (int j = 0; j < 11; j++)
{
for (int l = 0; l < 5; l++)
{
d[o][j][l] = { 0,0 };
}
}
}
while (k >= 0) {
if (x == 0) {
if (dir == 2) dir = 3;
if (dir == 1) dir = 4;
}
if (y == 0) {
if (dir == 1) dir = 2;
if (dir == 4) dir = 3;
}
if (x == m - 1) {
if (dir == 3) dir = 2;
if (dir == 4) dir = 1;
}
if (y == n - 1) {
if (dir == 2) dir = 1;
if (dir == 3) dir = 4;
}
if (d[x][y][dir].first) {
//loop
ull org = c;
ull lol = k / moves;
k -= (lol * (ll)moves);
c += (org * lol);
moves += lol * moves;
}
if (x == 0 || y == 0 || x == m - 1 || y == n - 1) c++;
moves++;
d[x][y][dir] = { moves,c };
k--;
if (dir == 1) {
x--;
y--;
}
if (dir == 2) {
x--;
y++;
}
if (dir == 3) {
x++;
y++;
}
if (dir == 4) {
x++;
y--;
}
}
std::cout << c << "\n";
}
}
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 10 5 76 9 8 78 8 6 49 3 3 94 ... |
| correct output |
|---|
| 25 19 15 47 8 ... |
| user output |
|---|
| 25 19 15 47 8 ... Truncated |
Test 2
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 7 5 99033171167123849 6 8 472883555390027162 9 10 258937093512465880 10 6 691774305483997493 ... |
| correct output |
|---|
| 33011057055707949 148620545979722822 57541576336103529 199845910473154830 52151060432923288 ... |
| user output |
|---|
| 33011057055707949 148620545979722822 57541576336103529 199845910473154830 5215106043292328 ... Truncated |
Test 3
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000 816332614 86098803 33572721929... |
| correct output |
|---|
| 4310587870 45982113074 1550250683 717639357 3282221941 ... |
| user output |
|---|
| 0 0 0 0 0 ... Truncated |
