Submission #486653

#TimeUsernameProblemLanguageResultExecution timeMemory
486653alextodoranNavigation 2 (JOI21_navigation2)C++17
30 / 100
801 ms872 KiB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int East = 0;
const int West = 1;
const int South = 2;
const int North = 3;
const int Finish = 4;

#include "Anna.h"

void SetFlag (int r, int c, int value);

void Anna (int N, int K, vector <int> R, vector <int> C)
{
    for(int r = 0; r < N; r++)
        for(int c = 0; c < N; c++)
        {
            int value = 0;
            int currPow = 1;
            for(int t = (r + c) % 2; t < K; t += 2)
            {
                int currVal;
                if(r == R[t] && c == C[t])
                    currVal = Finish;
                else if(r < R[t])
                    currVal = South;
                else if(r > R[t])
                    currVal = North;
                else if(c < C[t])
                    currVal = East;
                else if(c > C[t])
                    currVal = West;
                value += currVal * currPow;
                currPow *= 5;
            }
            if((r + c) % 2 == 1)
                value += 5 * 5 * 5 * 5;
            SetFlag(r, c, value + 1);
        }
}
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int East = 0;
const int West = 1;
const int South = 2;
const int North = 3;
const int Finish = 4;

#include "Bruno.h"

vector <int> Bruno (int K, vector <int> value)
{
    bool parity;

    int mat[3][3];
    for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            mat[i][j] = value[i * 3 + j] - 1;
    parity = (mat[1][1] >= 5 * 5 * 5 * 5);
    for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            if(mat[i][j] >= 5 * 5 * 5 * 5)
                mat[i][j] -= 5 * 5 * 5 * 5;

    vector <int> sol (K);
    for(int t = parity; t < K; t += 2)
    {
        sol[t] = mat[1][1] % 5;
        mat[1][1] /= 5;
    }
    for(int t = !parity; t < K; t += 2)
    {
        int vals[] = {mat[1][2] % 5, mat[1][0] % 5, mat[2][1] % 5, mat[0][1] % 5};
        if(vals[East] != West)
            sol[t] = (vals[East] == Finish ? East : vals[East]);
        else if(vals[West] != East)
            sol[t] = (vals[West] == Finish ? West : vals[West]);
        else if(vals[South] != North)
            sol[t] = (vals[South] == Finish ? South : vals[South]);
        else if(vals[North] != South)
            sol[t] = (vals[North] == Finish ? North : vals[North]);
        else
            sol[t] = Finish;

        for(int i = 0; i < 3; i++)
            for(int j = 0; j < 3; j++)
                mat[i][j] /= 5;
    }

    return sol;
}

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:45:34: warning: 'currVal' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |                 value += currVal * currPow;
      |                          ~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...