QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#123667 | #1197. Draw in Straight Lines | Diu | Compile Error | / | / | C++14 | 2.0kb | 2023-07-13 10:47:22 | 2023-07-13 10:47:24 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-13 10:47:24]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-13 10:47:22]
- 提交
answer
#include<bits/stdc++.h>
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;
const int N=1e5+10,Inf=1e8;
int T,n,m,a,b,c,s,t;
struct edge{
int v,w,nxt;
}e[N];
int hd[N],tot;
void add(int u,int v,int w){e[++tot]={v,w,hd[u]},hd[u]=tot;}
void Add(int u,int v,int w){add(u,v,w),add(v,u,0);}
int id(int k,int x,int y){return k*n*m+(x-1)*m+y;}
char ch[N];
int lev[N];
bool bfs(){
for(int i=1;i<=t;i++)lev[i]=-1;
lev[s]=1;queue<int> q;q.push(s);
while(!q.empty()){
int u=q.front();q.pop();
for(int i=hd[u];i;i=e[i].nxt){
int v=e[i].v;
if(e[i].w&&lev[v]==-1){
lev[v]=lev[u]+1,q.push(v);
if(v==t)return 1;
}
}
}
return 0;
}
int dfs(int u,int in){
if(u==t)return in;
int out=0;
for(int i=hd[u];i;i=e[i].nxt){
int v=e[i].v;
if(e[i].w&&lev[v]==lev[u]+1){
int use=dfs(v,min(e[i].w,in));
e[i].w-=use,out+=use;
e[i^1].w+=use,in-=use;
if(!in)break;
}
}
if(!out)lev[u]=-1;
return out;
}
int dinic(){
int ans=0;
while(bfs())ans+=dfs(s,Inf);
return ans;
}
signed main(){
// file("color");
// scanf("%d",&T);
for(T=1;T--;){
scanf("%d%d%d%d%d",&n,&m,&a,&b,&c);
tot=1;
s=n*m*4+1,t=s+1;
for(int i=1;i<=t;i++)hd[i]=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
Add(s,id(0,i,j),a);
if(j<m)Add(id(0,i,j+1),id(0,i,j),b);
else Add(s,id(0,i,j),b);
Add(s,id(1,i,j),a);
if(i<n)Add(id(1,i+1,j),id(1,i,j),b);
else Add(s,id(1,i,j),b);
Add(id(2,i,j),t,a);
if(j<m)Add(id(2,i,j),id(2,i,j+1),b);
else Add(id(2,i,j),t,b);
Add(id(3,i,j),t,a);
if(i<n)Add(id(3,i,j),id(3,i+1,j),b);
else Add(id(3,i,j),t,b);
}
}
for(int i=1;i<=n;i++){
scanf("\n%s",ch+1);
for(int j=1;j<=m;j++){
if(ch[j]=='#'){
Add(id(0,i,j),id(3,i,j),c);
Add(s,id(1,i,j),Inf);
Add(id(2,i,j),t,Inf);
}else{
Add(id(1,i,j),id(0,i,j),c);
Add(id(3,i,j),id(2,i,j),c);
Add(id(3,i,j),id(0,i,j),Inf);
}
}
}
printf("%d\n",dinic());
// }
}
Details
answer.code: In function ‘int main()’: answer.code:90:2: error: expected ‘}’ at end of input 90 | } | ^ answer.code:50:14: note: to match this ‘{’ 50 | signed main(){ | ^ answer.code:54:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 54 | scanf("%d%d%d%d%d",&n,&m,&a,&b,&c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:75:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 75 | scanf("\n%s",ch+1); | ~~~~~^~~~~~~~~~~~~