QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#450798 | #8304. Key Project | -Ofast | Compile Error | / | / | C++14 | 4.5kb | 2024-06-22 18:09:32 | 2024-06-22 18:09:32 |
Judging History
answer
#pragma GCC target("avx")
#pragma GCC optimize(3)
#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")
#include <bits/stdc++.h>
#define int 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;
int 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;
}
int dis[N],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]=1e9,vis[i]=0,pre[i][0]=pre[i][1]=0;
q.push(s);vis[s]=1;dis[s]=0;
while(q.size()){
int u=q.front();q.pop();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]==1e9)return;
int minf=1e9,sumc=0,now=t;
vector <int> path;
while(now!=s){
path.push_back(pre[now][1]);
minf=min(minf,f[pre[now][1]]);
sumc+=c[pre[now][1]];
now=pre[now][0];
}
for(auto it:path){
f[it]-=minf;
f[it^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+=minf*sumc;
cout<<mincost<<"\n";
}
}
}
signed 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();
return 0;
}
Details
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:58:42: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 58 | void add(int u,int v,int fl,int w){ | ^ answer.code:58:42: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:58:42: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:58:42: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:71:32: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 71 | void push(int x){a[++tail]=x;} | ^ answer.code:71:32: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:71:32: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:71:32: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:72:26: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 72 | void pop(){++head;} | ^ answer.code:72:26: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:72:26: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:72:26: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:73:26: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 73 | int size(){return tail-head+1;} | ^ 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:27: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 74 | int front(){return a[head];} | ^ answer.code:74:27: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:74:27: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:74:27: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:76:19: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 76 | void SPFA(){ | ^ answer.code:76:19: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:76:19: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:76:19: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:98:20: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 98 | void solve(){ | ^ answer.code:98:20: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:98:20: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:98:20: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes] answer.code:131:13: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes] 131 | signed main(){ | ^ answer.code:131:13: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes] answer.code:131:13: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes] answer.code:131:13: 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:48: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<long long int, std::allocator<long long int> >::_Vector_impl::~_Vector_impl()’: /usr/include/...