博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【CodeForces】Round #436
阅读量:4590 次
发布时间:2019-06-09

本文共 3569 字,大约阅读时间需要 11 分钟。

A FairGame

//Fair Game//一道裸的模拟题而已//二十分钟了。。。mdzz//虽然英文蛋疼#include
#include
using namespace std;map
ma;int a, b;int x, y;int main(){
int n; cin>>n; for(int i = 1; i <= n; i++){
int t; cin>>t; ma[t]++; } if(ma.size() != 2){
cout<<"NO\n"; return 0;} int co = 0; for(map
::iterator it = ma.begin(); it != ma.end(); it++){
if(co++==0){
a = it->first; x = it->second; } else {
b = it->first; y = it->second; } } if(x!=y || a==b)cout<<"NO\n"; else cout<<"YES\n"<
<<" "<<<"\n"; return 0;}

B

//第二题反而开始灌水了,十分钟都没有就搞定了??,结果WA。。。//两个智障BUG改了10分钟,我还差点写了对拍#include
#include
#include
#include
using namespace std;set
Set;int main(){
int n; cin>>n; string s; cin>>s; int t = 0, ans = 0; for(int i = 0; i < n; i++){
//BUG1QAQ字符串为什么会从1开始呢。。。 if(isupper(s[i])){
ans = max(ans, t); t = 0; Set.clear();} else if(islower(s[i])){
if(Set.count(s[i]))continue; else {
Set.insert(s[i]); t++; } } } //BUG2出来的时候要更新,万一没有大写字母呢 ans = max(ans, t); cout<
<<"\n"; return 0;}

C

//WA//数据范围有点方了,先试试模拟会不会T, 专业打表写了半小时我去。。。//打表到这份上也是没谁了,然而还是炸了,,第六个点就WA,,然而,真的,没法改了。。。#include
using namespace std;int main(){
int a, b, f, k; cin>>a>>b>>f>>k; int lx = f, rx = a-f; int ln = f*2, rn = (a-f)*2; int dir = 0, res = b-lx;//dir为0朝右边, int i = 0, ans = 0; if(res < 0){
cout<<"-1\n"; return 0; } while(i < k-1){
if(res < 0){
cout<<"-1\n"; return 0; } if(!dir){
if(res >= rn){
dir = 1; res -= rn; i++; continue; }else{
dir = 1; res = b-rn; i++; ans++; } if(res < 0){
cout<<"-1\n"; return 0; } } else{
if(res >= ln){
dir = 0; res -= ln; i++; continue; }else{
dir = 0; res=b-ln; i++; ans++; } if(res < 0){
cout<<-1<<"\n"; return 0; } } } if(res < 0){
cout<<"-1\n"; return 0; } if(i == k-1){
if(!dir && res < rx)ans++; if(dir && res < lx)ans++; } if(res < 0){
cout<<"-1\n"; return 0; } cout<
<<"\n"; return 0;}
//AC//正确的打表姿势#include
using namespace std;int main(){
int a, b, f, k; cin>>a>>b>>f>>k; int dir = 0, res = b-f, ans = 0; if(res < 0){
cout<<-1<<"\n"; return 0; } while(k-->0){
int l; if(!dir){
if(k == 0)l = a-f; else l = (a-f)<<1; }else{
if(k == 0)l = f; else l = f<<1; } if(res < l){
ans++; res = b; } res -= l; dir = !dir; if(res < 0){
cout<<-1<<"\n"; return 0; } } cout<
<<"\n"; return 0;}

D

//WA//贪心失败。。sort失败,,,现在手写排序已经来不及了。。。#include
#include
#include
#define maxn 200010using namespace std;set
s;int a[maxn], b[maxn], c[maxn];//b记录值i第一次在a中出现的位置bool cmp(int a, int b){
//if(c[a]&&c[b]) return a < b;}int main(){
int n; cin>>n; int t, ans = 0, minv = 1; for(int i = 1; i <= n; i++){
cin>>t; a[i] = t; if(!s.count(t)){
s.insert(t); b[t] = i; continue; } else{
if(minv >= *s.begin()){
for(set
::iterator it = s.begin()++; it != s.end(); it++){
if(minv < *it)break; else minv = (*it)+1; } } a[b[t]] = minv; c[minv] = 1; b[t] = i; minv++; ans++; } } sort(a+1,a+n+1, cmp); cout<
<<"\n"; for(int i = 1; i <= n; i++) cout<
<<" "; cout<<"\n"; return 0;}

转载于:https://www.cnblogs.com/gwj1314/p/10200059.html

你可能感兴趣的文章
c# 方法成员
查看>>
c# 定义和调用索引器
查看>>
c# 引用参数-ref
查看>>
c# 多态
查看>>
c# 参数数组
查看>>
c# 虚属性
查看>>
c# 子类的声明
查看>>
c# 类嵌套
查看>>
c# 方法的隐藏
查看>>
c# 接口实现
查看>>
c# 密封类
查看>>
c# is运算符
查看>>
c# 抽象类与接口
查看>>
c# 委托
查看>>
c# 接口使用
查看>>
c# 事件
查看>>
c# as运算符
查看>>
c# 调试过程
查看>>
c# 结构
查看>>
C# 中的异常处理
查看>>