QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#665589 | #8333. Gift | Fighoh# | Compile Error | / | / | C++20 | 2.8kb | 2024-10-22 14:16:41 | 2024-10-22 14:16:43 |
Judging History
answer
#include <climits>
#include <iostream>
#include <random>
#include <vector>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fir first
#define sec second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define lowbit(a) (a & (-a))
#define SZ(a) ((int)a.size())
#define all(a) a.begin(), a.end()
constexpr int N = 2e5 + 50;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 998244353;
constexpr int dir[4][2] = {
{-1, 0},
{ 0, 1},
{ 1, 0},
{ 0, -1},
};
mt19937_64 rnd(random_device{}());
uniform_int_distribution<ull> dist(0, ULLONG_MAX); // use dist(rnd)
vector<int>to[N];
int d[N],tmp[N];
multiset<int>st;
void solve() {
int n;
cin>>n;
for(int i=1;i<=n;i++){
int u,v;
cin>>u>>v;
to[u].push_back(v);
to[v].push_back(u);
d[u]++;
d[v]++;
}
queue<int>q;
int cnt[2];
for(int i=1;i<=n;i++){
tmp[i]=d[i];
st.insert(d[i]);
if(d[i]==1){
q.push(i);
}
cnt[d[i]<=3]++;
}
vector<int>vis(n+1);
while(!q.empty()){
int x=q.front();
q.pop();
vis[x]=1;
for(auto it:to[x]){
tmp[it]--;
if(tmp[it]==1){
q.push(it);
}
}
}
int Ans=0;
for(int i=1;i<=n;i++){
if(!vis[i]){
for(auto it:to[i]){
if(!vis[it]){
st.erase(st.lower_bound(d[i]));
st.erase(st.lower_bound(d[it]));
st.insert(d[i]-1);
st.insert(d[it]-1);
if(d[i]-1==3){
cnt[1]++;
cnt[0]--;
}
if(d[it]-1==3){
cnt[1]++;
cnt[0]--;
}
if(*st.begin()<=3&&*st.rbegin()<=4){
Ans+=d[1];
}
st.erase(st.lower_bound(d[i]-1));
st.erase(st.lower_bound(d[it]-1));
st.insert(d[i]);
st.insert(d[it]);
if(d[i]-1==3){
cnt[0]++;
cnt[1]--;
}
if(d[it]-1==3){
cnt[0]++;
cnt[1]--;
}
}
}
}
}
cout<<Ans/2<<'\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int _ = 1;
while (_--)
solve();
return 0;
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:46:5: error: ‘queue’ was not declared in this scope 46 | queue<int>q; | ^~~~~ answer.code:6:1: note: ‘std::queue’ is defined in header ‘<queue>’; did you forget to ‘#include <queue>’? 5 | #include <set> +++ |+#include <queue> 6 | using namespace std; answer.code:46:11: error: expected primary-expression before ‘int’ 46 | queue<int>q; | ^~~ answer.code:52:13: error: ‘q’ was not declared in this scope 52 | q.push(i); | ^ answer.code:57:12: error: ‘q’ was not declared in this scope 57 | while(!q.empty()){ | ^