QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#116327 | #4776. Smoking gun | momoyuu | Compile Error | / | / | C++17 | 3.6kb | 2023-06-28 15:23:05 | 2023-06-28 15:23:09 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-28 15:23:09]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-06-28 15:23:05]
- 提交
answer
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cassert>
using namespace std;
using ll = long long;
template< typename flow_t >
struct Dinic {
const flow_t INF;
struct edge {
int to;
flow_t cap;
int rev;
bool isrev;
int idx;
};
vector< vector< edge > > graph;
vector< int > min_cost, iter;
Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}
void add_edge(int from, int to, flow_t cap, int idx = -1) {
graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
}
bool bfs(int s, int t) {
min_cost.assign(graph.size(), -1);
queue< int > que;
min_cost[s] = 0;
que.push(s);
while(!que.empty() && min_cost[t] == -1) {
int p = que.front();
que.pop();
for(auto &e : graph[p]) {
if(e.cap > 0 && min_cost[e.to] == -1) {
min_cost[e.to] = min_cost[p] + 1;
que.push(e.to);
}
}
}
return min_cost[t] != -1;
}
flow_t dfs(int idx, const int t, flow_t flow) {
if(idx == t) return flow;
for(int &i = iter[idx]; i < graph[idx].size(); i++) {
edge &e = graph[idx][i];
if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
flow_t d = dfs(e.to, t, min(flow, e.cap));
if(d > 0) {
e.cap -= d;
graph[e.to][e.rev].cap += d;
return d;
}
}
}
return 0;
}
flow_t max_flow(int s, int t) {
flow_t flow = 0;
while(bfs(s, t)) {
iter.assign(graph.size(), 0);
flow_t f = 0;
while((f = dfs(s, t, INF)) > 0) flow += f;
}
return flow;
}
void output() {
for(int i = 0; i < graph.size(); i++) {
for(auto &e : graph[i]) {
if(e.isrev) continue;
auto &rev_e = graph[e.to][e.rev];
cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
}
}
}
};
void solve(){
int n,m;
cin>>n>>m;
int h = n;int w = m;
Dinic<int> dinic(2*n*m+2);
int st = 2 * n * m;
int t = st + 1;
int a = 0;
int b = 0;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
vector<string> s(n);
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]=='.') continue;
int ni = i * w + j;
if(s[i][j]=='W'){
a++;
dinic.add_edge(ni,t,1);
continue;
}
b++;
dinic.add_edge(st,ni,1);
dinic.add_edge(st,ni+n*m,1);
for(int k = 0;k<4;k++){
int nni = i + dx[k];
int nnj = j + dy[k];
if(nni<0||nni>=n||nnj<0||nnj>=m) continue;
if(s[nni][nnj]!='W') continue;
if(k<2) dinic.add_edge(ni,nni*w+nnj,1);
else dinic.add_edge(ni+n*m,nni*w+nnj,1);
}
}
}
int can = dinic.max_flow(st,t);
if(a==2*b&&can==a) cout<<"YES\n";
else cout<<"NO\n";
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
solve();
}
}
详细
answer.code: In constructor ‘Dinic<flow_t>::Dinic(int)’: answer.code:24:24: error: ‘numeric_limits’ was not declared in this scope 24 | Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {} | ^~~~~~~~~~~~~~ answer.code:24:47: error: expected primary-expression before ‘>’ token 24 | Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {} | ^ answer.code:24:53: error: no matching function for call to ‘max()’ 24 | Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {} | ~~~~~^~ In file included from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: answer.code:24:53: note: candidate expects 2 arguments, 0 provided 24 | Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {} | ~~~~~^~ In file included from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: answer.code:24:53: note: candidate expects 3 arguments, 0 provided 24 | Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {} | ~~~~~^~ In file included from /usr/include/c++/11/algorithm:62, from answer.code:3: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’ 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: answer.code:24:53: note: candidate expects 1 argument, 0 provided 24 | Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {} | ~~~~~^~ In file included from /usr/include/c++/11/algorithm:62, from answer.code:3: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’ 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: answer.code:24:53: note: candidate expects 2 arguments, 0 provided 24 | Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {} | ~~~~~^~