Submission #398532

#TimeUsernameProblemLanguageResultExecution timeMemory
398532fedoseevtimofeyNavigation 2 (JOI21_navigation2)C++17
75 / 100
989 ms892 KiB
#include "Anna.h"

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
#include <bitset>
#include <chrono>

using namespace std;

void Anna(int n, int k, vector <int> R, vector <int> C) {
  vector <pair <int, int>> d = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
  assert(k == 7);
  for (int r = 0; r < n; r++) {
    for (int c = 0; c < n; c++) {
      int id = (3 * r + c) % 9;
      if (id == 8) {
        SetFlag(r, c, 14);
      } else if (id == 7) {
        SetFlag(r, c, 1);
      } else {
        int val = 0;
        if (C[id] >= c + 2) val = 0;
        else if (C[id] <= c - 2) val = 1;
        else if (R[id] >= r + 2) val = 2;
        else if (R[id] <= r - 2) val = 3;
        else {
          for (int i = 0; i < (int)d.size(); ++i) {
            if (r + d[i].first == R[id] && c + d[i].second == C[id]) {
              /*if (r == 0 && c == 0 && id == 0) {
                cout << "go " << d[i].first << ' ' << d[i].second << endl;
              }*/
              val = 4 + i;
            }
          }
        }
        SetFlag(r, c, val + 1);
      }
    }
  }
}
#include "Bruno.h"

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
#include <bitset>
#include <chrono>

using namespace std;

vector <int> Bruno(int k, vector <int> value) {
  vector <pair <int, int>> d = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
  vector <int> res(k, 0);
  int dx, dy;
  for (int i = 0; i < (int)value.size(); ++i) {
    if (value[i] == 14) {
      dx = d[i].first, dy = d[i].second;
    }
  } 
  for (int i = 0; i < (int)value.size(); ++i) {
    int x = (8 + (3 * (d[i].first - dx) + (d[i].second - dy)) % 9) % 9;
    if (x >= k) continue;
    --value[i];
    if (value[i] <= 3) {
      res[x] = value[i];
    } else {
      int cx = d[i].first + d[value[i] - 4].first;
      int cy = d[i].second + d[value[i] - 4].second;
      //cout << x << ' ' << value[i] - 4 << ' ' << cx << ' ' << cy << endl;
      if (cy > 0) res[x] = 0;
      else if (cy < 0) res[x] = 1;
      else if (cx > 0) res[x] = 2;
      else if (cx < 0) res[x] = 3;
      else res[x] = 4;
    }
  }
  return res;
}

Compilation message (stderr)

Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:36:56: warning: 'dy' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     int x = (8 + (3 * (d[i].first - dx) + (d[i].second - dy)) % 9) % 9;
      |                                           ~~~~~~~~~~~~~^~~~~
Bruno.cpp:36:35: warning: 'dx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     int x = (8 + (3 * (d[i].first - dx) + (d[i].second - dy)) % 9) % 9;
      |                       ~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...