답안 #725688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725688 2023-04-17T21:36:56 Z Jovica 사다리꼴 (balkan11_trapezoid) C++14
10 / 100
500 ms 12796 KB
#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)
{
    if (poz==v.size()) return {0,0};
    if (visited[poz]==true) return dp[poz];

    int  zima=0,nacini=1;
    pair<int,int> p=f(poz+1);
    for (int i=poz+1;i<n;i++)
    {
        if (get<1>(v[poz])<get<0>(v[i]) && get<3>(v[poz])<get<2>(v[i]))
        {
            p=f(i);
            if (p.first==zima) nacini+=p.second;
            else if(p.first>zima)
            {
                zima=p.first;
                nacini=p.second;
            }
        }
    }

    zima++;
    if (poz==0)
    for (int i=poz+1;i<n;i++)
    {
        if (get<1>(v[poz])>=get<0>(v[i]) || get<3>(v[poz])>=get<2>(v[i]))
        {
            p=f(i);
            if (zima==p.first) nacini+=p.second;
        }
    }

    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= f(0);
    cout<<p.first<<" "<<p.second<<endl;
    return 0;
}

Compilation message

trapezoid.cpp: In function 'std::pair<int, int> f(int)':
trapezoid.cpp:12:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     if (poz==v.size()) return {0,0};
      |         ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 2 ms 340 KB Output isn't correct
4 Incorrect 4 ms 340 KB Output isn't correct
5 Incorrect 12 ms 588 KB Output isn't correct
6 Incorrect 27 ms 700 KB Output isn't correct
7 Incorrect 44 ms 860 KB Output isn't correct
8 Incorrect 30 ms 1080 KB Output isn't correct
9 Incorrect 256 ms 1612 KB Output isn't correct
10 Execution timed out 1091 ms 3008 KB Time limit exceeded
11 Execution timed out 1040 ms 3524 KB Time limit exceeded
12 Execution timed out 1066 ms 6624 KB Time limit exceeded
13 Execution timed out 1074 ms 8008 KB Time limit exceeded
14 Execution timed out 1058 ms 9168 KB Time limit exceeded
15 Execution timed out 1076 ms 9684 KB Time limit exceeded
16 Execution timed out 1078 ms 10400 KB Time limit exceeded
17 Execution timed out 1082 ms 10924 KB Time limit exceeded
18 Execution timed out 1083 ms 11436 KB Time limit exceeded
19 Execution timed out 1084 ms 12000 KB Time limit exceeded
20 Execution timed out 1077 ms 12796 KB Time limit exceeded