QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#88473 | #4107. 墙上的句子 | Jekyll_Y | Compile Error | / | / | C++14 | 6.5kb | 2023-03-16 11:55:52 | 2023-03-16 11:55:55 |
Judging History
This is the latest submission verdict.
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-03-16 11:55:55]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2023-03-16 11:55:52]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int N = 705;
int n, m, cnt, ans, tot;
int S, T, head[N], depth[N];#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int N = 705;
int n, m, cnt, ans, tot;
int S, T, head[N], depth[N];
int r[N], c[N];
char s[N][N];
queue<int> q;
set<string> p;
map<string, int> id;
struct edge
{
int v, c, next;
edge(int V = 0, int C = 0, int N = 0) :
v(V), c(C), next(N) {}
} e[N * N];
void add(int u, int v, int c)
{
e[++tot] = edge(v, c, head[u]), head[u] = tot;
e[++tot] = edge(u, 0, head[v]), head[v] = tot;
}
int bfs()
{
memset(depth, 0, sizeof(depth));
depth[S] = 1;
q.push(S);
while(!q.empty())
{
int u = q.front();
q.pop();
for(int i = head[u]; i; i = e[i].next)
{
int v = e[i].v;
if(e[i].c > 0 && !depth[v])
{
depth[v] = depth[u] + 1;
q.push(v);
}
}
}
if(!depth[T])
return 0;
return 1;
}
int dfs(int u, int in)
{
if(u == T)
return in;
int flow = 0, res = 0;
for(int i = head[u]; i; i = e[i].next)
{
int v = e[i].v;
if(depth[u] + 1 == depth[v] && e[i].c)
{
res = dfs(v, min(e[i].c, in));
if(!res)
continue;
in -= res;
e[i].c -= res;
e[i ^ 1].c += res;
flow += res;
if(!in)
break;
}
}
return flow;
}
void build(string s, int tp, int u)
{
string a, b;
int len = s.length();
for(int i = 0, r, flag; i < len; i = r + 1)
{
r = i;
if(s[i] == '_')
continue;
while(r + 1 < len && s[r + 1] != '_')
r++;
a = s.substr(i, r - i + 1);
b = a;
reverse(b.begin(), b.end());
if(b < a)
swap(a, b), flag = -1;
else
flag = 1;
if(a == b)
{
p.insert(a);
continue;
}
if(!id.count(a))
{
id[a] = ++cnt;
id[b] = ++cnt;
add(id[a], id[b], 2);
}
flag *= tp;
if(flag == 1)
add(S, id[a], inf);
else if(flag == -1)
add(id[b], T, inf);
else
add(id[b], u, inf), add(u, id[a], inf);
}
}
void solve()
{
p.clear();
id.clear();
scanf("%d%d", &n, &m);
cnt = n + m;
for(int i = 1; i <= n; i++)
scanf("%d", &r[i]);
for(int i = 1; i <= m; i++)
scanf("%d", &c[i]);
for(int i = 1; i <= n; i++)
scanf("%s", s[i] + 1);
S = 0;
T = N - 1;
string tmp;
for(int i = 1; i <= n; i++)
{
tmp = s[i] + 1;
build(tmp, r[i], i);
}
for(int i = 1; i <= m; i++)
{
tmp = "";
for(int j = 1; j <= n; j++)
tmp += s[j][i];
build(tmp, c[i], i + n);
}
while(bfs())
ans += dfs(S, inf);
printf("%d\n", ans +(int)(p.size()));
}
int main()
{
int T; scanf("%d", &T);
while(T--)
{
tot = 1;
ans = 0;
memset(head, 0, sizeof(head));
solve();
}
return 0;
}
int r[N], c[N];
char s[N][N];
queue<int> q;
set<string> p;
map<string, int> id;
struct edge
{
int v, c, next;
edge(int V = 0, int C = 0, int N = 0) :
v(V), c(C), next(N) {}
} e[N * N];
void add_edge(int u, int v, int c)
{
e[++tot] = edge(v, c, head[u]), head[u] = tot;
e[++tot] = edge(u, 0, head[v]), head[v] = tot;
}
int bfs()
{
memset(depth, 0, sizeof(depth));
depth[S] = 1;
q.push(S);
while(!q.empty())
{
int u = q.front();
q.pop();
for(int i = head[u]; i; i = e[i].next)
{
int v = e[i].v;
if(e[i].c > 0 && !depth[v])
{
depth[v] = depth[u] + 1;
q.push(v);
}
}
}
if(!depth[T])
return 0;
return 1;
}
int dfs(int u, int in)
{
if(u == T)
return in;
int flow = 0, res = 0;
for(int i = head[u]; i; i = e[i].next)
{
int v = e[i].v;
if(depth[u] + 1 == depth[v] && e[i].c)
{
res = dfs(v, min(e[i].c, in));
if(!res)
continue;
in -= res;
e[i].c -= res;
e[i ^ 1].c += res;
flow += res;
if(!in)
break;
}
}
return flow;
}
void build(string s, int tp, int u)
{
string a, b;
int len = s.length();
for(int i = 0, r, flag; i < len; i = r + 1)
{
r = i;
if(s[i] == '_')
continue;
while(r + 1 < len && s[r + 1] != '_')
r++;
a = s.substr(i, r - i + 1);
b = a;
reverse(b.begin(), b.end());
if(b < a)
swap(a, b), flag = -1;
else
flag = 1;
if(a == b)
{
p.insert(a);
continue;
}
if(!id.count(a))
{
id[a] = ++cnt;
id[b] = ++cnt;
add_edge(id[a], id[b], 2);
}
flag *= tp;
if(flag == 1)
add_edge(S, id[a], inf);
else if(flag == -1)
add_edge(id[b], T, inf);
else
add_edge(id[b], u, inf), add_edge(u, id[a], inf);
}
}
void solve()
{
p.clear();
id.clear();
scanf("%d%d", &n, &m);
cnt = n + m;
for(int i = 1; i <= n; i++)
scanf("%d", &r[i]);
for(int i = 1; i <= m; i++)
scanf("%d", &c[i]);
for(int i = 1; i <= n; i++)
scanf("%s", s[i] + 1);
S = 0;
T = N - 1;
string tmp;
for(int i = 1; i <= n; i++)
{
tmp = s[i] + 1;
build(tmp, r[i], i);
}
for(int i = 1; i <= m; i++)
{
tmp = "";
for(int j = 1; j <= n; j++)
tmp += s[j][i];
build(tmp, c[i], i + n);
}
while(bfs())
ans += dfs(S, inf);
printf("%d\n", ans +(int)(p.size()));
}
int main()
{
int T; scanf("%d", &T);
while(T--)
{
tot = 1;
ans = 0;
memset(head, 0, sizeof(head));
solve();
}
return 0;
}
詳細信息
answer.code:11:29: error: stray ‘#’ in program 11 | int S, T, head[N], depth[N];#include <bits/stdc++.h> | ^ answer.code:11:30: error: ‘include’ does not name a type 11 | int S, T, head[N], depth[N];#include <bits/stdc++.h> | ^~~~~~~ answer.code:17:11: error: redefinition of ‘const int N’ 17 | const int N = 705; | ^ answer.code:7:11: note: ‘const int N’ previously defined here 7 | const int N = 705; | ^ answer.code:19:5: error: redefinition of ‘int n’ 19 | int n, m, cnt, ans, tot; | ^ answer.code:9:5: note: ‘int n’ previously declared here 9 | int n, m, cnt, ans, tot; | ^ answer.code:19:8: error: redefinition of ‘int m’ 19 | int n, m, cnt, ans, tot; | ^ answer.code:9:8: note: ‘int m’ previously declared here 9 | int n, m, cnt, ans, tot; | ^ answer.code:19:11: error: redefinition of ‘int cnt’ 19 | int n, m, cnt, ans, tot; | ^~~ answer.code:9:11: note: ‘int cnt’ previously declared here 9 | int n, m, cnt, ans, tot; | ^~~ answer.code:19:16: error: redefinition of ‘int ans’ 19 | int n, m, cnt, ans, tot; | ^~~ answer.code:9:16: note: ‘int ans’ previously declared here 9 | int n, m, cnt, ans, tot; | ^~~ answer.code:19:21: error: redefinition of ‘int tot’ 19 | int n, m, cnt, ans, tot; | ^~~ answer.code:9:21: note: ‘int tot’ previously declared here 9 | int n, m, cnt, ans, tot; | ^~~ answer.code:21:5: error: redefinition of ‘int S’ 21 | int S, T, head[N], depth[N]; | ^ answer.code:11:5: note: ‘int S’ previously declared here 11 | int S, T, head[N], depth[N];#include <bits/stdc++.h> | ^ answer.code:21:8: error: redefinition of ‘int T’ 21 | int S, T, head[N], depth[N]; | ^ answer.code:11:8: note: ‘int T’ previously declared here 11 | int S, T, head[N], depth[N];#include <bits/stdc++.h> | ^ answer.code:21:11: error: redefinition of ‘int head [705]’ 21 | int S, T, head[N], depth[N]; | ^~~~ answer.code:11:11: note: ‘int head [705]’ previously declared here 11 | int S, T, head[N], depth[N];#include <bits/stdc++.h> | ^~~~ answer.code:21:20: error: redefinition of ‘int depth [705]’ 21 | int S, T, head[N], depth[N]; | ^~~~~ answer.code:11:20: note: ‘int depth [705]’ previously declared here 11 | int S, T, head[N], depth[N];#include <bits/stdc++.h> | ^~~~~ answer.code:178:5: error: redefinition of ‘int r [705]’ 178 | int r[N], c[N]; | ^ answer.code:23:5: note: ‘int r [705]’ previously declared here 23 | int r[N], c[N]; | ^ answer.code:178:11: error: redefinition of ‘int c [705]’ 178 | int r[N], c[N]; | ^ answer.code:23:11: note: ‘int c [705]’ previously declared here 23 | int r[N], c[N]; | ^ answer.code:180:6: error: redefinition of ‘char s [705][705]’ 180 | char s[N][N]; | ^ answer.code:25:6: note: ‘char s [705][705]’ previously declared here 25 | char s[N][N]; | ^ answer.code:182:12: error: redefinition of ‘std::queue<int> q’ 182 | queue<int> q; | ^ answer.code:27:12: note: ‘std::queue<int> q’ previously declared here 27 | queue<int> q; | ^ answer.code:184:13: error: redefinition of ‘std::set<std::__cxx11::basic_string<char> > p’ 184 | set<string> p; | ^ answer.code:29:13: note: ‘std::set<std::__cxx11::basic_string<char> > p’ previously declared here 29 | set<string> p; | ^ answer.code:186:18: error: redefinition of ‘std::map<std::__cxx11::basic_string<char>, int> id’ 186 | map<string, int> id; | ^~ answer.code:31:18: note: ‘std::map<std::__cxx11::basic_string<char>, int> id’ previously declared here 31 | map<string, int> id; | ^~ answer.code:188:8: error: redefinition of ‘struct edge’ 188 | struct edge | ^~~~ answer.code:33:8: note: previous definition of ‘struct edge’ 33 | struct edge | ^~~~ answer.code:193:3: error: conflicting declaration ‘int e [497025]’ 193 | } e[N * N]; | ^ answer.code:38:3: note: previous declaration as ‘edge e [497025]’ 38 | } e[N * N]; | ^ answer.code:201:5: error: redefinition of ‘int bfs()’ 201 | int bfs() | ^~~ answer.code:46:5: note: ‘int bfs()’ previously defined here 46 | int bfs() | ^~~ answer.code:225:5: error: redefinition of ‘int dfs(int, int)’ 225 | int dfs(int u, int in) | ^~~ answer.code:70:5: note: ‘int dfs(int, int)’ previously defined here 70 | int dfs(int u, int in) | ^~~ answer.code:249:6: error: redefinition of ‘void build(std::string, int, int)’ 249 | void build(string s, int tp, int u) | ...