题目链接: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. python3 sort list

    1. 对元素指定的某一部分进行排序,关键字排序 s = ['release.10.txt','release.1.txt','release.2.txt','release.14.txt','rele ...

  2. Tensorflow学习教程------普通神经网络对mnist数据集分类

    首先是不含隐层的神经网络, 输入层是784个神经元 输出层是10个神经元 代码如下 #coding:utf-8 import tensorflow as tf from tensorflow.exam ...

  3. jquery的读、写、增、删、查方法

    # 注:jquery需要导包  格式<script type="text/javascript" src="jquery-3.2.1.js">> ...

  4. 求1+2+3+…..+n

    [问题]求1+2+3+…+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字及条件判断语句(A?B:C). [思路]由于题目好多运算符不能用,我们只有想到使用递 ...

  5. ADFS 4.0 证书更新

    ADFS 4.0 证书更新 由于公网证书的过期,需要重新更新ADFS的服务通信证书: 证书要求: 带私钥 PFX格式 更换流程: 证书安装到 证书\计算机\个人,安装后点开证书能看到"你有一 ...

  6. HTML5 SVG应用(1)——loading效果

    先看一下效果: 链接 代码: <svg version="1.1" id="loader-1" xmlns="http://www.w3.org ...

  7. 微信小程序常用代码(1)——tab切换

          <view class="font-bold tab-content"> <!-- 循环列表 --> <block wx:for=&quo ...

  8. 【Python】关于import QtCore报错的处理方法

    刚开始学习使用PyQT,但总碰到一些小挫折 比如 import Pyqt成功 而 from PyQt5 import QtCore, QtGui, QtWidgets却报错,找了半天终于找到资料,原因 ...

  9. Linux相关笔记

    vim下 r /etc/hosts  会把这个文件读进来 r! df -Th  会把执行的内容读取进来 查找 /  ? 替换:s/old/new/g 2到9行替换2,9s/old/new/g 全部替换 ...

  10. springCloud 常用组件总结

    本文浅谈只是对我自己初期认识这spring cloud的一个笔记. 微服务是一种架构风格和一种应对业务的架构策略.实现这种的技术方式很多.本文主要说spring cloud. spring cloud ...