freee Programming Contest 2023(AtCoder Beginner Contest 310) - AtCoder

A - Order Something Else (atcoder.jp)

题意是在买一道菜的情况下可以将原为\(P\)元的饮料优惠\(Q\)元,否则就按原价买

#include<bits/stdc++.h>

#define int long long

using namespace std;

signed main(){
int n,p,q;
cin >> n >> p >> q; vector<int> a(n);
for(auto &i : a)
cin >> i; int ans = p;
for(auto i : a){
if(q + i < ans)
ans = q + i;
} cout << ans << endl; return 0;
}

B - Strictly Superior (atcoder.jp)

题意是有\(N\)种产品,每种产品有最多有\(M\)\((1 < C_i < M)\)种功能,定义第\(i\)种产品的第\(C_i\)种功能为\(F_{i,C_i}\),现满足以下条件则说明存在有一种商品严格大于另一种商品:

  • \(P_i \geq P_j\)

  • 第\(j\)种商品包含第\(i\)种商品的全部功能

  • $P_i > P_j $ 或者 第\(j\)种商品的功能比第\(i\)种更多

纯模拟,注意对条件的判断.

繁杂版(bushi

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define endl '\n'
#define int long long
#define all(a) (a).begin(),(a).end() using namespace std; typedef pair<int,int> PII; int n,m;
void solve() {
cin >> n >> m;
multimap<int,vector<int>> prj;
for(int i = 0;i < n;i ++){
int p,k;
cin >> p >> k;
vector<int> o;
for(int j = 0;j < k ;j ++){
int y;
cin >> y;
o.push_back(y);
}
prj.insert({p,o});
} bool f = false;
for(auto i : prj){
for(auto j : prj){
if(i == j) continue;
if(j.first <= i.first && j.second.size() >= i.second.size()){
for(int k = 0;k < i.second.size() ;k++){
if(std::find(j.second.begin(), j.second.end(),i.second[k]) == j.second.end())
break;
if (k == i.second.size() - 1){
if(j.first < i.first || j.second.size() > i.second.size())
f = true;
}
}
}
}
}
cout << (f ? "Yes" : "No") << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}

简洁版(\(jiangly\)的

#include <bits/stdc++.h>

using i64 = long long;

int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr); int N, M;
std::cin >> N >> M; std::vector<int> P(N);
std::vector<std::bitset<100>> F(N);
for (int i = 0; i < N; i++) {
std::cin >> P[i];
int C;
std::cin >> C;
while (C--) {
int x;
std::cin >> x;
F[i][x - 1] = 1;
}
} for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (P[i] <= P[j] && (F[i] & F[j]) == F[j] && (P[i] < P[j] || F[i] != F[j])) {
std::cout << "Yes\n";
return 0;
}
}
}
std::cout << "No\n"; return 0;
}

C - Reversible (atcoder.jp)

题意就是相同或相反的字符串算一个球棒,输出一共有多少球棒

每次判断一下就行

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define endl '\n'
#define int long long using namespace std; int n,m; void solve() {
cin >> n;
set<string> a;
map<string,int> mps;
for(int i = 0;i < n;i ++){
string s,ss;
cin >> s;
ss = s;
std::reverse(s.begin(), s.end());
if(mps.count(s))
continue;
mps[ss]++;
a.insert(ss);
}
cout << a.size() << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}

放份\(jiangly\)的学习下(

#include <bits/stdc++.h>

using i64 = long long;

int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr); int N;
std::cin >> N; std::vector<std::string> S(N);
for (int i = 0; i < N; i++) {
std::cin >> S[i];
auto T = std::string(S[i].rbegin(), S[i].rend());
if (T < S[i]) {
S[i] = T;
}
} auto ans = (std::set(S.begin(), S.end()).size());
std::cout << ans << "\n"; return 0;
}

D - Peaceful Teams (atcoder.jp)

后面没做出来了,不过看了\(jiangly\)的也算有了思路(bushi

题意就是有\(M\)对有矛盾的队员不能放一个队里,问最多能组成多少不同的队

因为数据范围较小所以可以直接搜就完了

\(c(x)\)代表的是第\(x\)个人被分配到哪一队了,\(max(y,i+ 1)\)是带入当前已经有人被分配的最大队伍数

#include  <bits/stdc++.h>
#define endl '\n'
#define int long long
#define inf 0x3f3f3f3f using namespace std; void solve(){ int t;
cin >> n >> t >> m;
vector<int> a(m),b(m);
for(int i = 0;i < m;i ++){
cin >> a[i] >> b[i];
a[i] --,b[i] --;
} vector<int> c(n);
int ans = 0; auto dfs = [&](auto self, int x,int y){
if(x == n){
if(y != t){
return ;
}
bool ok = true;
for(int i = 0;i < m;i ++){
if(c[a[i]] == c[b[i]])
ok = false;
}
ans += ok;
return ;
}
for(int i = 0;i <= y;i ++){
c[x] = i;
self(self, x + 1, max(y,i + 1));
}
}; dfs(dfs,0,0);
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> ie_scholar;
while(Ke_scholar--)
solve();
return 0;
}

就不放\(jiangly\)的了,因为跟他一样(

AtCoder Beginner Contest 310的更多相关文章

  1. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  2. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  5. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  6. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  7. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  8. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

  10. AtCoder Beginner Contest 075 C bridge【图论求桥】

    AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...

随机推荐

  1. 指令(Prompt)基本格式

    指令(Prompt)基本格式: 参考信息:包含文心一言完成任务时需要知道的必要背景和材料,如:报告.知识.数据库.对话上下文等 动作:需要文心一言帮你解决的事情,如:撰写.生成.总结.回答等 目标:需 ...

  2. java并发和排序的简单例子(Runnable+TreeSet)

    很多时候并发需要考虑线程安全,但也有很多时候和线程安全毛关系都没有,因为并发最大的作用是并行,线程安全仅仅是并发的一个子话题. 例如常常会用于并发运算,并发i/o. 下文是一个练习笔记. 运行环境:w ...

  3. USB 协议学习:000-有关概念

    USB 协议学习:000-有关概念 背景 USB作为一种串行接口,应用非常广泛.掌握usb也是作为嵌入式工程师的一项具体要求. 概述 USB( Universal Serial Bus, 通用串行总线 ...

  4. 不是人家太装逼,而是我们太low

    在一个社团的迎新的时候,每个人自我介绍.等到一个一身LV,爱马仕的女孩子自我介绍,说起爱好,她想了想说:喜欢跑车.然后很淡定的坐下了.很多同学你看我我看你,投以"炫富"的判断目光- ...

  5. JpaRepository:Paging query needs to have a Pageable parameter! Offending method public abstract

    在练习 Spring Data JPA 时,使用分页接口 Pageable 查询数据,接口实现后,运行报错: Paging query needs to have a Pageable paramet ...

  6. Codeforces Round 935 (Div. 3)

    A. Setting up Camp 题目描述 The organizing committee plans to take the participants of the Olympiad on a ...

  7. Solo开发者社区-H5-Dooring, 开箱即用的零代码搭建平台

    Dooring-Saas 是一款功能强大,高可扩展的零代码解决方案,致力于提供一套简单方便.专业可靠.无限可能的页面可视化搭建最佳实践.(Solo社区 投稿) 功能特点 可扩展, Dooring 实现 ...

  8. 【算法】在vue3的ts代码中分组group聚合源数据列表

    有一个IList<any>()对象列表, 示例数据为[{id:'1',fieldName:'field1',value:'1'},{id:'1',fieldName:'field2',va ...

  9. [oeasy]python0123_中文字符_文字编码_gb2312_激光照排技术_王选

    中文编码GB2312 回忆上次内容 上次回顾了 日韩各有 编码格式 日本 有假名 五十音 一字节 可以勉强放下   有日本汉字 字符数量超过20000+     韩国 有谚文 数量超过500 一个字节 ...

  10. Day 9 - 线段树

    线段树 引入 线段树是算法竞赛中常用的用来维护 区间信息 的数据结构. 线段树可以在 \(O(\log N)\) 的时间复杂度内实现单点修改.区间修改.区间查询(区间求和,求区间最大值,求区间最小值) ...