Submission #557234

# Submission time Handle Problem Language Result Execution time Memory
557234 2022-05-04T22:22:00 Z NintsiChkhaidze trapezoid (balkan11_trapezoid) C++14
5 / 100
204 ms 42928 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;
queue <pair<pair<int,int>,pair<int,int> > > q;
vector <pair<pair<int,int>,int> > vec;

void upd(int h,int l,int r,int idx,int val1,int val2){
    if (l == r){
        if (val1 == t[h].f) t[h].s = (val2 + t[h].s)%mod;
        else if (val1 > t[h].f) 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;
    
    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({{a[i],b[i]},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,x=vec[i].f.f,y=vec[i].f.s;
        while(q.size() && q.front().f.f < x){
            upd(1,1,N-5,q.front().f.s,q.front().s.f,q.front().s.s);
            q.pop();
        }
        
        pair <int,int> pr = get(1,1,N-5,1,c[id]);
        int len = pr.f,cnt = pr.s;
        if (len == 0) cnt=1;
        q.push({{b[id],d[id]},{len+1,cnt}});
    }
    
    while(q.size()){
        upd(1,1,N-5,q.front().f.s,q.front().s.f,q.front().s.s);
        q.pop();
    }
    cout<<t[1].f<<" "<<t[1].s;
}

Compilation message

trapezoid.cpp: In function 'int main()':
trapezoid.cpp:50:13: warning: unused variable 'mn' [-Wunused-variable]
   50 |         int mn = min({a[i],b[i],c[i],d[i]});
      |             ^~
trapezoid.cpp:56: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]
   56 |     for (int i=0;i<v.size();i++){
      |                  ~^~~~~~~~~
trapezoid.cpp:61:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for (int i = 0; i < vec.size(); i++){
      |                     ~~^~~~~~~~~~~~
trapezoid.cpp:62:40: warning: unused variable 'y' [-Wunused-variable]
   62 |         int id = vec[i].s,x=vec[i].f.f,y=vec[i].f.s;
      |                                        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 1 ms 596 KB Output isn't correct
4 Incorrect 2 ms 724 KB Output isn't correct
5 Incorrect 4 ms 1620 KB Output isn't correct
6 Incorrect 7 ms 4724 KB Output isn't correct
7 Incorrect 8 ms 3796 KB Output isn't correct
8 Incorrect 9 ms 2360 KB Output isn't correct
9 Incorrect 18 ms 4720 KB Output isn't correct
10 Incorrect 39 ms 17580 KB Output isn't correct
11 Incorrect 53 ms 15584 KB Output isn't correct
12 Incorrect 116 ms 32260 KB Output isn't correct
13 Incorrect 127 ms 34488 KB Output isn't correct
14 Incorrect 147 ms 34036 KB Output isn't correct
15 Incorrect 154 ms 33440 KB Output isn't correct
16 Incorrect 182 ms 38884 KB Output isn't correct
17 Incorrect 174 ms 41604 KB Output isn't correct
18 Incorrect 169 ms 32700 KB Output isn't correct
19 Incorrect 175 ms 38072 KB Output isn't correct
20 Incorrect 204 ms 42928 KB Output isn't correct