Submission #1100184

# Submission time Handle Problem Language Result Execution time Memory
1100184 2024-10-13T08:49:33 Z modwwe None (JOI16_worst_reporter2) C++17
100 / 100
390 ms 66220 KB
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC optimize("conserve-stack")
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar

inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while (c < '0' || c > '9')
    {
        c = getchar_unlocked();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar_unlocked();
    }
    return x;
}

void phongbeo();
const int inf = 1e9;
const int mod2 = 1e9 + 7;
const int  mod1 = 998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a, b, c;
};
struct id
{
    int a, b, c, d;
};
struct ie
{
    int a, b, c, d, e;

};

int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,t,lim,w,l,r;
int kk;
int el = 19;

main()
{
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    NHP
    /// cin>>s1;
///modwwe
    phongbeo();
    // checktime
}
set<int> s[400001];
set<int> cs;
vector<int> v;
vector<int> v2;
ib a[200001];
ib b[200001];
vector<int> sort1,sort2;
priority_queue<int,vector<int>>ask;
struct IT
{
    ib t[1600001];
    ib mer(ib a,ib b)
    {
        if(a.a<b.a) return a;
        else return b;
    }
    void upd(int node,int l,int r,int l1,int x)
    {
        if(l==r)
        {
            t[node].a=x;
            t[node].b=l;
            return;
        }
        int mid=l+r>>1;
        if(l1<=mid)
            upd(node<<1,l,mid,l1,x);
        else upd(node<<1|1,mid+1,r,l1,x);
        t[node]=mer(t[node<<1],t[node<<1|1]);
    }
    ib get(int node,int l,int r,int l1,int r1)
    {
        if(l>r1||r<l1||t[node].a==inf) return {inf,inf} ;
        if(l>=l1&&r<=r1) {
                return t[node];}
        int mid=l+r>>1;
        return mer(get(node<<1,l,mid,l1,r1),get(node<<1|1,mid+1,r,l1,r1));
    }
} st;
void phongbeo()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i].a>>a[i].b,sort1.pb(a[i].a),sort2.pb(a[i].b);
    for(int i=1; i<=n; i++)
        cin>>b[i].a>>b[i].b,sort1.pb(b[i].a),sort2.pb(b[i].b);
    sort(sort1.begin(),sort1.end());
    sort(sort2.begin(),sort2.end());
    for(int i=1; i<=n; i++)
        a[i].a=lower_bound(sort1.begin(),sort1.end(),a[i].a)-sort1.begin()+1,
            a[i].b=lower_bound(sort2.begin(),sort2.end(),a[i].b)-sort2.begin()+1,
                b[i].a=lower_bound(sort1.begin(),sort1.end(),b[i].a)-sort1.begin()+1,
                    b[i].b=lower_bound(sort2.begin(),sort2.end(),b[i].b)-sort2.begin()+1;
    k=n*2;
    for(int i=n; i>=1; --i)
        s[b[i].a].insert(b[i].b),
        cs.insert(b[i].b);
    for(int i=1; i<=4*k; i++)
        st.t[i]= {inf,inf};
    for(int i=1; i<=n; i++)
    {
        auto it=s[a[i].a].lower_bound(a[i].b);
        if(it==s[a[i].a].end())
            ask.push(a[i].b);
        else
        {
            st.upd(1,1,k,*it,a[i].b);
            s[a[i].a].erase(it);
            cs.erase(*it);
        }
    }
    for(auto x:cs)
        v.pb(x);
    reverse(v.begin(),v.end());
    l=0;
    while(!ask.empty())
    {
        int x=ask.top();
                    s4++;
        ask.pop();
        if(v[l]>=x)
        {
            l++;
            continue;
        }
        else
        {
            ib xx=st.get(1,1,k,x,k);
            ask.push({xx.a});
            st.upd(1,1,k,xx.b,inf);
        }
    }
    cout<<s4;
}

Compilation message

worst_reporter2.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main()
      | ^~~~
worst_reporter2.cpp: In member function 'void IT::upd(int, int, int, int, int)':
worst_reporter2.cpp:106:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  106 |         int mid=l+r>>1;
      |                 ~^~
worst_reporter2.cpp: In member function 'ib IT::get(int, int, int, int, int)':
worst_reporter2.cpp:117:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  117 |         int mid=l+r>>1;
      |                 ~^~
worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
worst_reporter2.cpp:73:9: note: in expansion of macro 'fin'
   73 |         fin(task);
      |         ^~~
worst_reporter2.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
worst_reporter2.cpp:74:9: note: in expansion of macro 'fou'
   74 |         fou(task);
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 22356 KB Output is correct
2 Correct 5 ms 22604 KB Output is correct
3 Correct 5 ms 22356 KB Output is correct
4 Correct 5 ms 22356 KB Output is correct
5 Correct 5 ms 22432 KB Output is correct
6 Correct 5 ms 22356 KB Output is correct
7 Correct 5 ms 22524 KB Output is correct
8 Correct 5 ms 22356 KB Output is correct
9 Correct 5 ms 22516 KB Output is correct
10 Correct 5 ms 22520 KB Output is correct
11 Correct 5 ms 22436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 22356 KB Output is correct
2 Correct 5 ms 22604 KB Output is correct
3 Correct 5 ms 22356 KB Output is correct
4 Correct 5 ms 22356 KB Output is correct
5 Correct 5 ms 22432 KB Output is correct
6 Correct 5 ms 22356 KB Output is correct
7 Correct 5 ms 22524 KB Output is correct
8 Correct 5 ms 22356 KB Output is correct
9 Correct 5 ms 22516 KB Output is correct
10 Correct 5 ms 22520 KB Output is correct
11 Correct 5 ms 22436 KB Output is correct
12 Correct 7 ms 22520 KB Output is correct
13 Correct 5 ms 22356 KB Output is correct
14 Correct 6 ms 22356 KB Output is correct
15 Correct 6 ms 22356 KB Output is correct
16 Correct 5 ms 22436 KB Output is correct
17 Correct 7 ms 22356 KB Output is correct
18 Correct 6 ms 22356 KB Output is correct
19 Correct 5 ms 22356 KB Output is correct
20 Correct 7 ms 22520 KB Output is correct
21 Correct 6 ms 22356 KB Output is correct
22 Correct 6 ms 22356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 22356 KB Output is correct
2 Correct 5 ms 22604 KB Output is correct
3 Correct 5 ms 22356 KB Output is correct
4 Correct 5 ms 22356 KB Output is correct
5 Correct 5 ms 22432 KB Output is correct
6 Correct 5 ms 22356 KB Output is correct
7 Correct 5 ms 22524 KB Output is correct
8 Correct 5 ms 22356 KB Output is correct
9 Correct 5 ms 22516 KB Output is correct
10 Correct 5 ms 22520 KB Output is correct
11 Correct 5 ms 22436 KB Output is correct
12 Correct 7 ms 22520 KB Output is correct
13 Correct 5 ms 22356 KB Output is correct
14 Correct 6 ms 22356 KB Output is correct
15 Correct 6 ms 22356 KB Output is correct
16 Correct 5 ms 22436 KB Output is correct
17 Correct 7 ms 22356 KB Output is correct
18 Correct 6 ms 22356 KB Output is correct
19 Correct 5 ms 22356 KB Output is correct
20 Correct 7 ms 22520 KB Output is correct
21 Correct 6 ms 22356 KB Output is correct
22 Correct 6 ms 22356 KB Output is correct
23 Correct 12 ms 25428 KB Output is correct
24 Correct 12 ms 25172 KB Output is correct
25 Correct 11 ms 25172 KB Output is correct
26 Correct 12 ms 25172 KB Output is correct
27 Correct 11 ms 25172 KB Output is correct
28 Correct 17 ms 25172 KB Output is correct
29 Correct 11 ms 25172 KB Output is correct
30 Correct 12 ms 25172 KB Output is correct
31 Correct 12 ms 25256 KB Output is correct
32 Correct 15 ms 25172 KB Output is correct
33 Correct 11 ms 25336 KB Output is correct
34 Correct 12 ms 25132 KB Output is correct
35 Correct 11 ms 25172 KB Output is correct
36 Correct 11 ms 25256 KB Output is correct
37 Correct 10 ms 25172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 22356 KB Output is correct
2 Correct 5 ms 22604 KB Output is correct
3 Correct 5 ms 22356 KB Output is correct
4 Correct 5 ms 22356 KB Output is correct
5 Correct 5 ms 22432 KB Output is correct
6 Correct 5 ms 22356 KB Output is correct
7 Correct 5 ms 22524 KB Output is correct
8 Correct 5 ms 22356 KB Output is correct
9 Correct 5 ms 22516 KB Output is correct
10 Correct 5 ms 22520 KB Output is correct
11 Correct 5 ms 22436 KB Output is correct
12 Correct 7 ms 22520 KB Output is correct
13 Correct 5 ms 22356 KB Output is correct
14 Correct 6 ms 22356 KB Output is correct
15 Correct 6 ms 22356 KB Output is correct
16 Correct 5 ms 22436 KB Output is correct
17 Correct 7 ms 22356 KB Output is correct
18 Correct 6 ms 22356 KB Output is correct
19 Correct 5 ms 22356 KB Output is correct
20 Correct 7 ms 22520 KB Output is correct
21 Correct 6 ms 22356 KB Output is correct
22 Correct 6 ms 22356 KB Output is correct
23 Correct 12 ms 25428 KB Output is correct
24 Correct 12 ms 25172 KB Output is correct
25 Correct 11 ms 25172 KB Output is correct
26 Correct 12 ms 25172 KB Output is correct
27 Correct 11 ms 25172 KB Output is correct
28 Correct 17 ms 25172 KB Output is correct
29 Correct 11 ms 25172 KB Output is correct
30 Correct 12 ms 25172 KB Output is correct
31 Correct 12 ms 25256 KB Output is correct
32 Correct 15 ms 25172 KB Output is correct
33 Correct 11 ms 25336 KB Output is correct
34 Correct 12 ms 25132 KB Output is correct
35 Correct 11 ms 25172 KB Output is correct
36 Correct 11 ms 25256 KB Output is correct
37 Correct 10 ms 25172 KB Output is correct
38 Correct 371 ms 66220 KB Output is correct
39 Correct 359 ms 65100 KB Output is correct
40 Correct 347 ms 64940 KB Output is correct
41 Correct 334 ms 64940 KB Output is correct
42 Correct 352 ms 64304 KB Output is correct
43 Correct 365 ms 62016 KB Output is correct
44 Correct 373 ms 61868 KB Output is correct
45 Correct 342 ms 62040 KB Output is correct
46 Correct 390 ms 62092 KB Output is correct
47 Correct 351 ms 63076 KB Output is correct
48 Correct 289 ms 61504 KB Output is correct
49 Correct 285 ms 61560 KB Output is correct
50 Correct 304 ms 61616 KB Output is correct
51 Correct 341 ms 61616 KB Output is correct
52 Correct 268 ms 61616 KB Output is correct