| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 538164 | huangqr | Event Hopping 2 (JOI21_event2) | C++14 | 3043 ms | 6156 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pl;
set<pl>taken;
ll chk(deque<pl>d){
sort(d.begin(),d.end(),[](pl a,pl b){
return a.second<b.second;
});
ll cur=-1,ans=0;
for(auto x:d){
auto it=taken.lower_bound(make_pair(x.first,-1));
if(it!=taken.end()){
if(it->first<x.second)continue;
}
if(it!=taken.begin()){
it--;
if(it->second>x.first)continue;
}
if(x.first>=cur){
ans++;
cur=x.second;
}
}
return ans;
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
ll n,k;
cin>>n>>k;
deque<pl>v(n);
for(int i=0;i<n;i++)cin>>v[i].first>>v[i].second;
vector<ll>ans;
for(int i=0;i<n && ans.size()<k;i++){
ll req = k - ans.size() - 1;
pl cur = v[0];
auto it=taken.lower_bound(make_pair(cur.first,-1));
if(it!=taken.end()){
if(it->first<cur.second){
v.push_back(v[0]);
v.pop_front();
continue;
}
}
if(it!=taken.begin()){
it--;
if(it->second>cur.first){
//cout<<"itsecond:"<<it->second<<" curfirst:"<<cur.first<<"\n";
v.push_back(v[0]);
v.pop_front();
continue; }
}
taken.insert(cur);
v.pop_front();
ll c=chk(v);
//cout<<"cur: "<<cur.first<<" "<<cur.second<<"\n chk:"<<chk<<"\n";
if(chk(v)>=req){
ans.push_back(i+1);
}
else{
taken.erase(cur);
v.push_back(cur);
}
}
if(ans.size()<k)cout<<"-1\n";
//else{
for(auto x:ans)cout<<x<<"\n";
//}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
