#include "closing.h"
#include<bits/stdc++.h>
#include<random>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)
using namespace std;
ll n , x , y , k;
vector<pll> adj[200009];
ll vis[200009];
vector<pll> v , xx , yy;
vector<ll> c;
int max_score(int N, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
n=N;
x=X;
y=Y;
k=K;
v.clear();
xx.clear();
yy.clear();
c.clear();
for(int i = 0 ; n>i ; i++)
{
adj[i].clear();
vis[i]=0;
}
for(int i = 0 ; n-1>i ; i++)
{
adj[U[i]].pb({V[i],W[i]});
adj[V[i]].pb({U[i],W[i]});
}
ll d = 0;
for(int i = x ; i>=0 ; i--)
{
xx.pb({d,x-i+1});
if(i)
d+=W[i-1];
}
d=0;
for(int i = y ; n>i ; i++)
{
yy.pb({d,i-y+1});
if(i<n-1)
d+=W[i];
}
for(auto it1 : xx)
for(auto it2 : yy)
v.pb({it1.F+it2.F,it1.S+it2.S});
sort(v.begin(),v.end());
ll mx = 0;
for(auto it : v)
{
mx=max(mx,it.S);
c.pb(mx);
}
ll ans = 0;
ll fcost = 0;
for(int i = x ; n>i ; i++)
{
for(int j = y ; j>=0 ; j--)
{
for(int i1 = x ; i1>=0 ; i1--)
{
for(int i2 = y ; n>i2 ; i2++)
{
ll vs[n];
memset(vs,-1,sizeof(vs));
d=0;
for(int h = x ; i>=h ; h++)
{
vs[h]=max(vs[h],d);
if(h<n-1)
d+=W[h];
}
d=0;
for(int h = y ; h>=j ; h--)
{
vs[h]=max(vs[h],d);
if(h)
d+=W[h-1];
}
d=0;
for(int h = x ; h>=i1 ; h--)
{
vs[h]=max(vs[h],d);
if(h)
d+=W[h-1];
}
d=0;
for(int h = y ; i2>=h ; h++)
{
vs[h]=max(vs[h],d);
if(h<n-1)
d+=W[h];
}
ll cost = 0;
ll ans1 = 0;
for(int i = 0 ; n>i ; i++)
{
if(vs[i]!=-1)
{
ans1++;
cost+=vs[i];
}
}
if(cost>k)
continue;
ans=max(ans,ans1);
}
}
}
}
return ans;
}
Compilation message
closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:75:8: warning: unused variable 'fcost' [-Wunused-variable]
75 | ll fcost = 0;
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6488 KB |
1st lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1104 ms |
1261876 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Incorrect |
2 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Incorrect |
2 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Incorrect |
2 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6488 KB |
1st lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6488 KB |
1st lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6488 KB |
1st lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6488 KB |
1st lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6488 KB |
1st lines differ - on the 1st token, expected: '6', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |