QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#880778 | #9983. Color-Balanced Tree | mortis_life | Compile Error | / | / | C++14 | 1.1kb | 2025-02-03 20:01:45 | 2025-02-03 20:01:45 |
Judging History
This is the latest submission verdict.
- [2025-02-03 20:01:45]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-02-03 20:01:45]
- Submitted
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+50;
int read() {
int x=0;short f=1;char s=getchar();
while(s<48||s>57){f=s=='-'?-1:1;s=getchar();}
while(s>=48&&s<=57){x=x*10+s-48;s=getchar();}
return x*f;
}
int n,siz[2],vis[N];
vector<int> v[N],Q[2];
int fa[N],dep[N];
void dfs(int p,int f) {
fa[p]=f;dep[p]=dep[f]+1;
siz[dep[p]%2]++;
if(p!=1&&v[p].size()==1) Q[dep[p]%2].push_back(p);
for(int i:v[p]) {
if(i==fa[p]) continue;
dfs(i,p);
}
return ;
}
void check() {
cin>>n;
for(int i=1,u,v1;i<n*2;i++) {
u=read(),v1=read();
v[u].push_back(v1),v[v1].push_back(u);
}
dfs(1,0);
int o=0;
if(siz[0]>siz[1]) o++,swap(siz[0],siz[1]),swap(Q[0],Q[1]);
int w=siz[1]-n;
if(w>1&&Q[1].size()<w) cout<<"boom";
else {
for(int i=0;w;i++) {
vis[Q[1][i]]=1;
w--;
}
for(int i=1;i<=n*2;i++) {
if(vis[i]||(dep[i]+o)%2==0) cout<<-1<<" ";
else cout<<1<<" ";
}
}cout<<endl;
}
signed main() {
cin>>T;
while(T--) {
check();
siz[0]=0,Q[0].clear();
siz[1]=0,Q[1].clear();
for(int i=1;i<=n;i++)vis[i]=fa[i]=dep[i]=0,v[i].clear();
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:51:14: error: ‘T’ was not declared in this scope 51 | cin>>T; | ^