Submission #418387

# Submission time Handle Problem Language Result Execution time Memory
418387 2021-06-05T10:34:55 Z rGamer Toy Train (IOI17_train) C++17
0 / 100
1975 ms 262148 KB
#include <bits/stdc++.h>

using namespace std;

vector<int> ans;
int dp(vector<int> &a, vector<int> &r, vector<vector<int>> gp, int poz) {
  if(ans[poz] != -1)
    return ans[poz];
  int cur;
  if(a[poz]) {
    cur = (gp[poz].size() > 1 and r[poz]) ? 1 : dp(a, r, gp, poz + 1);
  }
  else
    cur = (gp[poz].size() > 1 and !r[poz]) ? 0 : dp(a, r, gp, poz + 1);
  return ans[poz] = cur;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
  int n = a.size(), m = u.size();
  ans = vector<int>(n, -1);
  vector<vector<int>> gp(n);
  for(int i = 0; i < m; ++i)
    gp[u[i]].push_back(v[i]);
  ans[n - 1] = r[n - 1];
  int kz = 0;
  while(kz < n) {
      if(ans[kz] == -1)
        dp(a, r, gp, kz);
        kz++;
  }
  return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:26:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   26 |       if(ans[kz] == -1)
      |       ^~
train.cpp:28:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   28 |         kz++;
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 1699 ms 10412 KB Output is correct
2 Incorrect 1739 ms 11128 KB 3rd lines differ - on the 2541st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 245 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1975 ms 26636 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1701 ms 3372 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1699 ms 10412 KB Output is correct
2 Incorrect 1739 ms 11128 KB 3rd lines differ - on the 2541st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -