题目链接:http://codeforces.com/gym/102190/attachments

题解:我们先将前5个点分别涂上红色或者绿色,使得这两棵树在5个点中都是连通,并不存在自环(建边方式不唯一,主要看自己怎么想的,只要满足题意即可)。那么从第6个点开始:分别找一个固定的点与该点连边即可。

自己看别人做的方法,才自己做出来的,也是思考了一下,下面来张自己手动模拟的图,自己模拟一遍就会了呀

#include<bits/stdc++.h>
using namespace std;
int print(int a,int b,int c,int d)
{
cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
//fflush(stdout);
int x;
cin>>x;
return x;
}
void Init()
{
int k1=print(,,,);
int k2=print(,,,);
if(k1==k2){
int k3=print(,,,);
if(k3==k1)
print(,,,);
else
print(,,,);
}
else{
int k3=print(,,,);
if(k3==k1)
print(,,,);
else
print(,,,);
}
}
int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
Init();
for(int i=;i<=n;i++)
print(,i,,i);
}
return ;
}

G - Green-Red Tree Gym - 102190G的更多相关文章

  1. 第七届河南省赛G.Code the Tree(拓扑排序+模拟)

    G.Code the Tree Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 35  Solved: 18 [Submit][Status][Web ...

  2. AGC014E Blue and Red Tree

    题意 There is a tree with \(N\) vertices numbered \(1\) through \(N\). The \(i\)-th of the \(N−1\) edg ...

  3. AT2377 Blue and Red Tree

    AT2377 Blue and Red Tree 法一:正推 红色的边在蓝色的树上覆盖,一定每次选择的是覆盖次数为1的边的覆盖这条边的红色边连出来 覆盖次数可以树剖找到 这条红色边,可以开始的时候每个 ...

  4. F - No Link, Cut Tree! Gym - 101484F

    Marge is already preparing for Christmas and bought a beautiful tree, decorated with shiny ornaments ...

  5. E - Minimum Spanning Tree Gym - 102220E (转化+贡献)

    In the mathematical discipline of graph theory, the line graph of a simple undirected weighted graph ...

  6. 【模拟】BAPC2014 G Growling Gears (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  7. 【AGC014E】Blue and Red Tree

    Description 给定一棵\(n\)个节点的蓝边树,再给定一棵\(n\)个节点的红边树.请通过若干次操作将蓝树变成红树.操作要求和过程如下: 1.选定一条边全为蓝色的路径: 2.将路径上的一条蓝 ...

  8. 牛客网暑期ACM多校训练营(第三场)G:Coloring Tree(函数的思想)

    之前两次遇到过函数的思想的题,所以这次很敏感就看出来了.可以参考之前的题: https://www.cnblogs.com/hua-dong/p/9291507.html Christmas is c ...

  9. AtCoder AGC014E Blue and Red Tree (启发式合并)

    题目链接 https://atcoder.jp/contests/agc014/tasks/agc014_e 题解 完了考场上树剖做法都没想到是不是可以退役了... 首先有一个巨难写的据说是\(O(n ...

随机推荐

  1. 2019.1的IDEA的Pulgins无法使用解决

    第一步 第二步

  2. 9 react 基础 - 虚拟DOM

    一.虚拟DOM React 原理 1. 存放 state 数据 2. JSX 模版 3. 数据 + 模版 生成虚拟DOM(虚拟DOM就是一个JS 对象, 用来描述真实DOM) eg: ['div', ...

  3. hdu 5147 Sequence II【树状数组/线段树】

    Sequence IITime Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem ...

  4. 使用mysql的注意事项

    1,文件导入:LOAD DATA INFILE '/tmp/pet.txt' INTO TABLE pet FIELDS TERMINATED BY ',' LINES TERMINATED BY ' ...

  5. java AES加解密

    AES加解密工具类 package com.yan.demo; import org.apache.commons.lang3.StringUtils; import sun.misc.BASE64D ...

  6. E. Double Elimination (DP)

    题目:传送门 题意:有 2^n 个人进行比赛,对他们编号 1~2^n,起初1和2打,3和4打,5和6打,7和8打...,然后1和2打完胜利的 和 3和4打完胜利的再打一场,1和2打完失败的和3和4打完 ...

  7. Linux设置邮箱发送邮件

    安装sendmail服务 然后配置/etc/mail.rc文件,如果没有生成就自己建立. 内容如下: set from=xxx@163.com smtp=smtp.163.com set smtp-a ...

  8. 安装lombok插件IDEA的插件栏加载不出来

    打开 Setting-->Appearance & Behavior -->Syetem Setting -->Updates,将Use secure connection  ...

  9. 总结一些常用的训练 GANs 的方法

    众所周知,GANs 的训练尤其困难,笔者自从跳入了 GANs 这个领域(坑),就一直在跟如何训练 GANs 做「对抗训练」,受启发于 ganhacks,并结合自己的经验记录总结了一些常用的训练 GAN ...

  10. h5-FileReader对象的使用

    <!--FileReader对象的使用--> <!--需要及时预览 及时:当用户选择完图片之后就立即进行预览处理--onchange事件 预览:通过文件读取对象的readAsData ...