제출 #1217590

#제출 시각아이디문제언어결과실행 시간메모리
1217590mychecksedadNavigation 2 (JOI21_navigation2)C++20
85 / 100
294 ms876 KiB
#include "Anna.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 3e6+100, M = 1e5+10, K = 52, MX = 30, FFF = 1e8+1;


namespace {

int FunctionExample(int r, int c, int K) {
  return (r + c) % K + 1;
}

} // namespace

void Anna(int n, int k, std::vector<int> R, std::vector<int> C) {
  int arr[3][3] = {
    {0, 1, 2},
    {3, 4, 5},
    {6, 7, 8}
  };
  // for(int i = 0; i < k; ++i) cerr << R[i] << ' ' << C[i] << '\n';
  bitset<9> used;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      int pos = (i%3)*3 + (j%3);
      if(pos != 0 && pos < 8){
        --pos;
        int x_dif = R[pos] - i, y_dif = C[pos] - j;
        if(abs(x_dif) <= 1 && abs(y_dif) <= 1){
          used[(x_dif + 1) * 3 + y_dif + 1] = 1;
        }
      }
    }
  }
  int crap = 0;
  for(int i = 0; i < 9; ++i) if(!used[i]){
    crap = i;
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      int pos = (i%3)*3 + (j%3);
      if(pos == 0){
        SetFlag(i, j, 1);
      }else{
        if(pos < 8){
          --pos;
          int x_dif = R[pos] - i, y_dif = C[pos] - j;
          // cerr << i << ' ' << j << ' ' << x_dif << ' ' << y_dif << " wtf\n";
          if(abs(x_dif) <= 1 && abs(y_dif) <= 1){
            int val = arr[x_dif + 1][y_dif + 1];
            if(val > crap) --val;
            SetFlag(i, j, val + 2);                  
          }else{
            if(abs(y_dif) >= abs(x_dif)){
              if(y_dif > 0) SetFlag(i, j, 10);
              else SetFlag(i, j, 11);
            }else{
              if(x_dif > 0) SetFlag(i, j, 12);
              else SetFlag(i, j, 13);
            }
          }
        }else{
          SetFlag(i, j, crap + 1);
        }
      }
    }
  }
}
#include "Bruno.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 3e6+100, M = 1e5+10, K = 52, MX = 30, FFF = 1e8+1;


namespace {

int variable_example = 1;

} // namespace

std::vector<int> Bruno(int k, std::vector<int> value) {
  std::vector<int> res(k, 0);
  int x = 0, y = 0;
  vector<vector<int>> v(3, vi(3));
  for(int i = 0; i < 3; ++i) for(int j =0 ; j < 3; ++j) v[i][j] = value[i*3 + j];

  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < 3; ++j) if(v[i][j] == 1) x = i, y = j;
  }
cerr << '\n';
cerr << '\n';
for(int i = 0; i < 3; ++i){ for(int j = 0; j < 3; ++j) cerr << v[i][j] << ' '; cerr << '\n';}
cerr << '\n';
  int arr[9][2] = {
    {-1, -1},
    {-1, 0},
    {-1, 1},
    {0, -1},
    {0, 0},
    {0, 1},
    {1, -1},
    {1, 0},
    {1, 1}
  };
  int crap = v[(x+2)%3][(y+2)%3] - 1;
  int cur = 0;
  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < 3; ++j){
      if(i==0 && j==0) continue;
      int X = (x + i) % 3, Y = (y + j) % 3;
      if(cur == 8){
        continue;
      }
      if(v[X][Y] <= 9){
        int w = v[X][Y] - 2;
        if(w >= crap) ++w;
        int new_x = arr[w][0] + X, new_y = arr[w][1] + Y;
        int x_dif = new_x - 1, y_dif = new_y - 1;
        if(x_dif == 0 && y_dif == 0) res[cur] = 4;
        else if(y_dif > 0) res[cur] = 0;
        else if(y_dif < 0) res[cur] = 1;
        else if(x_dif > 0) res[cur] = 2;
        else res[cur] = 3;
      }else{
        res[cur] = v[X][Y] - 10;
      }
      ++cur;
    }
  }
  // for(int i = 0; i < 7; ++i) cerr << res[i] << ' ';

  return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...