| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 166919 | theStaticMind | Port Facility (JOI17_port_facility) | C++14 | 6071 ms | 292372 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<ii>arr;
map<vector<int>,map<vector<int>,map<int,int>>> Q;
int dp(vector<int>A,vector<int>B,int ind){
if(ind==arr.size())return 1;
if(Q[A][B].count(ind))return Q[A][B][ind];
int cnt=0;
if(arr[ind].second==0){
if(!A.empty()&&A.back()==arr[ind].first){
A.pop_back();
return Q[A][B][ind]=dp(A,B,ind+1);
}
else if(!B.empty()&&B.back()==arr[ind].first){
B.pop_back();
return Q[A][B][ind]=dp(A,B,ind+1);
}
else assert(0);
}
if(A.empty()||A.back()>arr[ind].second){
A.pb(arr[ind].second);
cnt=(cnt+dp(A,B,ind+1))%modulo;
A.pop_back();
}
if(B.empty()||B.back()>arr[ind].second){
B.pb(arr[ind].second);
cnt=(cnt+dp(A,B,ind+1))%modulo;
B.pop_back();
}
return Q[A][B][ind]=cnt;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("q.gir","r",stdin);
// freopen("q.cik","w",stdout);
int n,ans=1;
cin>>n;
for(int i=0;i<n;i++){
int a,b;
cin>>a>>b;
arr.pb({a,b});
arr.pb({b,0});
}
sort(all(arr));
vector<int>A,B;
cout<<dp(A,B,0);
}
컴파일 시 표준 에러 (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... | ||||
