답안 #989496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
989496 2024-05-28T08:37:34 Z AdamGS Roller Coaster Railroad (IOI16_railroad) C++17
0 / 100
166 ms 53552 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=2e5+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, n) if(fnd(i)!=fnd(0)) return 1;
  return 0;
}
# 결과 실행 시간 메모리 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 344 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Incorrect 0 ms 376 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Incorrect 0 ms 376 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 166 ms 53552 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Incorrect 0 ms 376 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -