Solution with online query 3D DP
#include <bits/stdc++.h>#define mod 1000000007#define ll long long#define infi (1<<29)#define f(i,j) for(int i=0;i<j;i++)#define pb(i) push_back(i)#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);using namespace std;typedef vector<vector<long long> > matrix;int main(){fasterint t;cin>>t;for(int h=1;h<=t;h++){ll n,p,q,k,s,d;cin>>n;ll dp[n+1][n+1][n+1];f(i,n-1)for(int j=i+1;j<=n-1;j++){dp[i+1][i+1][0]=0;dp[j+1][j+1][0]=0;cin>>dp[i+1][j+1][0];