QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#699229 | #6765. Don't Really Like How The Story Ends | beamishboys# | WA | 234ms | 3628kb | C++23 | 930b | 2024-11-02 06:46:35 | 2024-11-02 06:46:36 |
Judging History
answer
#include <iostream>
#include <vector>
#include <set>
using namespace std;
using vi = vector<int>;
void solve() {
int n, m; cin >> n >> m;
vector<set<int, greater<int>>> adj(n+1);
vi vis(n+1);
for (int i = 0; i < m; i++) {
int u, v; cin >> u >> v;
adj[u].insert(v);
adj[v].insert(u);
}
vi st;
st.push_back(1);
int out = 0;
while (st.size()) {
int top = st.back();
st.pop_back();
if (top == n) break;
vis[top] = true;
vi nex = {adj[top].begin(), adj[top].end()};
for (int i : nex) {
if (vis[i]) {
adj[top].erase(i);
adj[i].erase(top);
}
}
if (st.size() && adj[top].size() == 0 && st.back() == top+1) continue;
if (adj[top].count(top+1) == 0) {
adj[top].insert(top+1);
adj[top+1].insert(top);
out++;
}
for (int i : adj[top]) st.push_back(i);
}
cout << out << endl;
}
int main() {
int t; cin >> t;
while (t--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
3 2 3 1 1 1 2 2 1 4 1 1 4 4 2 1 2 3 4
output:
0 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 234ms
memory: 3628kb
input:
117747 3 7 2 1 3 3 1 3 1 1 3 2 1 1 3 1 4 8 2 3 4 3 3 2 4 2 1 3 2 1 4 3 2 4 3 4 2 3 2 2 3 3 1 1 2 5 1 1 2 2 2 2 1 2 2 2 3 7 2 1 1 2 3 3 3 2 1 2 3 3 3 2 4 5 1 2 3 3 4 4 1 4 2 1 3 1 3 2 1 3 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 5 4 2 1 2 5 1 3 3 2 4 7 1 1 2 4 3 2 1 1 1 1 4 2 2 3 5 8 3 3 2 2 4 2 1 4 1...
output:
0 0 1 0 0 1 1 0 0 1 1 1 0 0 2 0 2 0 1 0 0 3 0 0 0 2 1 1 1 0 0 0 2 0 3 1 3 0 2 0 3 1 2 1 0 0 1 2 0 2 0 1 2 0 0 2 0 0 0 1 0 3 0 1 0 0 1 0 0 3 2 0 0 0 1 0 2 3 0 1 1 1 1 0 0 2 1 3 0 1 2 0 0 0 3 0 0 3 1 0 2 0 0 0 1 0 1 0 0 0 0 4 0 0 0 0 0 0 2 0 2 1 0 1 1 0 0 2 0 1 0 0 0 2 0 1 2 1 0 0 0 1 0 0 1 1 1 0 0 0 ...
result:
wrong answer 35th lines differ - expected: '2', found: '3'