답안 #710919

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710919 2023-03-16T05:21:36 Z EthanKim8683 Plahte (COCI17_plahte) C++17
0 / 160
222 ms 26900 KB
#include<bits/stdc++.h>
using namespace std;
using I=int;
const I N=80000;
const I M=80000;
tuple<I,I,I,I>dons[N];
tuple<I,I,I>kims[M];
map<I,I>upps;
vector<tuple<I,I,I>>ques;
set<I>cols[N];
vector<I>adjs[N];
I inds[N];
I ress[N];
void dfs(I a){
  for(auto b:adjs[a]){
    dfs(b);
    if(cols[b].size()>cols[a].size())swap(cols[a],cols[b]);
    for(auto k:cols[b])cols[a].insert(k);
  }
  ress[a]=cols[a].size();
}
I main(){
  cin.tie(0)->sync_with_stdio(0);
  I n,m;cin>>n>>m;
  for(I i=0;i<n;i++){
    I a,b,c,d;cin>>a>>b>>c>>d;
    dons[i]={a,b,c,d};
    ques.push_back({-a,3,i});
    ques.push_back({-c,1,i});
  }
  for(I i=0;i<m;i++){
    I x,y,k;cin>>x>>y>>k;
    kims[i]={x,y,k};
    ques.push_back({-x,2,i});
  }
  sort(ques.begin(),ques.end());
  while(ques.size()){
    auto[cur,t,i]=ques.back();ques.pop_back();
    if(t==3){
      auto[a,b,c,d]=dons[i];
      upps.insert({d,i});
      auto it=upps.upper_bound(d);
      if(it==upps.end())continue;
      I j=it->second;
      if(b<get<1>(dons[j]))continue;
      adjs[j].push_back(i),inds[i]++;
      upps.insert({b,j});
    }
    if(t==2){
      auto[x,y,k]=kims[i];
      auto it=upps.lower_bound(y);
      if(it==upps.end())continue;
      I j=it->second;
      if(y<get<1>(dons[j]))continue;
      cols[j].insert(k);
    }
    if(t==1){
      auto[a,b,c,d]=dons[i];
      upps.erase(d);
      auto it=upps.upper_bound(d);
      if(it==upps.end())continue;
      I j=it->second;
      if(b<get<1>(dons[j]))continue;
      upps.erase(b);
    }
  }
  for(I i=0;i<n;i++)if(!inds[i])dfs(i);
  for(I i=0;i<n;i++)printf("%i\n",ress[i]);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 10556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 12728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 120 ms 19032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 222 ms 26900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 220 ms 24124 KB Output isn't correct
2 Halted 0 ms 0 KB -