QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#819874 | #9810. Obliviate, Then Reincarnate | Magical_Kingdom | Compile Error | / | / | C++20 | 3.7kb | 2024-12-18 17:55:07 | 2024-12-18 17:55:08 |
Judging History
This is the latest submission verdict.
- [2024-12-18 17:55:08]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-12-18 17:55:07]
- Submitted
answer
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const int maxn = 5e5 + 7;
ll n, m, q;
struct Edge {
ll v, w;
Edge(ll _v = 0, ll _w = 0)
: v(_v), w(_w) {}
};
vector<Edge> to[maxn];
ll dfn[maxn], low[maxn], cnt, tot;
ll vis[maxn], belong[maxn], index, belong_num[maxn], num_index;
ll indegree[maxn], outdegree[maxn];
stack<ll> st;
void tarjin(ll x) {
dfn[x] = low[x] = ++tot;
vis[x] = 1;
st.push(x);
for (auto [v, w] : to[x]) {
if (!dfn[v]) {
tarjin(v);
low[x] = min(low[x], low[v]);
} else if (vis[v] == 1) {
low[x] = min(low[x], dfn[v]);
}
}
if (dfn[x] == low[x]) {
ll v;
index = index + 1;
do {
v = st.top();
st.pop();
belong[v] = index;
belong_num[index]++;
vis[v] = 0;
} while (v != x);
}
}
ll stk[maxn], top, loc[maxn];
ll sum_min[maxn], sum_max[maxn];
bool in_stk[maxn];
set<int> visited;
bool can[maxn];
void dfs(int u) {
stk[++top] = u;
loc[u] = top;
map<ll, pll> mp;
for (auto [v, w] : to[u]) {
if (belong[v] != belong[u]) {
continue;
}
if (mp.find(v) == mp.end()) {
mp[v].first = mp[v].second = w;
} else {
mp[v].first = min(w, mp[v].first);
mp[v].second = max(w, mp[v].second);
}
}
for (auto [v, w] : mp) {
ll wmin = w.first, wmax = w.second;
if (in_stk[v] == true) {
if (sum_max[top] - sum_max[loc[v]] + wmax == 0 &&
sum_min[top] - sum_min[loc[v]] + wmin == 0) {
continue;
} else {
can[belong[u]] = true;
loc[u] = 0;
stk[top--] = 0;
return;
}
}
if (visited.find(v) != visited.end()) {
continue;
}
visited.insert(v);
in_stk[v] = true;
sum_min[top + 1] = sum_min[top] + wmin;
sum_max[top + 1] = sum_max[top] + wmax;
dfs(v);
sum_min[top + 1] = 0;
sum_max[top + 1] = 0;
in_stk[v] = false;
if (can[belong[u]] == true) {
loc[u] = 0;
stk[top--] = 0;
return;
}
}
loc[u] = 0;
stk[top--] = 0;
return;
}
set<int> nto[maxn];
void dfs2(int u) {
can[u] = true;
for (auto v : nto[u]) {
if (!can[v]) {
dfs2(v);
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> q;
for (int i = 1; i <= m; i++) {
ll u, w;
cin >> u >> w;
ll v = u + w;
u = (u % n + n) % n;
v = (v % n + n) % n;
to[u].push_back(Edge(v, w));
}
for (int i = 0; i < n; i++) {
if (!dfn[i]) {
tarjin(i);
}
}
for (int i = 1; i <= index; i++) {
visited.clear();
top = 0;
sum_min[i] = sum_max[i] = 0;
in_stk[i] = 1;
dfs(i);
in_stk[i] = 0;
}
for (int u = 0; u < n; u++) {
for (auto e : to[u]) {
int v = e.v;
if (belong[u] != belong[v]) {
nto[belong[v]].insert(belong[u]);
}
}
}
for (int i = 1; i <= index; i++) {
if (can[i] == true) {
dfs2(i);
}
}
while (q--) {
ll x;
cin >> x;
x = (x % n + n) % n;
if (can[belong[x]]) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
return 0;
}
詳細信息
answer.code:15:29: error: ‘long long int index’ redeclared as different kind of entity 15 | ll vis[maxn], belong[maxn], index, belong_num[maxn], num_index; | ^~~~~ In file included from /usr/include/string.h:432, from /usr/include/c++/13/cstring:42, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:121, from answer.code:1: /usr/include/strings.h:61:1: note: previous declaration ‘const char* index(const char*, int)’ 61 | index (const char *__s, int __c) __THROW | ^~~~~ answer.code: In function ‘void tarjin(long long int)’: answer.code:32:23: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator+’ 32 | index = index + 1; | ~~~~~~^~~ answer.code:36:25: error: cannot resolve overloaded function ‘index’ based on conversion to type ‘long long int’ 36 | belong[v] = index; | ^~~~~ answer.code:37:23: error: invalid types ‘long long int [500007][<unresolved overloaded function type>]’ for array subscript 37 | belong_num[index]++; | ^ answer.code: In function ‘int main()’: answer.code:131:23: error: invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator<=’ 131 | for (int i = 1; i <= index; i++) { | ~~^~~~~~~~ answer.code:149:23: error: invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator<=’ 149 | for (int i = 1; i <= index; i++) { | ~~^~~~~~~~