QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#464928 | #6406. Stage Clear | dengrk | WA | 6ms | 13868kb | C++14 | 1.2kb | 2024-07-06 16:12:37 | 2024-07-06 16:12:37 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N=72,N1=20;
const long long PIN=4557430888798830399;
int n,m;
int len_list=0,e[N],ne[N],h[N];
long long a[N],b[N],f[1<<N1],g[1<<N1];
void add_once(int a,int b){
e[len_list]=b;
ne[len_list]=h[a];
h[a]=len_list;
len_list++;
}
long long solve1(){
int i,j,k,x,y;
long long s1;
for(i=1;i<n;i++)
scanf("%lld%lld",&a[i],&b[i]);
for(i=1;i<(1<<n);i++)
for(j=0;j<n;j++){
if(i>>j&1) continue;
g[i]+=b[j]-a[j];
}
memset(h,-1,sizeof h);
for(i=1;i<=m;i++){
scanf("%d%d",&x,&y);
add_once(--x,--y);
}
memset(f,PIN,sizeof f);
f[0]=PIN,f[1]=0;
for(i=1;i<(1<<n);i+=2)
for(j=0;j<n;j++){
if(!(i>>j&1)) continue;
for(k=h[j];k>=0;k=ne[k]){
if(i>>e[k]&1) continue;
s1=max(f[i],a[e[k]]-g[i]);
f[i|(1<<e[k])]=min(f[i|(1<<e[k])],s1);
}
}
return f[(1<<n)-1];
}
long long solve2(){
return 0;
}
int main(){
// freopen("HP.in","r",stdin);
// freopen("HP.out","w",stdout);
scanf("%d%d",&n,&m);
if(n<=N1) printf("%lld",solve1());
else printf("%lld",solve2());
// fclose(stdin);
// fclose(stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 12884kb
input:
4 4 4 2 5 3 2 6 1 2 1 3 2 4 3 4
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: -100
Wrong Answer
time: 6ms
memory: 13868kb
input:
15 14 254040392438309 117083115436273 500005748229691 557255157630172 821034233718230 865199673774998 659892147898798 987564141425694 81172575487567 811635577877255 751768357864605 341103322647288 454926350150218 140191090713900 921608121471585 659295670987251 223751724062143 505619245326640 8907765...
output:
2430295914489149
result:
wrong answer 1st numbers differ - expected: '1665396301509143', found: '2430295914489149'