Submission #989505

# Submission time Handle Problem Language Result Execution time Memory
989505 2024-05-28T08:38:52 Z AdamGS Roller Coaster Railroad (IOI16_railroad) C++17
0 / 100
258 ms 38320 KB
#include "railroad.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=4e5+7, INF=1e9+7;
vector<int>skal;
map<int,int>mp;
int F[LIM], akt;
int fnd(int x) {
  if(F[x]==x) return x;
  return F[x]=fnd(F[x]);
}
void uni(int a, int b) {
  if(fnd(a)==fnd(b)) return;
  F[fnd(b)]=fnd(a);
}
ll plan_roller_coaster(vector<int>s, vector<int>t) {
  s.pb(INF);
  t.pb(0);
  int n=s.size();
  for(auto i : s) skal.pb(i);
  for(auto i : t) skal.pb(i);
  sort(all(skal));
  for(auto i : skal) if(mp.find(i)==mp.end()) mp[i]=akt++;
  rep(i, akt) F[i]=i;
  vector<pair<int,int>>P;
  rep(i, n) {
    P.pb({s[i], -1});
    P.pb({t[i], 1});
  }
  sort(all(P));
  int lst=P[0].st;
  ll sum=0;
  for(auto i : P) {
    if(i.st!=lst) {
      if(sum<0) return 1;
      if(sum>0) uni(mp[i.st], mp[lst]);
    }
    sum+=i.nd;
    lst=i.st;
  }
  rep(i, akt) if(fnd(i)!=fnd(0)) return 1;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 1 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 600 KB n = 2
6 Incorrect 0 ms 348 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 1 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 600 KB n = 2
6 Incorrect 0 ms 348 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 258 ms 38320 KB n = 199999
2 Correct 190 ms 34220 KB n = 199991
3 Correct 187 ms 33716 KB n = 199993
4 Correct 184 ms 28700 KB n = 152076
5 Correct 112 ms 17896 KB n = 93249
6 Correct 221 ms 32428 KB n = 199910
7 Correct 242 ms 36308 KB n = 199999
8 Correct 230 ms 32044 KB n = 199997
9 Correct 209 ms 32244 KB n = 171294
10 Incorrect 178 ms 27132 KB answer is not correct: 1 instead of 0
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 2
2 Correct 1 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 600 KB n = 2
6 Incorrect 0 ms 348 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -