Submission #683118

# Submission time Handle Problem Language Result Execution time Memory
683118 2023-01-17T18:16:13 Z bleahbleah Roller Coaster Railroad (IOI16_railroad) C++17
0 / 100
1465 ms 74384 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;

//#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

const int nmax = 5e5 + 5, inf = 1e9 + 5; 

vector<int> g[nmax];
bool occ[nmax];
void dfs(int node) {
  if(occ[node]) return;
  occ[node] = 1;
  for(auto x : g[node]) {
    dfs(x);
  }
  return;
}

long long plan_roller_coaster(vector<int> s, vector<int> t) {
  t.emplace_back(0);
  s.emplace_back(inf);
  
  map<int,int> smen, nrm;
  for(auto x : s)
    smen[x]++;
  for(auto x : t)
    smen[x]--;
  
  int edgc = 0;
  int last = 0, cnt = 0;
  
  for(auto [a, b] : smen)  {
    nrm[a] = cnt++;
    if(edgc != 0)
      g[nrm[a]].emplace_back(nrm[last]),
      g[nrm[last]].emplace_back(nrm[a]);
    edgc += b;
    if(edgc > 0) return 0;
    last = a;
  }
  
  for(int i = 0; i < sz(s); i++)
    g[nrm[s[i]]].emplace_back(nrm[t[i]]),
    g[nrm[t[i]]].emplace_back(nrm[s[i]]);
  dfs(0);
  for(auto x : s)
    if(occ[nrm[x]] == 0) return 0;
  for(auto x : t)
    if(occ[nrm[x]] == 0) return 0;
  
  return 3;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11988 KB answer is not correct: 3 instead of 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11988 KB answer is not correct: 3 instead of 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1465 ms 74384 KB answer is not correct: 1 instead of 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11988 KB answer is not correct: 3 instead of 0
2 Halted 0 ms 0 KB -