QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#451452 | #8304. Key Project | -Ofast | Compile Error | / | / | C++20 | 4.6kb | 2024-06-23 13:35:02 | 2024-06-23 13:35:02 |
Judging History
answer
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5e4+10;
vector <int> P[N],Q[N];
int n,m,dis[N],a[N],b[N],c[N],d[N];
namespace MCMF{
const int N=1e6+10;
int n,s,t,head[N],to[N],nxt[N],f[N],tmphead[N],c[N],cnt=-1;
ll maxflow,mincost;
void add(int u,int v,int fl,int w){
++cnt;
nxt[cnt]=head[u];
head[u]=cnt;to[cnt]=v;
f[cnt]=fl;c[cnt]=w;
++cnt;
nxt[cnt]=head[v];
head[v]=cnt;to[cnt]=u;
f[cnt]=0;c[cnt]=-w;
}
ll dis[N];int vis[N],pre[N][2];
struct Queue{
int head,tail,a[N];
void push(int x){a[++tail]=x;}
void pop(){++head;}
int size(){return tail-head+1;}
int front(){return a[head];}
}q;
void SPFA(){
q.head=q.tail=0;
for(int i=0;i<=n;i++)dis[i]=1e18,vis[i]=0;
q.push(s);vis[s]=1;dis[s]=0;
int cur=0;
while(q.size()){
int u=q.front();q.pop();
cur^=1;
vis[u]=0;
for(int i=head[u];~i;i=nxt[i]){
int v=to[i],w=c[i];
if(!f[i])continue;
if(dis[v]>dis[u]+w){
dis[v]=dis[u]+w;
pre[v][0]=u;
pre[v][1]=i;
if(!vis[v]){
q.push(v);vis[v]=1;
}
}
}
}
}
int pid[N],qid[N];
void solve(){
while(true){
int tmp=cnt;
for(int i=0;i<=n;i++)tmphead[i]=head[i];
for(int i=1;i<=::n;i++){
if(P[i].size())add(s,i,1,P[i].back()),pid[i]=cnt;
if(Q[i].size())add(i,t,1,Q[i].back()),qid[i]=cnt;
}
SPFA();
if(dis[t]==1e18)return;
ll minf=1e9,sumc=0;int now=t;
vector <int> path;
while(now!=s){
path.push_back(pre[now][1]);
minf=min(minf,1ll*f[pre[now][1]]);
sumc+=c[pre[now][1]];
now=pre[now][0];
}
for(int i=0;i<path.size();i++){
f[path[i]]-=minf;
f[path[i]^1]+=minf;
}
for(int i=1;i<=::n;i++){
if(P[i].size()&&f[pid[i]])P[i].pop_back();
if(Q[i].size()&&f[qid[i]])Q[i].pop_back();
}
cnt=tmp;
for(int i=0;i<=n;i++)head[i]=tmphead[i];
mincost+=1ll*minf*sumc;
cout<<mincost<<"\n";
}
}
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
memset(MCMF::head,-1,sizeof(MCMF::head));
cin>>n>>m;
for(int i=1;i<n;i++)
cin>>dis[i];
for(int i=1;i<=m;i++)
cin>>a[i]>>b[i];
for(int i=1;i<=m;i++)
cin>>c[i]>>d[i];
MCMF::t=n+1;
MCMF::s=0;
MCMF::n=MCMF::t;
for(int i=1;i<n;i++){
MCMF::add(i,i+1,1e9,dis[i]);
MCMF::add(i+1,i,1e9,dis[i]);
}
for(int i=1;i<=m;i++){
Q[a[i]].push_back(b[i]);
}
for(int i=1;i<=m;i++){
P[c[i]].push_back(d[i]);
}
for(int i=1;i<=n;i++){
sort(Q[i].begin(),Q[i].end());
sort(P[i].begin(),P[i].end());
reverse(Q[i].begin(),Q[i].end());
reverse(P[i].begin(),P[i].end());
}
MCMF::solve();
cerr<<1.0*clock()/CLOCKS_PER_SEC<<endl;
return 0;
}
详细
answer.code:22:39: warning: bad option ‘-fwhole-program’ to pragma ‘optimize’ [-Wpragmas] 22 | #pragma GCC optimize("-fwhole-program") | ^ answer.code:29:41: warning: bad option ‘-fstrict-overflow’ to pragma ‘optimize’ [-Wpragmas] 29 | #pragma GCC optimize("-fstrict-overflow") | ^ answer.code:31:41: warning: bad option ‘-fcse-skip-blocks’ to pragma ‘optimize’ [-Wpragmas] 31 | #pragma GCC optimize("-fcse-skip-blocks") | ^ answer.code:45:51: warning: bad option ‘-funsafe-loop-optimizations’ to pragma ‘optimize’ [-Wpragmas] 45 | #pragma GCC optimize("-funsafe-loop-optimizations") | ^ answer.code:59:42: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 59 | void add(int u,int v,int fl,int w){ | ^ answer.code:59:42: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:59:42: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:59:42: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:72:32: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 72 | void push(int x){a[++tail]=x;} | ^ answer.code:72:32: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:72:32: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:72:32: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:73:26: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 73 | void pop(){++head;} | ^ answer.code:73:26: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:73:26: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:73:26: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:74:26: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 74 | int size(){return tail-head+1;} | ^ answer.code:74:26: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:74:26: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:74:26: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:75:27: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 75 | int front(){return a[head];} | ^ answer.code:75:27: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:75:27: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:75:27: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:77:19: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 77 | void SPFA(){ | ^ answer.code:77:19: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:77:19: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:77:19: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:101:20: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 101 | void solve(){ | ^ answer.code:101:20: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:101:20: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:101:20: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:134:10: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 134 | int main(){ | ^ answer.code:134:10: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:134:10: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:134:10: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] In file included from /usr/include/c++/13/string:43, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from answer.code:49: /usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()’: /usr/include/c++/13/bits/...