Pagini recente » Cod sursa (job #736666) | Rating Stafie Ciprian Mihai (alcholistu) | Cod sursa (job #2511996) | Cod sursa (job #362373) | Cod sursa (job #2518894)
#include <fstream>
#include <vector>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
ifstream fin("cutii.in");
ofstream fout("cutii.out");
struct cutie {
int x, y, z;
bool operator<(const cutie &other) const {
return x < other.x && y < other.y && z < other.z;
}
} v[3510];
int n, t, res;
int dp[3510];
vector<cutie> p;
void cb(int st, int dr, cutie x) {
if(!p.size() || p[p.size()-1] < x) {
p.push_back(x);
return;
}
if(x < p[0]) {
p[0] = x;
return;
}
while(dr-st-1 > 0) {
int m = (st+dr) / 2;
if(p[m] < x) st = m;
else dr = m;
}
p[dr] = x;
}
bool cmp(cutie a, cutie b) {
if (a.x > b.x) return 0;
else if(a.x == b.x) {
if(a.y > b.y) return 0;
if(a.y == b.y) {
if(a.z > b.z) return 0;
else return 1;
}
else return 1;
}
else return 1;
}
void solve() {
while(t--) {
for(int i = 1; i <= n; i++)
fin >> v[i].x >> v[i].y >> v[i].z;
//sort(v+1, v+n+1, cmp);
/* res = 0;
memset(dp, -1, sizeof dp);
for(int i = 1; i <= n; i++) {
dp[i] = 1;
for(int j = i-1; j >= 1; j--)
if(v[j] < v[i] && dp[i] < dp[j]+1)
dp[i] = dp[j]+1;
if(dp[i] > res) res = dp[i];
}
fout << res << '\n';*/
p.clear();
for(int i = 1; i <= n; i++)
cb(0, p.size()-1, v[i]);
fout << p.size() << '\n';
}
}
int main() {
fin >> n >> t;
solve();
}