当前位置:网站首页>Codeforces Round #394 (Div. 2) E. Dasha and Puzzle
Codeforces Round #394 (Div. 2) E. Dasha and Puzzle
2022-06-21 18:07:00 【不吃土司边】
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
const int maxn = 1e5+2;
const int INF = 1<<30;
const int mod = 1e9+7;
int in[maxn],n;
std::vector<int> v[maxn];
int dr[4][2]={
{
1,0},{
0,1},{
-1,0},{
0,-1}};
pair<int,int> res[maxn];
void dfs(int x,int fa,int dep,int p1,int p2,int from){
res[x]={
p1,p2};
// cout<<dep<<endl;
// cout<<x<<" "<<fa<<" "<<p1<<" "<<p2<<" "<<from<<endl;
int now=0;
for(int i=0;i<v[x].size();i++){
int to=v[x][i];
if(to==fa) continue;
if(now==from) ++now;
int nx=p1+dr[now][0]*(1<<dep),ny=p2+dr[now][1]*(1<<dep);
dfs(to,x,dep-1,nx,ny,(now+2)%4);
++now;
}
}
void solve(){
scanf("%d",&n);
for(int i=1;i<n;i++){
int x,y;scanf("%d%d",&x,&y);
in[x]++;in[y]++;
v[x].pb(y);v[y].pb(x);
if(in[x]>4||in[y]>4){
cout<<"NO"<<endl;
return;
}
}
dfs(1,0,30,0,0,-1);
cout<<"YES"<<endl;
for(int i=1;i<=n;i++){
cout<<res[i].first<<" "<<res[i].second<<endl;
}
return;
}
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
- R language uses GLM function to build Poisson regression model, and coef function to obtain the coefficients of Poisson regression model and analyze the effects of various variables
- Yolov5 trains its own data set to report error records
- 在 KubeSphere 上部署 Apache Pulsar
- Guys, please ask me a question about flynk SQL. I have an FQL statement, insert into C sale
- Alibaba cloud Yum source configuration
- 转发提醒 MetaMask小狐狸钱包安全公告 如何应对拓展程序潜在的私钥泄露
- 6月25日PMP考前指南,你需要做好这些
- How many correct answers can you get to Huawei Hongmeng certification test questions?
- After the 80 version of Google browser, how to deal with the problem samesite cross domain problem
- Nebula Graph入驻阿里云计算巢,助力企业打造云上超大规模图数据库
猜你喜欢

Mvcc implementation principle of MySQL
![[pwn基础]Pwntools学习](/img/72/0f80d2f91d772e361b6d23a67e2ca3.png)
[pwn基础]Pwntools学习

yolov5训练自己的数据集报错记录

API interface for discharge summary identification - medical bill OCR identification / discharge diagnosis record / electronic medical record / claim settlement service

Insert class collation

CPDA|数据分析师需要具备哪些基本功?

6月22日直播 | 华南理工詹志辉: 面向昂贵优化的进化计算

How many correct answers can you get to Huawei Hongmeng certification test questions?

jvm造轮子

文献分析 Citespace 6.1.2 下载及安装教程
随机推荐
网管型全国产加固交换机如何创建网络冗余
Kubernetes 跨 StorageClass 迁移 Persistent Volumes 完全指南
vivo 容器集群监控系统架构与实践
298th weekly match
Must the database primary key be self incremented? What scenarios do not suggest self augmentation?
Guys, please ask me a question about flynk SQL. I have an FQL statement, insert into C sale
2022年下半年传统产品经理国际资格认证招生简章(NPDP)
How many correct answers can you get to Huawei Hongmeng certification test questions?
力扣今日题1108. IP 地址无效化
Gartner 网络研讨会 “九问数字化转型” 会后感
论文解读(USIB)《Towards Explanation for Unsupervised Graph-Level Representation Learning》
2022年6月25日PMP考试通关宝典-4
华为鸿蒙认证测试题,你能答对几道?
R语言dist函数计算dataframe数据中两两样本之间的距离并返回样本间距离矩阵,将距离矩阵输入给hclust函数进行层次聚类分析,method参数指定两个组合数据点间的距离计算方式
Introduction to setting program icon in QT
Enabling developers of shengteng scientific research innovation enabling program Huawei computing provides three dimensional support
鸿蒙之后,华为宣布再将捐赠欧拉,鸿蒙和欧拉的捐赠预计将给业界带来哪些影响?
动态规划【一】(背包问题)
CloudCompare&PCL 根据匹配点计算变换矩阵
使用uniapp框架搭建浙里办微应用(单点登录、埋点、适老化、RPC网关)