当前位置:网站首页>【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;
}
边栏推荐
- How does computer nail adjust sound
- 关于imx8mp的es8316的芯片调试
- 关于es8316的音频爆破音的解决
- word封面下划线
- IPv6 comprehensive experiment
- CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)
- Sqlserver query results are not displayed in tabular form. How to modify them
- Visio draw fan
- SQL injection vulnerability (MSSQL injection)
- Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
猜你喜欢

How to realize automatic playback of H5 video

Postman管理测试用例

Programmers' position in the Internet industry | daily anecdotes

Postman前置脚本-全局变量和环境变量

Postman关联
![[数学建模] 微分方程--捕鱼业的持续发展](/img/7c/2ab6f2a34bc2c97318537ec8e0b0c5.png)
[数学建模] 微分方程--捕鱼业的持续发展

程序员在互联网行业的地位 | 每日趣闻

Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022

SQL注入漏洞(MSSQL注入)

行业专网对比公网,优势在哪儿?能满足什么特定要求?
随机推荐
Implementation of knowledge consolidation source code 1: epoll implementation of TCP server
canal同步mysql数据变化到kafka(centos部署)
也算是学习中的小总结
The value of two date types is subtracted and converted to seconds
DMA use of stm32
Flink kakfa data read and write to Hudi
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
Postman断言
Is the mode of education together - on campus + off campus reliable
[NOIP2008 提高组] 笨小猴
Redis 排查大 key 的4種方法,優化必備
Dynamic programming (tree DP)
Ue5 small knowledge freezerendering view rendered objects in the cone
Selection sort
[数学建模] 微分方程--捕鱼业的持续发展
[HBZ sharing] how to locate slow queries in cloud database
ue5 小知识 FreezeRendering 查看视锥内渲染的物体
【HBZ分享】ArrayList的增删慢查询快的原因
acwing周赛58