QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#638474 | #7905. Ticket to Ride | lsj2009 | WA | 0ms | 8100kb | C++20 | 1.7kb | 2024-10-13 16:00:25 | 2024-10-13 16:00:29 |
Judging History
answer
#include<bits/stdc++.h>
//#pragma GCC optimize(3,"Ofast","inline")
//#define int long long
#define i128 __int128
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define ld double
#define PII pair<int,int>
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define chkmax(a,b) a=max(a,b)
#define chkmin(a,b) a=min(a,b)
#define rep(k,l,r) for(int k=l;k<=r;++k)
#define per(k,r,l) for(int k=r;k>=l;--k)
#define cl(f,x) memset(f,x,sizeof(f))
#define pcnt(x) __builtin_popcount(x)
#define lg(x) (31-__builtin_clz(x))
using namespace std;
void file_IO() {
// system("fc .out .ans");
freopen(".in","r",stdin);
freopen(".out","w",stdout);
}
bool M1;
const int N=1e4+5;
int f[N][N],g[N][N],w[N];
vector<PII> vec[N];
void solve() {
int n,m;
scanf("%d%d",&n,&m);
rep(i,0,n) {
rep(j,0,n)
f[i][j]=g[i][j]=0;
vec[i].clear();
}
while(m--) {
int l,r,val;
scanf("%d%d%d",&l,&r,&val);
vec[r].push_back(make_pair(l,val));
}
rep(i,0,n) {
rep(j,0,n)
f[i][j]=g[i][j]=-INF;
}
f[0][0]=g[0][0]=0;
rep(k,0,n) {
rep(i,0,n)
w[i]=-INF;
rep(i,k,n) {
int j=i-k;
g[i][j]=max(g[i-1][j],f[i-1][j]);
w[i]=g[i][j];
for(auto x:vec[i]) {
rep(p,0,x.first)
w[p]+=x.second;
}
int res=0;
rep(j,0,i-1)
chkmax(res,w[j]);
f[i][j]=res;
}
}
rep(i,1,n)
printf("%d ",max(f[n][i],g[n][i]));
puts("");
}
bool M2;
signed main() {
//file_IO();
int testcase=1;
scanf("%d",&testcase);
while(testcase--)
solve();
fprintf(stderr,"used time = %ldms\n",1000*clock()/CLOCKS_PER_SEC);
fprintf(stderr,"used memory = %lldMB\n",(&M2-&M1)/1024/1024);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5968kb
input:
2 4 3 0 2 3 3 4 2 0 3 1 3 1 1 3 100
output:
2 3 5 6 0 100 100
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 8100kb
input:
1000 2 9 0 2 396628655 1 2 268792718 0 2 16843338 1 2 717268783 0 1 693319712 0 1 856168102 1 2 407246545 1 2 527268921 0 1 536134606 6 2 2 5 451394766 0 5 695984050 9 7 0 6 73936815 2 9 505041862 4 5 223718927 5 7 179262261 3 5 449258178 0 5 493128 0 3 994723920 6 6 3 5 433389755 2 4 773727734 4 5 ...
output:
2085622420 859467400 86269249 86269249 451394766 451394766 1147378816 1147378816 223718927 672977105 994723920 1218442847 1668194153 1742130968 1921393229 1921393229 296171661 1571499973 1571499973 1614534784 1614534784 1614534784 1166346826 1286799108 1904646888 2143238271 2142663283 1892039465...
result:
wrong answer 1st lines differ - expected: '2085622420 4419671380', found: '2085622420 859467400 '