QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#225046 | #6406. Stage Clear | ucup-team1004 | WA | 888ms | 4152kb | C++14 | 1.6kb | 2023-10-23 21:27:37 | 2023-10-23 21:27:38 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=36+5,M=N*40+5,K=(1<<25)+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,m;ll A[N],B[N];
vector<int> S[N];
struct Node{
ll x,y;
Node operator +(const Node &B)const{return (Node){x+max(B.x-(x+y),0ll),y+B.y};}
bool operator <(const Node &B)const{
if((y>0)^(B.y>0)) return (y>0)>(B.y>0);
if(y>0) return x<B.x;
return x+y>B.x+B.y;
}
}w[N];
int vis[N];
void Solve(){
int i,j;scanf("%d%d",&n,&m);
for(i=2;i<=n;i++) scanf("%lld%lld",&A[i],&B[i]);
while(m--){int x,y;scanf("%d%d",&x,&y);S[x].emplace_back(y);}
ll ans=INF;
while(clock()*1.0/CLOCKS_PER_SEC<0.95){
Node tot=(Node){0,0};Me(vis,0);
for(int i:S[1]) vis[i]=1;
for(i=2;i<=n;i++) {
vector<pair<Node,int> > pus;
for(j=2;j<=n;j++) if(vis[j]==1) pus.emplace_back((Node){A[j],B[j]},j);
sort(pus.begin(),pus.end());
for(j=0;j<pus.size();j++) if(R(2)==1||j+1==pus.size()) {
int id=pus[j].se;vis[id]=-1;
for(int h:S[id]) if(!vis[h]) vis[h]=1;
tot=tot+pus[j].fi;
break;
}
}
ans=min(ans,tot.x);
}
printf("%lld\n",ans);
}
int main(){
int t;
// scanf("%d",&t);
t=1;
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 642ms
memory: 4036kb
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: 888ms
memory: 4152kb
input:
15 14 254040392438309 117083115436273 500005748229691 557255157630172 821034233718230 865199673774998 659892147898798 987564141425694 81172575487567 811635577877255 751768357864605 341103322647288 454926350150218 140191090713900 921608121471585 659295670987251 223751724062143 505619245326640 8907765...
output:
367841861670175
result:
wrong answer 1st numbers differ - expected: '1665396301509143', found: '367841861670175'