QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#762471 | #5114. Cells Coloring | PoonYaPat | Compile Error | / | / | C++14 | 2.0kb | 2024-11-19 15:07:25 | 2024-11-19 15:07:26 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define sz(x) (int)(x.size())
typedef vector<int> vi;
typedef pair<int,int> pii;
#define ll short;
struct Dinic {
struct Edge {
int to, rev;
ll c, oc;
ll flow() { return max(oc - c, 0LL); }
};
vi lvl, ptr, q;
vector<vector<Edge>> adj;
Dinic(int n) : lvl(n), ptr(n), q(n), adj(n) {}
void addEdge(int a, int b, ll c, ll rcap = 0) {
adj[a].push_back({b, sz(adj[b]), c, c});
adj[b].push_back({a, sz(adj[a]) - 1, rcap, rcap});
}
ll dfs(int v, int t, ll f) {
if (v == t || !f) return f;
for (int& i = ptr[v]; i < sz(adj[v]); i++) {
Edge& e = adj[v][i];
if (lvl[e.to] == lvl[v] + 1)
if (ll p = dfs(e.to, t, min(f, e.c))) {
e.c -= p, adj[e.to][e.rev].c += p;
return p;
}
}
return 0;
}
ll calc(int s, int t) {
ll flow = 0; q[0] = s;
rep(L,30,31) do {
lvl = ptr = vi(sz(q));
int qi = 0, qe = lvl[s] = 1;
while (qi < qe && !lvl[t]) {
int v = q[qi++];
for (Edge e : adj[v])
if (!lvl[e.to] && e.c >> (30 - L))
q[qe++] = e.to, lvl[e.to] = lvl[v] + 1;
}
while (ll p = dfs(s, t, LLONG_MAX)) flow += p;
} while (lvl[t]);
return flow;
}
bool leftOfMinCut(int a) { return lvl[a] != 0; }
};
int n,m;
long long c,d,cnt;
string s[255];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m>>c>>d;
for (int i=0; i<n; ++i) cin>>s[i];
for (int i=0; i<n; ++i) for (int j=0; j<m; ++j) if (s[i][j]=='.') ++cnt;
long long ans=cnt*d;
for (ll k=1; k<=250; ++k) {
if (rand()%4==0) continue;
Dinic dnc=Dinic(n+m+2);
for (int i=0; i<n; ++i) for (int j=0; j<m; ++j) if (s[i][j]=='.') dnc.addEdge(i,j+n,1);
for (int i=0; i<n; ++i) dnc.addEdge(n+m,i,k);
for (int i=n; i<n+m; ++i) dnc.addEdge(i,n+m+1,k);
ll res=dnc.calc(n+m,n+m+1);
ans=min(ans, c*k+d*(cnt-res));
if (res==cnt) break;
}
cout<<ans<<"\n";
}
Details
answer.code:8:12: error: declaration does not declare anything [-fpermissive] 8 | #define ll short; | ^~~~~ answer.code:13:17: note: in expansion of macro ‘ll’ 13 | ll c, oc; | ^~ answer.code:13:20: error: ‘c’ does not name a type 13 | ll c, oc; | ^ answer.code:8:12: error: declaration does not declare anything [-fpermissive] 8 | #define ll short; | ^~~~~ answer.code:14:17: note: in expansion of macro ‘ll’ 14 | ll flow() { return max(oc - c, 0LL); } | ^~ answer.code:14:20: error: ISO C++ forbids declaration of ‘flow’ with no type [-fpermissive] 14 | ll flow() { return max(oc - c, 0LL); } | ^~~~ answer.code:8:17: error: expected ‘)’ before ‘;’ token 8 | #define ll short; | ^ answer.code:21:36: note: in expansion of macro ‘ll’ 21 | void addEdge(int a, int b, ll c, ll rcap = 0) { | ^~ answer.code:21:21: note: to match this ‘(’ 21 | void addEdge(int a, int b, ll c, ll rcap = 0) { | ^ answer.code:21:39: error: ‘c’ does not name a type 21 | void addEdge(int a, int b, ll c, ll rcap = 0) { | ^ answer.code:21:45: error: ‘rcap’ does not name a type 21 | void addEdge(int a, int b, ll c, ll rcap = 0) { | ^~~~ answer.code:8:12: error: declaration does not declare anything [-fpermissive] 8 | #define ll short; | ^~~~~ answer.code:26:9: note: in expansion of macro ‘ll’ 26 | ll dfs(int v, int t, ll f) { | ^~ answer.code:8:17: error: expected ‘)’ before ‘;’ token 8 | #define ll short; | ^ answer.code:26:30: note: in expansion of macro ‘ll’ 26 | ll dfs(int v, int t, ll f) { | ^~ answer.code:26:15: note: to match this ‘(’ 26 | ll dfs(int v, int t, ll f) { | ^ answer.code:26:12: error: ISO C++ forbids declaration of ‘dfs’ with no type [-fpermissive] 26 | ll dfs(int v, int t, ll f) { | ^~~ answer.code:26:33: error: ‘f’ does not name a type 26 | ll dfs(int v, int t, ll f) { | ^ answer.code:8:12: error: declaration does not declare anything [-fpermissive] 8 | #define ll short; | ^~~~~ answer.code:39:9: note: in expansion of macro ‘ll’ 39 | ll calc(int s, int t) { | ^~ answer.code:39:12: error: ISO C++ forbids declaration of ‘calc’ with no type [-fpermissive] 39 | ll calc(int s, int t) { | ^~~~ answer.code: In member function ‘int Dinic::Edge::flow()’: answer.code:14:40: error: ‘oc’ was not declared in this scope 14 | ll flow() { return max(oc - c, 0LL); } | ^~ answer.code:14:45: error: ‘c’ was not declared in this scope 14 | ll flow() { return max(oc - c, 0LL); } | ^ answer.code: In member function ‘int Dinic::calc(int, int)’: answer.code:8:12: error: declaration does not declare anything [-fpermissive] 8 | #define ll short; | ^~~~~ answer.code:40:17: note: in expansion of macro ‘ll’ 40 | ll flow = 0; q[0] = s; | ^~ answer.code:40:20: error: ‘flow’ was not declared in this scope 40 | ll flow = 0; q[0] = s; | ^~~~ answer.code:47:61: error: ‘struct Dinic::Edge’ has no member named ‘c’ 47 | if (!lvl[e.to] && e.c >> (30 - L)) | ^ answer.code:8:17: error: expected unqualified-id before ‘;’ token 8 | #define ll short; | ^ answer.code:50:32: note: in expansion of macro ‘ll’ 50 | while (ll p = dfs(s, t, LLONG_MAX)) flow += p; | ^~ answer.code:8:17: error: expected ‘)’ before ‘;’ token 8 | #define ll short; | ^ answer.code:50:32: note: in expansion of macro ‘ll’ 50 | while (ll p = dfs(s, t, LLONG_MAX)) flow += p; | ^~ answer.code:50:31: note: to match this ‘(’ 50 | while (ll p = dfs(s, t, LLONG_MAX)) flow += p; | ^ answer.code:50:35: error: ‘p’ was not declared in this scope 50 | while (ll p = dfs(s, t, LLONG_MAX)) flow += p; | ^ answer.code:50:49: warning: overflow in conversion from ‘long long int’ to ‘short int’ changes value from ‘9223372036854775807’ to ‘-1’ [-...