补题—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 ...
随机推荐
- https协议(4)
架构层次 HTTPS(全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版.即HTT ...
- SCUT - 114 - 作业之数学篇 - 杜教筛
https://scut.online/p/114 \(A(n)=\sum\limits_{i=1}^{n} \frac{lcm(i,n)}{gcd(i,n)}\) \(=\sum\limits_{i ...
- Weekly Contest 78-------->811. Subdomain Visit Count (split string with space and hash map)
A website domain like "discuss.leetcode.com" consists of various subdomains. At the top le ...
- P5175 数列(矩阵加速)
//minamoto #include<bits/stdc++.h> #define R register #define ll long long #define fp(i,a,b) f ...
- (转)linux du命令
转自 http://www.cnblogs.com/peida/archive/2012/12/10/2810755.html Linux du命令也是查看使用空间的,但是与df命令不同的是Linux ...
- echarts相关属性设置(3)环状图
option = { grid: { left: '3%', top: '0%', // height: 500, right: '30%', containLabel: true, }, legen ...
- D - Fliptile
#include <stdio.h> #include <iostream> #include <math.h> #include <algorithm> ...
- foreach循环报NPE空指针异常
前言 最近debug时忽然发现,如果一个集合赋值为null,那么对该集合进行foreach循环(也叫增强for循环)时,会报NPE(即空指针异常NullPointerException). 代码如下: ...
- Connected Components? Codeforces - 920E || 洛谷 P3452 &&bzoj1098 [POI2007]BIU-Offices
https://codeforces.com/contest/920/problem/E https://www.luogu.org/problemnew/show/P3452 https://www ...
- Hive_Hive和数据仓库简介
文章摘自 : http://www.imooc.com/video/7573 Hive是建立在Hadoop HDFS上的数据仓库基础架构.Hive可以用来进行数据的ETL.Hive定义了简单的类似SQ ...