Cod sursa(job #2768111)

Utilizator ililogIlinca ililog Data 9 august 2021 15:21:56
Problema Cutii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.1 kb
#include <bits/stdc++.h>
using namespace std;

ifstream fin("cutii.in");
ofstream fout("cutii.out");

int n,t;
int dp[3501];
vector<int> v[3];

int main() {
    
    fin >> n >> t;
    
    for (int i = 1; i<=t; i++) {
        int nrmax = 1;
        int a, b, c;
        for (int j = 1; j<=n; j++) {
            fin >> a >> b >> c;
            v[j].push_back(a);
            v[j].push_back(b);
            v[j].push_back(c);
            
            sort(v[j].begin(), v[j].end());
            //cout << v[j][0] << " " << v[j][1] << " " << v[j][2] << endl;
        }
        
        dp[1] = 1;
        //cout << "1 ";
        for (int j = 2; j<=n; j++) {
            dp[j] = 1;
            for (int k = 1; k<=j; k++) {
                if (v[k][0] < v[j][0] && v[k][1] < v[j][1] && v[k][2] < v[j][2]) {
                    dp[j] = max(dp[j], dp[k]+1);
                }
            }
            
           // cout << dp[j] << " ";
            nrmax = max(nrmax, dp[j]);
        }
        //cout << endl << endl;
        
        fout << nrmax << endl;
    }
    
    return 0;
}