Submission #425302

# Submission time Handle Problem Language Result Execution time Memory
425302 2021-06-12T20:13:04 Z Osama_Alkhodairy Navigation 2 (JOI21_navigation2) C++17
0 / 100
0 ms 192 KB
#include <bits/stdc++.h>
#include "Anna.h"
using namespace std;

//~ 1: move right
//~ 2: move left
//~ 3: move down
//~ 4: move up
//~ 5: (x - 1, y - 1)
//~ 6: (x - 1, y)
//~ 7: (x - 1, y + 1)
//~ 8: (x, y - 1)
//~ 9: (x, y)
//~ 10: (x, y + 1)
//~ 11: (x + 1, y - 1)
//~ 12: (x + 1, y)
//~ 13: (x + 1, y + 1)

int calc(pair <int, int> l, pair <int, int> r){
    if(abs(l.first - r.first) > 1){
        if(r.first < l.first) return 4;
        else return 3;
    }
    else if(abs(l.second - r.second) > 1){
        if(r.second < l.second) return 2;
        else return 1;
    }
    else if(l.first - 1 == r.first){
        if(l.second - 1 == r.second) return 5;
        else if(l.second == r.second) return 6;
        else return 7;
    }
    else if(l.first == r.first){
        if(l.second - 1 == r.second) return 8;
        else if(l.second == r.second) return 9;
        else return 10;
    }
    else{
        if(l.second - 1 == r.second) return 11;
        else if(l.second == r.second) return 12;
        else return 13;
    }
}
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
    for(int i = 0 ; i < N ; i++){
        vector <int> cur;
        if(i % 3 == 0) cur = {0, 1, 2};
        else if(i % 3 == 1) cur = {3, 4, 5};
        else cur = {6, 7, 8};
        for(int j = 0 ; j < N ; j++){
            int idx = cur[j % cur.size()];
            if(idx == 7){
                SetFlag(i, j, 14 + i % 3);
            }
            else if(idx == 8){
                SetFlag(i, j, 14 + j % 3);
            }
            else{
                SetFlag(i, j, calc(make_pair(i, j), make_pair(R[idx], C[idx])));
            }
        }
    }
}
#include <bits/stdc++.h>
#include "Bruno.h"
using namespace std;

std::vector<int> Bruno(int K, std::vector<int> value) {
    vector <vector <int> > v(3, vector <int>(3));
    for(int k = 0 ; k < 9 ; k++){
        v[k / 3][k % 3] = value[k];
    }
    vector <pair <int, int> > f;
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            if(v[i][j] >= 14){
                f.push_back(make_pair(i, j));
                v[i][j] -= 14;
            }
        }
    }
    assert(f.size() == 2);
    int rmod, cmod;
    if(abs(f[0].first - f[1].first) + abs(f[0].second - f[1].second) == 1){
        rmod = (v[f[0].first][f[0].second] - f[0].first + 3) % 3;
        cmod = (v[f[1].first][f[1].second] - f[1].second + 3) % 3;
    }
    else{
        cmod = (v[f[0].first][f[0].second] - f[0].second + 3) % 3;
        rmod = (v[f[1].first][f[1].second] - f[1].first + 3) % 3;
    }
    vector <int> ret(7);
    for(int i = 0 ; i < 3 ; i++){
        vector <int> cur;
        if((rmod + i) % 3 == 0) cur = {0, 1, 2};
        else if((rmod + i) % 3 == 1) cur = {3, 4, 5};
        else cur = {6, 7, 8};
        for(int j = 0 ; j < 3 ; j++){
            int idx = cur[(cmod + j) % cur.size()];
            if(idx > 6) continue;
            if(v[i][j] <= 4) ret[idx] = v[i][j] - 1;
            else{
                pair <int, int> p = make_pair(i, j);
                if(v[i][j] == 5) p.first--, p.second--;
                else if(v[i][j] == 6) p.first--;
                else if(v[i][j] == 7) p.first--, p.second++;
                else if(v[i][j] == 8) p.second--;
                else if(v[i][j] == 10) p.second++;
                else if(v[i][j] == 11) p.first++, p.second--;
                else if(v[i][j] == 12) p.first++;
                else if(v[i][j] == 13) p.first++, p.second++;
                if(p.first < 1) ret[idx] = 3;
                else if(p.first > 1) ret[idx] = 4;
                else if(p.second < 1) ret[idx] = 1;
                else if(p.second > 1) ret[idx] = 0;
                else ret[idx] = 4;
            }
        }
    }
    return ret;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 192 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -