Submission #557228

# Submission time Handle Problem Language Result Execution time Memory
557228 2022-05-04T21:53:53 Z NintsiChkhaidze trapezoid (balkan11_trapezoid) C++14
12 / 100
193 ms 48144 KB
#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define ll long long
#define int ll
#define left (h<<1),l,((l+r)>>1)
#define right ((h<<1)|1),((l+r)>>1) + 1,r
using namespace std;
const int N = 400005,mod = 30013;
map <int,int> mp;
int a[N],b[N],c[N],d[N];
pair <int,int> t[4*N];
vector <int> v;
vector <pair<int,int> > vec;

void build(int h,int l,int r){
    if (l == r){
        t[h] = {0,1};
        return;
    }
    build(left),build(right);
    if (t[h*2].f > t[h*2 + 1].f) t[h] = t[h*2];
    else if (t[h*2].f < t[h*2 + 1].f) t[h] = t[h*2 + 1];
    else t[h] = {t[h*2].f,(t[h*2].s + t[h*2+1].s)%mod};
}
void upd(int h,int l,int r,int idx,int val1,int val2){
    if (l == r){
        t[h] = {val1,val2};
        return;
    }
    if(idx > (l+r)/2) upd(right,idx,val1,val2);
    else upd(left,idx,val1,val2);
    
    if (t[h*2].f > t[h*2 + 1].f) t[h] = t[h*2];
    else if (t[h*2].f < t[h*2 + 1].f) t[h] = t[h*2 + 1];
    else t[h] = {t[h*2].f,(t[h*2].s + t[h*2+1].s)%mod};
}
pair<int,int> get(int h,int l,int r,int L,int R){
    if (r < L || R < l) return {0,0};
    if (L <= l && r <= R) return t[h];
    pair <int,int> a = get(left,L,R),b = get(right,L,R);
    if (a.f > b.f) return a;
    if (b.f > a.f) return b;
    return {a.f,(a.s + b.s)%mod};
}
signed main() {
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    cin>>n;
    
    build(1,1,N-5);
    for (int i = 1; i <= n; i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        v.pb(a[i]);
        v.pb(b[i]);
        v.pb(c[i]);
        v.pb(d[i]);
        int mn = min({a[i],b[i],c[i],d[i]});
        vec.pb({mn,i});
    }
    sort(v.begin(),v.end());
    sort(vec.begin(),vec.end());
    int k=0;
    for (int i=0;i<v.size();i++){
        if (!i || v[i] != v[i - 1]) k++;
        mp[v[i]] = k;
    }
    
    for (int i = 0; i < vec.size(); i++){
        int id = vec[i].s,mn = vec[i].f;
        int mx = max({a[id],b[id],c[id],d[id]});
        pair <int,int> pr = get(1,1,N-5,1,mn);
        // cout<<"id = "<<id<<" | "<<pr.f<<" & "<<pr.s<<endl;
        int len = pr.f,cnt = pr.s;
        upd(1,1,N-5, mx, len + 1,cnt);
        // cout<<"id = "<<id<<" | "<<mn<<" * "<<mx<<" "<<len + 1<<" "<<cnt<<endl;
    }
    
    cout<<t[1].f<<" "<<t[1].s;
}

Compilation message

trapezoid.cpp: In function 'int main()':
trapezoid.cpp:65:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (int i=0;i<v.size();i++){
      |                  ~^~~~~~~~~
trapezoid.cpp:70:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for (int i = 0; i < vec.size(); i++){
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 9 ms 16724 KB Partially correct
2 Partially correct 12 ms 16708 KB Partially correct
3 Incorrect 10 ms 16852 KB Output isn't correct
4 Partially correct 11 ms 16980 KB Partially correct
5 Incorrect 13 ms 17364 KB Output isn't correct
6 Incorrect 15 ms 17796 KB Output isn't correct
7 Partially correct 16 ms 17616 KB Partially correct
8 Incorrect 17 ms 18132 KB Output isn't correct
9 Incorrect 27 ms 20112 KB Output isn't correct
10 Partially correct 45 ms 21444 KB Partially correct
11 Incorrect 63 ms 25088 KB Output isn't correct
12 Incorrect 105 ms 33812 KB Output isn't correct
13 Incorrect 122 ms 36496 KB Output isn't correct
14 Incorrect 148 ms 40944 KB Output isn't correct
15 Incorrect 167 ms 39220 KB Output isn't correct
16 Incorrect 168 ms 40752 KB Output isn't correct
17 Incorrect 168 ms 44692 KB Output isn't correct
18 Partially correct 174 ms 37428 KB Partially correct
19 Incorrect 193 ms 47144 KB Output isn't correct
20 Incorrect 190 ms 48144 KB Output isn't correct