G - Green-Red Tree Gym - 102190G
题目链接: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的更多相关文章
- 第七届河南省赛G.Code the Tree(拓扑排序+模拟)
G.Code the Tree Time Limit: 2 Sec Memory Limit: 128 MB Submit: 35 Solved: 18 [Submit][Status][Web ...
- AGC014E Blue and Red Tree
题意 There is a tree with \(N\) vertices numbered \(1\) through \(N\). The \(i\)-th of the \(N−1\) edg ...
- AT2377 Blue and Red Tree
AT2377 Blue and Red Tree 法一:正推 红色的边在蓝色的树上覆盖,一定每次选择的是覆盖次数为1的边的覆盖这条边的红色边连出来 覆盖次数可以树剖找到 这条红色边,可以开始的时候每个 ...
- F - No Link, Cut Tree! Gym - 101484F
Marge is already preparing for Christmas and bought a beautiful tree, decorated with shiny ornaments ...
- E - Minimum Spanning Tree Gym - 102220E (转化+贡献)
In the mathematical discipline of graph theory, the line graph of a simple undirected weighted graph ...
- 【模拟】BAPC2014 G Growling Gears (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【AGC014E】Blue and Red Tree
Description 给定一棵\(n\)个节点的蓝边树,再给定一棵\(n\)个节点的红边树.请通过若干次操作将蓝树变成红树.操作要求和过程如下: 1.选定一条边全为蓝色的路径: 2.将路径上的一条蓝 ...
- 牛客网暑期ACM多校训练营(第三场)G:Coloring Tree(函数的思想)
之前两次遇到过函数的思想的题,所以这次很敏感就看出来了.可以参考之前的题: https://www.cnblogs.com/hua-dong/p/9291507.html Christmas is c ...
- AtCoder AGC014E Blue and Red Tree (启发式合并)
题目链接 https://atcoder.jp/contests/agc014/tasks/agc014_e 题解 完了考场上树剖做法都没想到是不是可以退役了... 首先有一个巨难写的据说是\(O(n ...
随机推荐
- Mybatis之配置文件
Mybatis_config.xml <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE conf ...
- POJ 1995:Raising Modulo Numbers 快速幂
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5532 Accepted: ...
- ORACLE自增函数,一般函数
1.UNIX时间与普通时间互相转换 1.ORACLE先创建函数方法,再直接使用,MySQL直接使用方法UNIX_TIMESTAMP,FROM_UNIXTIME oracle_to_unix(creat ...
- map/vector遍历删除
map遍历删除 map<int, vector<int>>::iterator it = g_map.begin(); for (; it != g_map.end(); /* ...
- Windows下Nodejs的开发环境搭建
我为什么选择学习 Node.js Node.js是前后端分离开发的新选择.比较热门的前端框架React,Vue都可以在Node.js环境上开发. Node.js 是一个基于 Chrome V8 引擎的 ...
- Asp.NET CORE安装部署
先安装IIS再安装这两个,不然后面各种bug HTTP 错误 500.19 代码 0x8007000d 解决方案 for win7_64 asp.net core IIS Web Core 1.比如最 ...
- 201612-1 中间数 Java
思路: 先排序,两个count变量记录.有点暴力 import java.util.Arrays; import java.util.Scanner; public class Main { publ ...
- python刷LeetCode:1.两数之和
难度等级:简单 题目描述: 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. 你可以假设每种输入只会对应一个答案.但是,你不 ...
- 2020/1/28 PHP代码审计之命令执行漏洞
0x00 命令执行漏洞原理 应用程序有时需要调用一些执行系统命令的函数,如在PHP中,使用system.exec.shell_exec.passthru.popen.proc_popen等函数可以执行 ...
- POJ 3660 Cow Contest【Floyd 传递闭包】
传送门:http://poj.org/problem?id=3660 题意:有n头牛, 给你m对关系.(a, b)表示牛a能打败牛b, 求在给出的这些关系下, 能确定多少头牛的排名. 传递闭包: 关系 ...