이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
int n, m;
struct column {
    int x[3];
    int dp = 1;
    bool operator<(const column &p) const {
        return x[1] < p.x[1];
    }
} cs[200000];
int cp[200000];
int seg[200001];
int find(int x, int n) {
    return lower_bound(cp, cp + n, x) - cp + 1;
}
int segn;
void init(int n) {
    segn = n;
    for (int i = 0; i <= n; ++i) seg[i] = 0;
}
void update(int i, int x) {
    while (i <= segn) {
        seg[i] = max(seg[i], x);
        i += i & -i;
    }
}
int query(int i) {
    int ret = 0;
    while (i) {
        ret = max(ret, seg[i]);
        i -= i & -i;
    }
    return ret;
}
void dnc(int s, int e) {
    if (s == e) return;
    int m = (s + e) / 2;
    int mx = cs[m].x[0];
    dnc(s, m);
    int tp = 0;
    for (int i = s; i <= e; ++i) {
        cp[tp++] = cs[i].x[2];
    }
    sort(cp, cp + tp);
    tp = unique(cp, cp + tp) - cp;
    init(tp);
    sort(cs + (m + 1), cs + (e + 1));
    for (int i = m + 1, j = s; i <= e; ++i) {
        while (j <= m && cs[j].x[1] <= cs[i].x[1]) 
            {
            update(find(cs[j].x[2], tp), cs[j].dp);
            ++j;
        }
        cs[i].dp = max(cs[i].dp, query(find(cs[i].x[2], tp)) + 1);
    }
    
	sort(cs + (m + 1), cs + (e + 1), [&](const column &x, const column &y) {
        return x.x[0] < y.x[0];
	});
	dnc(m + 1, e);
	sort(cs + s, cs + (e + 1));
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> m >> n;
	for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> cs[j].x[i];
        }
	}
	sort(cs, cs + n, [&](const column &x, const column &y) {
        return x.x[0] < y.x[0];
	});
	dnc(0, n - 1);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
        ans = max(ans, cs[i].dp);
	}
	printf("%d\n", ans);
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
matrix.cpp: In function 'void dnc(int, int)':
matrix.cpp:62:9: warning: unused variable 'mx' [-Wunused-variable]
     int mx = cs[m].x[0];
         ^~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |