Submission #160489

# Submission time Handle Problem Language Result Execution time Memory
160489 2019-10-27T20:08:12 Z jhnah917 None (KOI18_matrix) C++14
100 / 100
311 ms 36152 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

struct asdf{
    int a, b, c;
    asdf(int a = 0, int b = 0, int c = 0) : a(a), b(b), c(c) {}
    bool operator < (const asdf &t) const {
        if(a != t.a) return a < t.a;
        if(b != t.b) return b < t.b;
        return c < t.c;
    }
};

int k, n;
int arr[4][202020];
vector<asdf> tmp;
vector<p> v;
set<p> st[202020];

int solve(){
    int ans = 0;
    for(int i=0; i<n; i++){
        int l = 1, r = ans + 1;
        while(l < r){
            int m = l + r >> 1;
            auto it = st[m].lower_bound(v[i]);
            if(it == st[m].begin()) r = m;
            else{
                if(prev(it)->y < v[i].y) l = m + 1;
                else r = m;
            }
        }
        ans = max(ans, l);
        auto it = st[l].insert(v[i]).first;
        it++;
        while(it != st[l].end() && it->y >= v[i].y){
            auto tmp = it; it++;
            st[l].erase(tmp);
        }
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> k >> n;
    for(int i=1; i<=3; i++) for(int j=1; j<=n; j++){
        if(k < i) arr[i][j] = arr[i-1][j];
        else cin >> arr[i][j];
    }

    for(int i=1; i<=n; i++) tmp.pb({arr[1][i], arr[2][i], arr[3][i]});
    sort(all(tmp));
    for(auto &i : tmp) v.pb({i.b, i.c});
    cout << solve();
}

Compilation message

matrix.cpp: In function 'int solve()':
matrix.cpp:32:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int m = l + r >> 1;
                     ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 17 ms 10680 KB Output is correct
2 Correct 16 ms 10684 KB Output is correct
3 Correct 16 ms 10680 KB Output is correct
4 Correct 16 ms 10680 KB Output is correct
5 Correct 16 ms 10680 KB Output is correct
6 Correct 16 ms 11148 KB Output is correct
7 Correct 15 ms 10680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 10932 KB Output is correct
2 Correct 19 ms 11060 KB Output is correct
3 Correct 19 ms 10936 KB Output is correct
4 Correct 36 ms 10836 KB Output is correct
5 Correct 19 ms 10780 KB Output is correct
6 Correct 18 ms 11188 KB Output is correct
7 Correct 20 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 10680 KB Output is correct
2 Correct 16 ms 10684 KB Output is correct
3 Correct 16 ms 10680 KB Output is correct
4 Correct 16 ms 10680 KB Output is correct
5 Correct 16 ms 10680 KB Output is correct
6 Correct 16 ms 11148 KB Output is correct
7 Correct 15 ms 10680 KB Output is correct
8 Correct 138 ms 24648 KB Output is correct
9 Correct 134 ms 24604 KB Output is correct
10 Correct 131 ms 24544 KB Output is correct
11 Correct 115 ms 24748 KB Output is correct
12 Correct 132 ms 24688 KB Output is correct
13 Correct 139 ms 27868 KB Output is correct
14 Correct 132 ms 24544 KB Output is correct
15 Correct 114 ms 24672 KB Output is correct
16 Correct 144 ms 34140 KB Output is correct
17 Correct 145 ms 27804 KB Output is correct
18 Correct 138 ms 27004 KB Output is correct
19 Correct 132 ms 24724 KB Output is correct
20 Correct 135 ms 24660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 10932 KB Output is correct
2 Correct 19 ms 11060 KB Output is correct
3 Correct 19 ms 10936 KB Output is correct
4 Correct 36 ms 10836 KB Output is correct
5 Correct 19 ms 10780 KB Output is correct
6 Correct 18 ms 11188 KB Output is correct
7 Correct 20 ms 10808 KB Output is correct
8 Correct 196 ms 29200 KB Output is correct
9 Correct 185 ms 27836 KB Output is correct
10 Correct 195 ms 32728 KB Output is correct
11 Correct 168 ms 36036 KB Output is correct
12 Correct 150 ms 26592 KB Output is correct
13 Correct 191 ms 30940 KB Output is correct
14 Correct 217 ms 26604 KB Output is correct
15 Correct 171 ms 31880 KB Output is correct
16 Correct 171 ms 31940 KB Output is correct
17 Correct 195 ms 27656 KB Output is correct
18 Correct 268 ms 26528 KB Output is correct
19 Correct 152 ms 26664 KB Output is correct
20 Correct 205 ms 27836 KB Output is correct
21 Correct 170 ms 31808 KB Output is correct
22 Correct 272 ms 26464 KB Output is correct
23 Correct 184 ms 27604 KB Output is correct
24 Correct 153 ms 26596 KB Output is correct
25 Correct 240 ms 26604 KB Output is correct
26 Correct 311 ms 36152 KB Output is correct
27 Correct 150 ms 26596 KB Output is correct
28 Correct 172 ms 31912 KB Output is correct
29 Correct 187 ms 27660 KB Output is correct
30 Correct 191 ms 27692 KB Output is correct
31 Correct 297 ms 36060 KB Output is correct
32 Correct 188 ms 27612 KB Output is correct