首页 > 其他分享 >Forever Winter

Forever Winter

时间:2023-06-30 19:45:31浏览次数:37  
标签:Forever Winter int graph vertices each test output

Forever Winter time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

A snowflake graph is generated from two integers x and y, both greater than 11, as follows:

  • Start with one central vertex.
  • Connect x new vertices to this central vertex.
  • Connect y new vertices to each of these x vertices.
For example, below is a snowflake graph for x=5=5 and y=3=3.

The snowflake graph above has a central vertex 1515, then x=5=5 vertices attached to it (33, 66, 77, 88, and 2020), and then y=3=3 vertices attached to each of those.

Given a snowflake graph, determine the values of x and y. Input

The first line contains a single integer t (1≤t≤10001≤≤1000) — the number of test cases.

The first line of each test case contains two integers n and m (2≤n≤2002≤≤200; 1≤m≤min(1000,n(n−1)2)1≤≤min(1000,(−1)2)) — the number of vertices and edges in the graph, respectively.

The next m lines each contain two integers each u and v (1≤u,v≤n1≤,≤, u≠v≠) — the numbers of vertices connected by an edge. The graph does not contain multiple edges and self-loops.

It is guaranteed that this graph is a snowflake graph for some integers x and y both greater than 11.

Output

For each test case, on a separate line output the values of x and y, in that order, separated by a space.

Example input Copy 3 21 20 21 20 5 20 13 20 1 3 11 3 10 3 4 8 19 8 14 8 9 7 12 7 17 7 18 6 16 6 2 6 6 15 7 15 8 15 20 15 3 15 7 6 1 2 1 3 2 4 2 5 3 6 3 7 9 8 9 3 3 6 6 2 2 1 5 2 2 7 4 3 3 8 output Copy
5 3
2 2
2 3
Note

The first test case is pictured in the statement. Note that the output 3 5 is incorrect, since x should be output before y.

#include <bits/stdc++.h>
//#define int long long
using namespace std;
const int N=1e5+10,mod=1e9+7;
string s;
int n,t,f[N],res,num,ans,m;
bool vis[N];
int main()
{
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>t;
    while(t--){
        cin>>n;
        ans=0;
        map<int,int>a;
        for(int i=0;i<n;i++){
            cin>>f[i];
            a[f[i]]=1;
        }
        for(int i=0;i<=n;i++)//只需要找到一个所有的子节点都不是1的点就可以
            if(!a.count(i)){
                num=i;
                break;
            }
        int l=0,r=0;
        for(int i=0;i<n;i++){
            if(f[i]==num+1){
                if(l==0) l=i;
                r=i;
            }
        }

    }
    return 0;
}

 

标签:Forever,Winter,int,graph,vertices,each,test,output
From: https://www.cnblogs.com/o-Sakurajimamai-o/p/17517686.html

相关文章

  • 「解题报告」CF768G The Winds of Winter
    真的不难,为啥是3300*。还是模拟赛T3,很气啊,为什么不先看这个题。首先贪心很容易发现一定是将当前子树大小最大的那棵树的某个子树移动到最小的那个树内。那么我们记移动的这个子树的大小为\(x\),所有树中最小的树大小为\(a\),最大的为\(c\),次大的为\(b\),那么我们就是在最小化......
  • 外汇天眼:Winter平台积极鼓吹借贷投资黄金,诱导入金建仓诈骗30万!
    对现代人来说,通过社交平台认识新朋友已经是很普遍的事情。然而,网络交友确实也有一定程度的风险,近年来有愈来愈人落入诈骗集团假冒帅哥美女的杀猪盘陷阱,并因此蒙受莫大的损失,日前外汇天眼就收到一位投资人的爆料,控诉黑平台Winter的恶行。根据受害者的回忆,她是在社群网站IG上被一位......
  • Walkthrough-WINTERMUTE 1
    0x01环境靶机地址:https://www.vulnhub.com/entry/wintermute-1,239/两个靶机,做网络隔离STRAYLIGHT一张网卡桥接,另一张仅主机模式,桥接网卡时,可能有点问题,重选一下网卡就好了Kali做桥接网卡NEUROMANCER仅主机kali和NEUROMANCER网络不联通0x02过程STRAYLIGHT1.信息收......
  • Holt-Winters模型原理分析及代码实现(python)
    引言最近实验室老师让我去预测景区内代步车辆的投放量,于是乎,本着“一心一意地输出年富力强的劳动力”这份初心,我就屁颠屁颠地去找资料,然后发现了Holt-Winters模型,感......
  • I am 23 years old. What can I do now that will change my life forever?
    Savemoney,don’tspendit.Ifyoudon’tneeditdon’tbuyit.ICANNOTSTRESSTHISONEENOUGH.Travelcheapandoften.Travelingisharderasyougofrom......
  • nodejs 后台运行 forever
    一、安装nodejs//安装必要的make以及gcc,gcc-c++编译器yum-yinstallmakegccgcc-c++//获取源码wget http://nodejs.org/dist/v0.8.14/node-v0.8.14.tar.gz//解压......
  • SMU Winter 2023 Round #13
    B.BM算日期题意:就是给定两个整数n,k,n是第一个日期,n+k是第二个日期,如果n+k>9999,那么9999-(n+k-9999)是第二个日期,算这两个日期中有多少个闰年。思路:首先根据题目规则得到......
  • SMU Winter 2023 Round #14
    A.解开束缚缠丝Ⅱ题意:给出n个字母(含大小写),求它们能构成最长回文串的长度。思路:找到里面成对的字符串有多少,然后如果有多出来的就+1,如果没有了就不加了,如果有三个只能算......
  • SMU Winter 2023 Round #12 (Div.2)
    A.KK画猪题目:输入pig,输出一些字符。代码:点击查看代码importjava.util.Scanner;publicclassMain{ publicstaticvoidmain(String[]args){ Scannerscanne......
  • SMU Winter 2023 Round #11 (Div.2)
    A.BCD题意:输入两个数,一个是数的数量N,另一个是每个箱子能够装多少书M,问需要多少个箱子。思路:我们只需要用书n的数量去除以容量m,然后判断一下取模有没有余数,有的话就结果......