# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
726104 | Jovica | 사다리꼴 (balkan11_trapezoid) | C++14 | 1080 ms | 2492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
vector<tuple<int,int,int,int> > v;
bool visited[100000];
pair<int,int> dp[100000];
/// zima,nacini
pair<int,int> f(int poz)
{
//cout <<"ulava u "<<poz<<endl;
if (poz==v.size()) return {0,0};
if (visited[poz]==true) return dp[poz];
int zima=0,nacini=1;
pair<int,int> p={zima,nacini};
for (int i=0;i<n;i++)
{
if (get<1>(v[poz])<get<0>(v[i]) && get<3>(v[poz])<get<2>(v[i]))
{
//cout<<"poz = "<<poz<<" && i = "<<i<<" "<< get<1>(v[poz])<<" < "<<get<0>(v[i])<<" && "<<get<3>(v[poz])<<" < "<<get<2>(v[i])<<endl;
p=f(i);
if (p.first==zima) nacini+=p.second;
else if(p.first>zima)
{
zima=p.first;
nacini=p.second;
}
}
}
zima++;
p={zima,nacini};
visited[poz]=true;
dp[poz]=p;
return p;
}
int main()
{
cin>>n;
for (int i=0;i<n;i++)
{
int A,B,C,D;
cin>>A>>B>>C>>D;
v.push_back({A,B,C,D});
}
//sort(v.begin(),v.end());
pair<int,int> p={0,0};
for (int i=0;i<n;i++)
if (visited[i]==false)
{
pair<int,int> q=f(i);
//cout<< "i="<<i<<" zima="<<q.first<<endl<<" najde="<<q.second<<endl;
if (p.first==q.first) p.second+=q.second;
if (q.first>p.first) p=q;
}
//for (int i=1;i<n;i++) if (dp[i].second==p.first) p.second+=dp[i].second;
cout<<p.first<<" "<<p.second<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |