当前位置:网站首页>ABC find 4-cycle (pigeon nest theorem)
ABC find 4-cycle (pigeon nest theorem)
2022-07-26 01:28:00 【Lovely and beautiful girl】
The question :
It's for you. n+k Points and m side , Two points on each side, one point <=n, One point >n, There is no double edge . Now I ask if you have a size of 4 Rings , If there is any output , If no output -1.n<=3e5,k<=3000.
reflection :
First of all, the two points on the side must be in the two point sets , Draw a picture and find , For two points in a point set . If they contain points >=2 A the same , Then you can output these four points . Find out k Very small , therefore kk The complexity of enumerates which two points , It's stuck here , How to find what they have in common ? This cannot be done quickly . If you enumerate n This point set , Not to mention .
Actually , For the point on the left , It contains some points on the right . If these points are enumerated twice , See if any two points are elsewhere i It's OK to include this in the point ? But a want to , Each point 3000 A little bit , Complexity nk*k, It's not going to work . But think about it , Not so many times , For example, the first point contains k/2 A little bit , The second point contains different k/2 A little bit , The third point, if it contains points >=3 Then there must be two included by others , Here is the pigeon nest theorem .
So it's just some problems that you can't do with complexity , You can try , Because when there is no other algorithm, it is usually violence , This violence looks like violence, in fact , If you add some details, you will not run so many times .
Code :
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define db double
#define int long long
#define PII pair<int,int >
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int mod = 1e9+7,inf = 1e18;
const int N = 4e5+10,M = 3010;
int T,n,m,k;
int va[M][M]; // If you use map<PII,int> mp To mark , Will timeout
set<int> s[N];
signed main()
{
IOS;
cin>>n>>k>>m;
while(m--)
{
int a,b;
cin>>a>>b;
s[a].insert(b-n);
}
for(int i=1;i<=n;i++)
{
for(auto t1:s[i])
{
for(auto t2:s[i])
{
if(t1==t2) continue;
int a = t1,b = t2;
if(!va[a][b]) va[a][b] = i;
else
{
cout<<a+n<<" "<<b+n<<" "<<va[a][b]<<" "<<i;
return 0;
}
}
}
}
cout<<-1;
return 0;
}
summary :
Try more , Think more .
边栏推荐
- Is it safe to buy funds on e fund? Professional answers
- Kubernetes Pod启动流程
- [unity] random generation of two-dimensional cave map
- Game thinking 17: Road finding engine recast and detour learning II: recast navigation grid generation process and limitations
- Basic version of Google browser debugging tool (I)
- NLP introduction + practice: Chapter 3: gradient descent and back propagation
- Browser development and use skills
- 8. Learn Mysql to create data tables
- Case when of SQL
- The best way to practice Animation: cover transition
猜你喜欢

【数据挖掘】生成模型和判别模型的区别及优缺点

iNFTnews | 假如这是元宇宙20年后的样子

Docker高级篇-Mysql主从复制
![[secsha concept] large and small end](/img/1e/d295a6eb7ecaccb53ed9f7d2234956.png)
[secsha concept] large and small end

NiO simple example

Detailed explanation of at and crontab commands of RHCE and deployment of Chrony

PTGui Pro12垂直线纠正

The second China rust developer conference is coming, and the complete agenda has been exposed!

U++ learning notes ustruct, uenum declaration and function library simple function implementation

谷歌浏览器调试工具使用基础版(一)
随机推荐
NodeJS 基于 Dapr 构建云原生微服务应用,从 0 到 1 快速上手指南
Nodejs builds cloud native microservice applications based on dapr, a quick start guide from 0 to 1
Is it safe to open an account for stock speculation through the online account manager?
Special topic of distributed micro service e-commerce (I) - Project Introduction
Fundamentals of MATLAB shift operation
1.30 upgrade bin file, add suffix and file length
Leetcode 537. complex multiplication (netizens' thoughts, ashamed)
“蔚来杯“2022牛客暑期多校训练营2 I.[let fat tension] 矩阵乘法 J.[Link with Arithmetic Progression]线性回归
"Yuanqi Cola" is not the end point, "China Cola" is
Leetcode 537. 复数乘法(网友思路,自愧不如)
RHCE之at和crontab命令详解及chrony部署
Web middleware log analysis script 3.0 (shell script)
【数据挖掘】生成模型和判别模型的区别及优缺点
Understand Linglong platform unified access service from simple to deep Monet
[software development specification II] prohibited item development specification
Fiddler5+ lightning simulator 4.0 settings for app packet capturing
[secsha concept] original reverse supplement
MDK compilation process and arm compilation tool chain
MDK编译过程及ARM编译工具链
数据库系统原理与应用教程(057)—— MySQL 练习题