This commit is contained in:
Zengtudor 2024-08-18 11:22:56 +08:00
parent ac9c9571af
commit 261a9ea6ce
12 changed files with 300685 additions and 6 deletions

View File

@ -40,12 +40,12 @@ int main(){
}
for(int i=1;i<=m;i++){
for(int j=n;j>=0;j--){
if(items[i].subNum==2&&j>=(items[i+1].v+items[i+2].v)){
dp[j]=max(dp[j],dp[j-(items[i+1].v+items[i+2].v)]+(items[i+1].v*items[i+1].p)+(items[i+2].v*items[i+2].p));
}else if((items[i].subNum==2&&j>=items[i+1].v) || (items[i].subNum==1&&j>=items[i+1].v)){
dp[j]=max(dp[j],dp[j-items[i+1].v]+(items[i+1].v*items[i+1].p));
}else if(items[i].subNum==2&&j>=items[i+2].v){
dp[j]=max(dp[j],dp[j-items[i+2].v]+(items[i+2].v*items[i+2].p));
if(items[i].subNum==2&&j>=(items[i].v+items[i+1].v+items[i+2].v)){
dp[j]=max(dp[j],dp[j-(items[i].v+items[i+1].v+items[i+2].v)]+(items[i].v*items[i].p)+(items[i+1].v*items[i+1].p)+(items[i+2].v*items[i+2].p));
}else if((items[i].subNum==2&&j>=(items[i].v+items[i+1].v)) || (items[i].subNum==1&&j>=(items[i].v+items[i+1].v))){
dp[j]=max(dp[j],dp[j-(items[i].v+items[i+1].v)]+(items[i].v*items[i].p)+(items[i+1].v*items[i+1].p));
}else if(items[i].subNum==2&&j>=(items[i].v+items[i+2].v)){
dp[j]=max(dp[j],dp[j-(items[i].v+items[i+2].v)]+(items[i].v*items[i].p)+(items[i+2].v*items[i+2].p));
}else if(j>=items[i].v){
dp[j] = max(dp[j],dp[j-items[i].v]+items[i].v*items[i].p);
}

4
day14/P3367/1.ans Normal file
View File

@ -0,0 +1,4 @@
N
Y
N
Y

8
day14/P3367/1.in Normal file
View File

@ -0,0 +1,8 @@
4 7
2 1 2
1 1 2
2 1 2
1 3 4
2 1 4
1 2 3
2 1 4

62
day14/P3367/P3367.cpp Normal file
View File

@ -0,0 +1,62 @@
#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
const int MAX_N=1e4+114;
int n,m;
int b[MAX_N];
inline int readint();
inline int getfather(int n);
inline int getroot(int n);
inline void pre(int n);
#define PV(v){cout<<#v<<" : "<<(v)<<endl;}
#define L(m){cout<<"[LOG]: "<<(m)<<endl;}
int main(){
n=readint(),m=readint();
pre(n);
for(int i=1;i<=m;i++){
const int z=readint(),x=readint(),y=readint();
if(z==1){
b[getroot(x)]=getroot(y);
}else{
cout<<(getroot(x)==getroot(y)?"Y":"N")<<endl;
}
}
}
void pre(int n){
for(int i=1;i<=n;i++){
b[i]=i;
}
}
int getroot(int n){
int r=getfather(n);
while(r!=getfather(r)){
r=b[r]=b[b[r]];
}
return r;
}
int getfather(int n){
return b[n];
}
int readint(){
int x=0,w=1;
char ch=0;
while (!isdigit(ch)) {
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
x=x*10+(ch-'0');
ch=getchar();
}
return x*w;
}

9
day14/P3367/P3367.json Normal file
View File

@ -0,0 +1,9 @@
{
"files":["P3367.cpp"],
"args":["-O3","-Wall"],
"tests":[
{"in":"1.in","ans":"1.ans"},
{"in":"P3367_2.in","ans":"P3367_2.out"}
],
"runtimeout":1000
}

200001
day14/P3367/P3367_2.in Normal file

File diff suppressed because it is too large Load Diff

100521
day14/P3367/P3367_2.out Normal file

File diff suppressed because it is too large Load Diff

8
day14/P3865/1.ans Normal file
View File

@ -0,0 +1,8 @@
9
9
7
7
9
8
7
9

10
day14/P3865/1.in Normal file
View File

@ -0,0 +1,10 @@
8 8
9 3 1 7 5 6 0 8
1 6
1 5
2 7
2 6
1 8
4 8
3 7
1 8

48
day14/P3865/P3865.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int readint();
const int MAX_N = 1e5+5;
const int MAX_LN = 20;
int s[MAX_N][MAX_LN];
int m,n;
int l2[MAX_N];
int main(){
n=readint(),m=readint();
l2[1]=0;
for(int i=2;i<=n;i++){
l2[i]=l2[i/2]+1;
}
for(int i=1;i<=n;i++){
s[i][0]=readint();
}
for (int j=1;j<=l2[n]; j++) {
for(int i=1;i<=n-(1<<j)+1;i++){
s[i][j]=max(s[i][j-1],s[i+(1<<(j-1))][j-1]);
}
}
for(int i=1;i<=m;i++){
const int l=readint(),r=readint();
int j = l2[r-l+1];
cout<<max(s[l][j],s[r-(1<<j)+1][j])<<endl;
}
}
int readint(){
int x=0,w=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
x=x*10+(ch-'0');
ch=getchar();
}
return x*w;
}

8
day14/P3865/P3865.json Normal file
View File

@ -0,0 +1,8 @@
{
"files":["P3865.cpp"],
"args":["-O2","-Wall"],
"tests":[
{"in":"1.in","ans":"1.ans"}
],
"runtimeout":1000
}

0
day14/P5788/P5788.cpp Normal file
View File