Submission #588577

# Submission time Handle Problem Language Result Execution time Memory
588577 2022-07-03T14:56:26 Z balbit Navigation 2 (JOI21_navigation2) C++17
0 / 100
1 ms 288 KB
#include "Anna.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define f first
#define s second

#define REP(i,n) for (int i = 0; i<n; ++i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)

#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)
#define pb push_back
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)

#endif // BALBIT


namespace {



const int maxn = 505;
int g[maxn][maxn];

int get(int r, int c, int tr, int tc) {
    if (max(abs(r - tr) , abs(c - tc) ) <= 1) {
        return (tr-r+1) * 3 + (tc - c+1) + 1;
    }else{
        if (r < tr-1) return 10; // r++
        if (r > tr+1) return 11; // r--;
        if (c < tc-1) return 12; // c++
        if (c > tc+1) return 13; // c--;
    }
}

int raw[maxn][maxn];

#ifdef BALBIT

#endif // BALBIT

} // namespace

void Anna(int N, int K, vector<int> R, vector<int> C) {
    vector<int> used(15);
    for (int r = 0; r < N; r++) {
        for (int c = 0; c < N; c++) {
            int id = (r % 3) * 3 + (c % 3);
            if (id < K) {
                int yo = get(r, c, R[id],C[id]);
                raw[r][c] = yo;
                used[yo] = 1;
            }else{
                if (id == K) {
                    // nope
                }else{
                    raw[r][c] = 14;
                    used[14] = 1;
                }
            }
        }
    }
    int unused = 0;
    while (used[unused]) ++unused;
    for (int r = 0; r < N; r++) {
        for (int c = 0; c < N; c++) {
            int id = (r % 3) * 3 + (c % 3);
            if (id == K) SetFlag(r,c,unused);
            else {
                SetFlag(r,c,raw[r][c]>unused?raw[r][c]-1:raw[r][c]);
            }
        }
    }
}







#include "Bruno.h"
#include <vector>
//#define BALBIT
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define f first
#define s second

#define REP(i,n) for (int i = 0; i<n; ++i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)

#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)
#define pb push_back
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)

#endif // BALBIT


namespace {


const int maxn = 505;
}

std::vector<int> Bruno(int K, std::vector<int> value) {
    array<array<int, 5>, 5> tmp;
    REP(i,5) REP(j,5) {
        tmp[i][j] = (i % 3) * 3 + (j % 3);
//        bug(i,j,tmp[i][j]);
    }
    for (int ti = 1; ti <= 3; ++ti) for (int tj = 1; tj <= 3; ++tj) {
        // test it
        vector<int> re(K);
        bool ok = 1;
        int it = 0;
        for (int di = -1; di <= 1; ++di) for (int dj = -1; dj <= 1; ++dj) {

            if (value[it] == 13) {
                if (tmp[ti + di][tj + dj] <= K) {
                    ok = 0; goto nope;
                }
            }

            ++it;
        }

        bug(ti, tj);

        assert(ok);
        int gone;
        int gi, gj;
        it = 0;
        for (int di = -1; di <= 1; ++di) for (int dj = -1; dj <= 1; ++dj) {
            if (value[it] == 13) {
                gi = di; gj = dj==-1?1:dj-1;
                goto over1;
            }
            ++it;
        }
        over1:;

        it = 0;
        for (int di = -1; di <= 1; ++di) for (int dj = -1; dj <= 1; ++dj) {
            if (di == gi && dj == gj) {
                gone = value[it];
                goto over2;
            }
            ++it;
        }
        over2:;

        it = 0;

        for (int di = -1; di <= 1; ++di) for (int dj = -1; dj <= 1; ++dj) {

            if (value[it] >= gone) value[it] ++;
            int hi = value[it];
            bug(it, hi);
            if (value[it] == 14) {
                ++it; continue;
            }
            int who = tmp[ti + di][tj + dj];
            if (value[it] >= 10) {
                if (value[it] == 10) re[who] = 2;
                if (value[it] == 11) re[who] = 3;
                if (value[it] == 12) re[who] = 0;
                if (value[it] == 13) re[who] = 1;
            }else{
                int ai = di + ((hi-1)/3-1);
                int aj = dj + ((hi-1)%3-1);
                if (ai == 0 && aj == 0) {
                    re[who] = 4;
                }else{
                    bug("from here!");
                    if (0 < ai) re[who] = 2;
                    if (0 > ai) re[who] = 3;
                    if (0 < aj) re[who] = 0;
                    if (0 > aj) re[who] = 1;
                }
            }

            bug(it, who, re[who]);

            ++it;
        }

        return re;

        nope:;
    }

}


/*
1
7 7
2 2
2 3
4 5
4 2
6 4
3 2
3 3
2 3
*/

Compilation message

Anna.cpp: In function 'int {anonymous}::get(int, int, int, int)':
Anna.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
Anna.cpp: At global scope:
Anna.cpp:35:5: warning: '{anonymous}::g' defined but not used [-Wunused-variable]
   35 | int g[maxn][maxn];
      |     ^

Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:124:1: warning: control reaches end of non-void function [-Wreturn-type]
  124 | }
      | ^
Bruno.cpp:88:13: warning: 'gone' may be used uninitialized in this function [-Wmaybe-uninitialized]
   88 |             if (value[it] >= gone) value[it] ++;
      |             ^~
Bruno.cpp:76:32: warning: 'gj' may be used uninitialized in this function [-Wmaybe-uninitialized]
   76 |             if (di == gi && dj == gj) {
      |                             ~~~^~~~~
Bruno.cpp:76:20: warning: 'gi' may be used uninitialized in this function [-Wmaybe-uninitialized]
   76 |             if (di == gi && dj == gj) {
      |                 ~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 288 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -