补题—Codeforces Round #346 (Div. 2) _智商欠费系列
这次的题目相对容易 但是智商依旧不够用
原因有三点 1.英文水平堪忧 2 逻辑不严密 3 细节掌握不够好
传送门
http://codeforces.com/contest/659
A 题目大意 圆环上有n个点 人从a位置出发 走b步 正负代表方向
(a+b%n+n)%n 需要特判 避免走到 0位置
观察数据范围 只需要(100*n+a+b-1)%n+1 还省去了特判
B 题目大意 有n个人的数据 m个地区 每个地区最少参赛2人 晋级2人
出线则输出 需要加赛 如第二个人和第三个人成绩一样 就输出?
#include<cstdio>
#include<map>
//#include<bits/stdc++.h>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<climits>
#define PI acos(-1.0)
#define INF 0x3fffffff
using namespace std;
typedef long long ll;
typedef __int64 int64;
const ll mood=1e9+;
const int64 Mod=;
const double eps=1e-;
const int N=1e3+;
const int MAXN=;
typedef int rl;
inline void r(rl&num){
num=;rl f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<='')num=num*+ch-'',ch=getchar();
num*=f;
}
typedef pair<string,int> psi;
bool cmp(psi a,psi b)
{
return a.second>b.second;
}
int main()
{
vector<psi>v[];
int t;
psi tem;
int n,m;
r(n),r(m);
for(int i=;i<n;i++)
{
cin>>tem.first;
r(t);r(tem.second);
v[t].push_back(tem);
}
for(int i=;i<=m;++i)
{
if(v[i].size()<)
{
putchar('?');
}
else{
sort(v[i].begin(),v[i].end(),cmp);
if(v[i][].second==v[i][].second)
{
putchar('?');
}
else{
cout<<v[i][].first<<' '<<v[i][].first;
}
}
putchar('\n');
}
return ;
}
错误代码
错误原因 未在判断第二个人和第三个成绩是否一样前判断 人数是否大于2
在(——人数等2 第二个人成绩为0的时候 第三个人不存在默认为0 则相等 输出?)因此wa
改完AC
#include<cstdio>
#include<map>
//#include<bits/stdc++.h>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<climits>
#define PI acos(-1.0)
#define INF 0x3fffffff
using namespace std;
typedef long long ll;
typedef __int64 int64;
const ll mood=1e9+;
const int64 Mod=;
const double eps=1e-;
const int N=1e3+;
const int MAXN=1e4+;
typedef int rl;
inline void r(rl&num){
num=;rl f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<='')num=num*+ch-'',ch=getchar();
num*=f;
}
typedef pair<string,int> psi;
bool cmp(psi a,psi b)
{
// if(a.second==b.second) return a.first<b.first;
return a.second>b.second;
}
int main()
{
vector<psi>v[MAXN];
int t;
psi tem;
int n,m;
r(n),r(m);
for(int i=;i<n;i++)
{
cin>>tem.first;
r(t);r(tem.second);
v[t].push_back(tem);
}
for(int i=;i<=m;++i)
{ sort(v[i].begin(),v[i].end(),cmp);
if(v[i].size()>&&v[i][].second==v[i][].second)
{
putchar('?');
}
else{
cout<<v[i][].first<<' '<<v[i][].first;
}
putchar('\n');
}
return ;
}
B——AC
这样写 还是不够好 我们注意到pair默认是先排一维从小到大然后二维依次
在输出的时候用pis 成绩*-1输入 ,成绩*-1从小到大即原成绩从大到小
就可以了
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+;
int n,m,r,p;
vector<pair<int,string> > mp[MAX];
string s;
int main()
{
cin>>n>>m;
for (int i=;i<n;i++)
cin>>s>>r>>p,mp[r].push_back({-p,s});
for (int i=;i<=m;i++)
{
sort(mp[i].begin(),mp[i].end());
if (mp[i].size()> && mp[i][].first==mp[i][].first)
cout<<"?\n";
else
cout<<mp[i][].second<<" "<<mp[i][].second<<'\n';
}
}
某人简短AC码
C 题目大意 找1-n序列中 未标记的和<m
开始用set瞎搞错误 姿势错误
可以开个vis数组 没意思 其实开vis是有问题的 可惜他的数据弱233
于是去学习了一下set的姿势
把存在的的插入 以后的扫描只有一趟 所以不用再次插入
补题—Codeforces Round #346 (Div. 2) _智商欠费系列的更多相关文章
- Codeforces Round #346 (Div. 2)---E. New Reform--- 并查集(或连通图)
Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory lim ...
- 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...
- 水题 Codeforces Round #302 (Div. 2) A Set of Strings
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas
题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...
- 水题 Codeforces Round #303 (Div. 2) A. Toy Cars
题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...
- 水题 Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift
题目传送门 /* 水题:vector容器实现插入操作,暴力进行判断是否为回文串 */ #include <cstdio> #include <iostream> #includ ...
- 水题 Codeforces Round #306 (Div. 2) A. Two Substrings
题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...
- 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...
随机推荐
- Makefile研究(三) —— 实际应用
转自:http://blog.csdn.net/jundic/article/details/17886637 前面讲了Makefile 的简单语法和简单的应用模板,但在实际项目应用中比这个肯定复杂很 ...
- flex设置默认字体为微软雅黑
必须使用英文名称 Microsoft YaHei 否则有些系统不识别
- JavaScript之——对象Object(一)
1. 新建对象.删除和访问: (1).新建 var obj1 = {b: 2}; //对象文本表示法 var obj2 = new Object(); obj2.a = 1; (2).访问 //第一种 ...
- 51nod1483(打表)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1483 题意:中文题诶- 思路: 在输入时预处理每个数据能达到的 ...
- P5136 sequence(矩阵快速幂)
传送门 数列的特征方程和特征根老师上课好像讲过然而我没听--以后老师上数学课要认真听了QAQ 设\(x=\frac{1+\sqrt{5}}{2},y=\frac{1-\sqrt{5}}{2}\),那么 ...
- [Xcode 实际操作]八、网络与多线程-(10)使用异步Get方式查询GitHub数据
目录:[Swift]Xcode实际操作 本文将演示如何通过Get请求方式,异步获取GitHub资源的详细信息. 异步请求与同步请求相比,不会阻塞程序的主线程,而会建立一个新的线程. 在项目导航区,打开 ...
- IT兄弟连 JavaWeb教程 Servlet会话跟踪 获取Session对象
Session对象的获取有两种: ● 有参方法: HttpSession request.getSession(boolean isNew) 参数: true:获取一个Session对象,如果之前S ...
- C#求圆的周长、面积、体积
窗体应用程序 private void button1_Click(object sender, EventArgs e) { double r; r = Convert.ToInt32(textBo ...
- OFFICE 365 A1 Plus账号注册
OFFICE365 A1 Plus账号注册 Office2019与Office365专业增强版之间的区别: Office2019是一次性购买,不会在购买后接收功能更新,但会根据需要接收质量和安全修补程 ...
- C# 对DataTable中按条件进行筛选和更新。
当我们频繁的对数据库进行操作时,可能造成CPU使用率过高,这时我们可以先将数据表读取到DataTable,然后在必要的时候再更新到数据库中. 以下是DataTable中对数据的选择和更新操作.采用Da ...