QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#734193#9564. Hey, Have You Seen My Kangaroo?ucup-team3215Compile Error//C++202.1kb2024-11-11 03:09:102024-11-11 03:09:11

Judging History

你现在查看的是最新测评结果

  • [2024-11-11 03:09:11]
  • 评测
  • [2024-11-11 03:09:10]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 2e5, L = 20;

string s, a;
int n, m, k, jump[L][N], mark[N], ct;
vector<int> preim[N], merges;

void adv(int& i, int& j, int k) {
  int di = s[k] == 'U'? -1: s[k] == 'D';
  int dj = s[k] == 'L'? -1: s[k] == 'R';
  if (i + di >= 0 && i + di < n && j + dj >= 0 && j + dj < m && a[(i + di) * m + j + dj] == '1') i += di, j += dj;
}

vector<int> shrink(const vector<int>& v, int l) {
  vector<int> res;
  ++ct;
  for (auto v: v) {
    v = jump[l][v];
    if (mark[v] != ct) res.push_back(v);
    mark[v] = ct;
  }
  return res;
}

void solve1(vector<int> v, int t) {
  vector<int> u;
  for (int i = 0; i < k; ++i) {
    ++ct;
    for (auto v: v) {
      int r = v / m, j = v % m;
      adv(r, j, i);
      v = r * m + j;
      if (mark[v] != ct) u.push_back(v), mark[v] = ct;
      else merges.push_back(t * k + i + 1);
    }
    swap(v = {}, u);
  }
}

void solve(vector<int> v, int t, int l) {
  if (v.size() == 1) return;
  if (!~l) return solve1(v, t);
  auto u = shrink(v, l);
  for (auto v: vector(move(v))) preim[jump[l][v]].push_back(v);
  vector<pair<int, vector<int>>> val;
  for (auto v: u) preim[v].size() > 1? val.push_back({v, move(preim[v])}): preim[v].clear();
  for (auto& [u, v]: vector(move(val)) solve(move(v), t, l - 1);
  solve(move(u), t | 1 << l, l - 1);
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m >> k >> s;
  string t;
  for (int i = 0; i < n; ++i) cin >> t, a += t;
  vector<int> all;
  for (int i = 0; i < n; ++i)
  for (int j = 0; j < m; ++j) if (a[i * m + j] == '1') {
    all.push_back(i * m + j);
    int ti = i, tj = j;
    for (int i = 0; i < k; ++i) adv(ti, tj, i);
    jump[0][i * m + j] = ti * m + tj;
  }
  for (int l = 0; l < L - 1; ++l)
  for (int i = 0; i < n * m; ++i) jump[l + 1][i] = jump[l][jump[l][i]];
  solve(all, 0, L - 1);
  sort(merges.begin(), merges.end());
  vector<int> ans(all.size() - 1, -1);
  copy(merges.begin(), merges.end(), ans.rbegin());
  ans.resize(n * m);
  for (auto ans: ans) cout << ans << '\n';
}

Details

answer.code: In function ‘void solve(std::vector<int>, int, int)’:
answer.code:50:39: error: expected ‘)’ before ‘solve’
   50 |   for (auto& [u, v]: vector(move(val)) solve(move(v), t, l - 1);
      |       ~                               ^~~~~~
      |                                       )