QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#329018 | #1197. Draw in Straight Lines | Dualqwq | Compile Error | / | / | C++20 | 2.4kb | 2024-02-16 11:57:37 | 2024-02-16 11:57:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5,M = 2e6 + 5;
int tot;
namespace Flow {
int fir[N],nxt[M],to[M],w[M],ect = 1;
inline void addedge(int u1,int v1,int w1) {
nxt[++ect] = fir[u1];fir[u1] = ect;to[ect] = v1;w[ect] = w1;
}
inline void ins(int u1,int v1,int w1) { addedge(u1,v1,w1);addedge(v1,u1,0);}
int dep[N],cur[N];
inline bool bfs(int S,int T) {
for(int i = 1;i <= tot;i++) cur[i] = fir[i],dep[i] = 1e9;
queue<int> Q;Q.push(S);dep[S] = 0;
while(!Q.empty()) {
int x = Q.front();Q.pop();
for(int i = fir[x],y;y = to[i],i;i = nxt[i])
if(dep[y] > dep[x] + 1 && w[i])
dep[y] = dep[x] + 1,Q.push(y);
}
return dep[T] < 1e9;
}
int dfs(int u,int t,int limit) {
if(u == t || !limit) return limit;
int flow = 0,f;
for(int i = cur[u],v;v = to[i],i;i = nxt[i]) {
cur[u] = i;
if((dep[v] == dep[u] + 1) && w[i] && (f = dfs(v,t,min(limit,w[i])))) {
flow += f;
limit -= f;
w[i] -= f;w[i ^ 1] += f;
if(!limit) break;
}
}
return flow;
}
inline int dinic(int S,int T) {
int res = 0;
while(bfs(S,T)) res += dfs(S,T,2e9);
return res;
}
}
int n,m;
int A,B,C;
char s[45][45];
int id[45][45][4];
int main() {
cin >> n >> m;
cin >> A >> B >> C;
for(int i = 1;i <= n;i++) cin >> (s[i] + 1);
for(int i = 1;i <= n;i++)
for(int j = 1;j <= m;j++)
for(int k = 0;k < 4;k++) id[i][j][k] = ++tot;
int S = ++tot,T = ++tot;
for(int i = 1;i <= n;i++)
for(int j = 1;j <= m;j++) {
Flow::ins(id[i][j][0],T,A); // x = 1 才有贡献
Flow::ins(S,id[i][j][1],A); // x = 0 才有贡献
Flow::ins(S,id[i][j][2],A);
Flow::ins(id[i][j][3],T,A);
if(j < m) {
Flow::ins(id[i][j][0],id[i][j + 1][0],B);
Flow::ins(id[i][j + 1][2],id[i][j][2],B);
} else {
Flow::ins(id[i][j][0],T,B);
Flow::ins(S,id[i][j][2],B);
}
if(i < n) {
Flow::ins(id[i + 1][j][1],id[i][j][1],B);
Flow::ins(id[i][j][3],id[i + 1][j][3],B);
} else {
Flow::ins(S,id[i][j][1],B);
Flow::ins(id[i][j][3],T,B);
}
if(s[i][j] == '#') {
Flow::ins(id[i][j][1],id[i][j][0],C);
Flow::ins(id[i][j][3],T,2e9);
Flow::ins(S,id[i][j][2],2e9);
}
if(s[i][j] == '.') {
Flow::ins(id[i][j][0],id[i][j][3],C);
Flow::ins(id[i][j][2],id[i][j][1],C);
Flow::ins(id[i][j][0],id[i][j][1],2e9);
}
}
cout << Flow::dinic(S,T) << endl;
return 0;
}
詳細信息
answer.code: In function ‘int main()’: answer.code:50:39: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’) 50 | for(int i = 1;i <= n;i++) cin >> (s[i] + 1); | ~~~ ^~ ~~~~~~~~~~ | | | | | char* | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/13/sstream:40, from /usr/include/c++/13/complex:45, from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127, from answer.code:1: /usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 325 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/13/istream:325:7: note: conversion of argument 1 would be ill-formed: answer.code:50:48: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’ 50 | for(int i = 1;i <= n;i++) cin >> (s[i] + 1); | ~~~~~~^~~~ /usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 201 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:201:7: note: conversion of argument 1 would be ill-formed: answer.code:50:48: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive] 50 | for(int i = 1;i <= n;i++) cin >> (s[i] + 1); | ~~~~~~^~~~ | | | char* answer.code:50:48: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& s[i])) + 1)’ to ‘long long unsigned int&’ /usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 197 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:197:7: note: conversion of argument 1 would be ill-formed: answer.code:50:48: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive] 50 | for(int i = 1;i <= n;i++) cin >> (s[i] + 1); | ~~~~~~^~~~ | | | char* answer.code:50:48: error: cannot bind rvalue ‘(long long int)(((char*)(& s[i])) + 1)’ to ‘long long int&’ /usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:192:7: note: conversion of argument 1 would be ill-formed: answer.code:50:48: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive] 50 | for(int i = 1;i <= n;i++) cin >> (s[i] + 1); | ~~~~~~^~~~ | | | char* answer.code:50:48: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& s[i])) + 1)’ to ‘long unsigned int&’ /usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:188:7: note: conversion of argument 1 would be ill-formed: answer.code:50:48: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive] 50 | for(int i = 1;i <= n;i++) cin >> (s[i] + 1); | ~~~~~~^~~~ | | | char* answer.code:50:48: error: cannot bind rvalue ‘(long int)(((char*)(& s[i])) + 1)’ to ‘long int&’ /usr/include/c++/13/istream:184:7: note: ca...