当前位置:网站首页>[lgr-109] Luogu may race II & windy round 6
[lgr-109] Luogu may race II & windy round 6
2022-07-06 04:46:00 【Zqchang】
P8344 「Wdoi-6」 Walking in the lotus field at night
P8344 「Wdoi-6」 Walking in the lotus field at night
This is to deduce a formula , Relatively simple , But at that time, the minus sign was written as a plus sign, and I didn't see it , speechless , Painted for more than ten minutes
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
int x, y, z;
signed main()
{
int t;
cin >> t;
while (t--)
{
cin >> x >> y >> z;
int p = x * z - (x + 1) * x / 2 + z - x;
if(x > z || p < y ) cout << "Merry" << endl;
else cout << "Renko" << endl;
}
return 0;
}
P8345 「Wdoi-6」 Hua Xu's dream
P8345 「Wdoi-6」 Hua Xu's dream
Some people talk nonsense about graph theory , Almost believed
It's also a push question , Write directly
Pushed during the game
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;
int a[N];
int n, c, q;
signed main()
{
fast;
cin >> n >> c >> q;
for (int i = 1; i <= n; i++) cin >> a[i];
vector<int> v;
while(q --)
{
v.clear();
int x, y; cin >> x;
int sum = 0;
for(int i=1; i<=x; i++)
{
cin >> y;
v.push_back(a[y]);
sum += a[y];
}
sort(v.begin(), v.end());
cout << (x - 1) * c - sum - v[x - 1] + 2 * v[0] << endl;
}
return 0;
}
P8346 「Wdoi-6」 The clearest air and sea
P8346 「Wdoi-6」 The clearest air and sea
The main idea of this question is
Find out some hidden dangers of my code
In the valley of Los Angeles ,vector You can't empty it like this
1e6 You're almost ready to use fast reading , Be careful STL, Here we use set Want to remove the heavy edge , to T 了 , Split
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bitsdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 2e6 + 10;
int n, m, t;
vector<int> mp[N];
int in[N];
int u, v;
set<PII> s;
bool vis[N];
signed main()
{
fast;
cin >> t;
while(t --)
{
cin >> n >> m;
for(int i=1; i<=m; i++)
{
cin >> u >> v;
v += n;
// if(s.count({u, v}) || s.count({v, u})) continue;
mp[u].push_back(v);
mp[v].push_back(u);
in[u] ++ ;
in[v] ++;
// s.insert({u, v});
}
n *= 2;
int res = 0;
queue<int> q;
for(int i=1; i<=n; i++) if(in[i] == 1) q.push(i);
while(q.size())
{
u = q.front();
q.pop();
if(vis[u] || in[u] != 1) continue;
vis[u] = 1;
in[u] --;
for(auto i: mp[u])
{
if(in[i] == 1 && !vis[i])
{
res ++;
in[i] --;
vis[i] = 1;
}
else if(!vis[i])
{
res ++;
vis[i] = 1;
for(auto j : mp[i])
{
-- in[i];
-- in[j];
if(in[j] == 1 && !vis[j]) q.push(j);
}
}
}
}
if(res == n / 2) cout << "Renko" << endl;
else cout << "Merry" << endl;
// s.clear();
for(int i=1; i<=n; i++)
{
in[i] = 0;
vis[i] = 0;
mp[i].clear();
}
}
return 0;
}
P8347 「Wdoi-6」 The moon on the other side
P8347 「Wdoi-6」 The moon on the other side
Questions and points for attention are in the code
The general method is , If you can find
The circled structure , It must be the first to win , There are other situations , Not one by one , See for yourself if you want to see
Reference resources 1
Reference resources 2
!((n + 1) & n) Tell me about this judgment , This is judgment n+1 Is it right? 2 To the power of , That is, it can judge the full binary tree , Feel reference 1 It shouldn't be , Yes bug, I'll think about it again
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
int in[N];
vector<int> v[N];
bool dfs(int u, int fa)
{
for(auto i : v[u])
{
if(i == fa) continue;
if(!(in[u] & 1) && in[i] == 1) return true;
if(dfs(i, u)) return true;
}
return false;
}
signed main()
{
int t;
cin >> t;
while (t--)
{
int n; cin >> n;
int a, b;
for(int i=1; i<n; i++)
{
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
in[a] ++;
in[b] ++;
}
bool flag = 0;
for(int i=1; i<=n; i++)
if(in[i] != 2) flag = 0;
if(dfs(1, -1) || !((n + 1) & n)) cout << "Hifuu" << endl;
//!((n + 1) & n) This determines whether it is a full binary tree , But this judgment method is not rigorous , I don't know why I should make a special judgment
// Students have a way of writing , The same way of thinking , But he directly judges whether there is a degree 2 The point of , I can live , There is no need for special judgment
else cout << "Luna" << endl;
for(int i=1; i<=n; i++)
{
in[i] = 0;
v[i].clear();
}
}
return 0;
}
边栏推荐
- Tengine kernel parameters
- Finance online homework
- Knowledge consolidation source code implementation 3: buffer ringbuffer
- Database - MySQL storage engine (deadlock)
- 力扣(LeetCode)186. 翻转字符串里的单词 II(2022.07.05)
- The value of two date types is subtracted and converted to seconds
- [Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
- Flody的应用
- Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
- MIT CMS. 300 session 8 – immersion / immersion
猜你喜欢
[FreeRTOS interrupt experiment]
程序员在互联网行业的地位 | 每日趣闻
CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps
canal同步mysql数据变化到kafka(centos部署)
Mysql database storage engine
【LGR-109】洛谷 5 月月赛 II & Windy Round 6
Coreldraw2022 new version new function introduction cdr2022
SQL注入漏洞(MSSQL注入)
随机推荐
Visio draw fan
Request (request object) and response (response object)
Yyds dry goods inventory OSI & tcp/ip
Excellent PM must experience these three levels of transformation!
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
Canal synchronizes MySQL data changes to Kafka (CentOS deployment)
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
Easyrecovery靠谱不收费的数据恢复电脑软件
关于es8316的音频爆破音的解决
Nestjs配置文件上传, 配置中间件以及管道的使用
win10电脑系统里的视频不显示缩略图
Digital children < daily question> (Digital DP)
Redis —— Redis In Action —— Redis 实战—— 实战篇一 —— 基于 Redis 的短信登录功能 —— Redis + Token 的共享 session 应用— 有代码
tengine 内核参数
Platformio create libopencm3 + FreeRTOS project
canal同步mysql数据变化到kafka(centos部署)
yolov5 tensorrt加速
The value of two date types is subtracted and converted to seconds
729. My schedule I (set or dynamic open point segment tree)
图论的扩展