当前位置:网站首页>【LGR-109】洛谷 5 月月赛 II & Windy Round 6
【LGR-109】洛谷 5 月月赛 II & Windy Round 6
2022-07-06 04:43:00 【Zqchang】
P8344 「Wdoi-6」走在夜晚的莲台野
P8344 「Wdoi-6」走在夜晚的莲台野
这个就是推一个公式,比较简单,但是当时减号写成加号没看出来,无语,画了十多分钟
#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」华胥之梦
P8345 「Wdoi-6」华胥之梦
有人瞎说图论,差点信了
也是个推式子的题,就直接写
赛时推的
#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」最澄澈的空与海
这个题大意就是
这个题目找出来我代码的一些隐患吧
在洛谷,vector不能这么清空
1e6的读入差不多就要用快读了,注意STL,这里用set想去掉重边,给T了,裂开
#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」另一侧的月
疑问和注意点在代码里面
大致方法就是,如果能找到
圈起来的这种结构,就一定是先手必胜,此外还有别的情况,不一一列举了,想看的自己看吧
!((n + 1) & n)讲一下这个判断,这是判断n+1是不是2的幂次方的,也就是能判断满二叉树,感觉参考1不应该过,有bug,我再想想
#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)这个判断的是是否为满二叉树,但是这个判断方法感觉不严谨,不知道为什么要特判
//同学有种写法,思路一样,但是他直接判断有没有度是2的点,也能过,就不用特判了
else cout << "Luna" << endl;
for(int i=1; i<=n; i++)
{
in[i] = 0;
v[i].clear();
}
}
return 0;
}
边栏推荐
- 力扣(LeetCode)186. 翻转字符串里的单词 II(2022.07.05)
- 项目经理,你会画原型嘛?项目经理需要做产品设计了?
- CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
- Complete list of common functions of turtle module
- Fuzzy -- basic application method of AFL
- Lagrange polynomial
- [NOIP2009 普及组] 分数线划定
- Redis 排查大 key 的4種方法,優化必備
- Visio draw fan
- 729. My schedule I (set or dynamic open point segment tree)
猜你喜欢
满足多元需求:捷码打造3大一站式开发套餐,助力高效开发
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
Easyrecovery reliable and toll free data recovery computer software
Etcd database source code analysis -- etcdserver bootstrap initialization storage
How to estimate the population with samples? (mean, variance, standard deviation)
[detailed steps of FreeRTOS shift value for the first time]
Fedora/rehl installation semanage
How does computer nail adjust sound
Embedded development program framework
随机推荐
cdc 能全量拉去oracle 表嘛
P2022 interesting numbers (binary & digit DP)
Database - MySQL storage engine (deadlock)
Introduction of several RS485 isolated communication schemes
Flink kakfa data read and write to Hudi
优秀PM必须经历这3层蜕变!
捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统
Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps
麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東
How to estimate the population with samples? (mean, variance, standard deviation)
Chip debugging of es8316 of imx8mp
[network] channel attention network and spatial attention network
Fuzzy -- basic application method of AFL
729. My schedule I (set or dynamic open point segment tree)
SQL注入漏洞(MSSQL注入)
web工程导入了mysql驱动jar包却无法加载到驱动的问题
Excellent PM must experience these three levels of transformation!
Fedora/rehl installation semanage
我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
Certbot failed to update certificate solution