补题—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 ...
随机推荐
- 一个例子读懂 JS 异步编程: Callback / Promise / Generator / Async
JS异步编程实践理解 回顾JS异步编程方法的发展,主要有以下几种方式: Callback Promise Generator Async 需求 显示购物车商品列表的页面,用户可以勾选想要删除商品(单选 ...
- 使用Spring Security控制会话
1.概述 在本文中,我们将说明Spring Security如何允许我们控制HTTP会话.此控件的范围从会话超时到启用并发会话和其他高级安全配置. 2.会话何时创建? 我们可以准确控制会话何时创建以及 ...
- HDU2824【欧拉函数性质】
思路: 打表. 利用公式. 类似素数打表一样. #include<bits/stdc++.h> using namespace std; const int N=3e6+10; bool ...
- ZOJ3164【区间dp】
题意: 有n个人,有一种关系叫做8g关系,给出m个关系,给出n个人的阵列 问你最多能拿走多少人,拿走以后相邻就是相邻了 思路: 典型的区间dp: dp[i][j] 代表 i-j 最多能去多少人: 如 ...
- 【Unity3D】3D角色换装++ Advance
http://www.cnblogs.com/dosomething/archive/2012/12/15/2818897.html 本文在之前的文章Unity3D角色换装的原理 基础上做一个补充 给 ...
- Unity手游之路游戏摇杆之Easy Touch 3教程
之前已经介绍过Unity自带的摇杆Joystick,它用起来很简单.但是它也存在很多局限,不能全部满足普通mmo手游的一些需求,例如:要能方便地更好素材:能指定在某个区域显示,或者只有在该区域触摸时才 ...
- qscoj53(图的m着色问题)
题目链接:http://qscoj.cn/contest/12/problem/53/ 题意:中文题诶- 思路:n个点, 那么最多用n种颜色,所以我们可以枚举颜色种类1~n,然后再判断用 i 种颜色可 ...
- [Xcode 实际操作]八、网络与多线程-(23)多线程的同步与异步的区别
目录:[Swift]Xcode实际操作 本文将演示线程的同步与异步的区别. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] 异步线程的运行,是没有按照顺序执行的. ...
- Springboot下事务管理的简单使用
关于事务管理的概念这里就不多介绍了,在我的博客“JDBC事务之理论篇”中也有介绍. 关于Spring的事务管理,主要是通过事务管理器来进行的.这里看个Spring事务管理的接口图:(来自博客https ...
- 17995 Stupid thief 组合数学
17995 Stupid thief 时间限制:1000MS 内存限制:65535K提交次数:0 通过次数:0 题型: 编程题 语言: 不限定 Description A stupid thie ...