Good Bye 2020(CodeForces2020.12.30场10:35--1:35)

最近考试都已经结束了,元旦后有两个课程设计,这几天很清闲。
昨晚第一次参加CodeForces比赛,上来就遇到一个纪念场哈,再见2020~
一个半小时才A了第一题,第二题没做出来,菜狗我都不配诶。希望Good Bye 2021的时候我的水平大大提高嗷,定个小目标A4题吧哈哈。


和Tourist他们同场竞技可太棒了!(虽然我只是个小丑哈哈哈哈,他们一分半就把A题A掉了,我一个半小时······


最后Rating变成了368,不应该是从0开始吗?初始分咋成100啦?
在这里插入图片描述


下面来看看Tourist的A题,顺便把B题补了。


A题
题意:给定一组数,求他们之间有多少个不同的非零的差。
我的思路:开int数组,hash,最后遍历整个数组找非零的个数。

上Tourist代码,思路差不多。

/**
 *    author:  tourist
 *    created: 30.12.2020 17:34:56       
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
      cin >> x[i];
    }
    set<int> s;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        s.insert(x[j] - x[i]);
      }
    }
    cout << s.size() << '\n';
  }
  return 0;
}
#include <bits/stdc++.h> //万能头文件,可自己配置,不多说了
ios::sync_with_stdio(false);  //关闭兼容、关闭输入、输出缓存,提高cin、cout效率
cin.tie(0);  //解除cin、cout绑定,进一步提高效率
vector<int> x(n); //最大容量为n的可变数组
set<int> s;  //集合(元素唯一),正好解决了要找不同差的问题

B题
题意:给定一组数,每个数可以充当自己或者比它大1的数,问这一组数最多可充当多少种不同的数。

我····面向样例编程,不太行,直接上Tourist代码

应该是个思维题,我看不懂T神的代码,尴尬。找了个rank21的中国大佬的代码~
#include <bits/stdc++.h>
using namespace std;
int t, n, a[100010];
inline void rmain() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    int ans = 1;
    for (int i = 2; i <= n; i++) {  
        if (a[i] <= a[i - 1]) a[i]++;
        if (a[i] != a[i - 1]) ans++;
    }
    printf("%d\n", ans);
}
int main() {
    scanf("%d", &t);
    while (t--) rmain();
}
if (a[i] <= a[i - 1]) a[i]++;         //啊,脑袋~
if (a[i] != a[i - 1]) ans++;

学到了,自己敲了一个,呜呜呜,好难想。2020最后一天,继续加油嗷~

#include<iostream>
#include<vector>
using namespace std;
int t; 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>t;
	int n;
	while(t--){
		cin>>n;
		vector<int>a(n);
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int ans=1;
		for(int i=1;i<n;i++){
			if(a[i]<=a[i-1]) a[i]++;
			if(a[i]!=a[i-1]) ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
您提供的链接是Codeforces的一个问题,问题编号为104377。Codeforces是一个知名的在线编程竞赛平台,经常举办各种编程比赛和训练。Gym是Codeforces的一个扩展包,用于组织私人比赛和训练。您提供的链接指向了一个问题的页面,但具体的问题内容和描述无法通过链接获取。如果您有具体的问题或需要了解关于Codeforces Gym的更多信息,请提供更详细的信息。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [http://codeforces.com/gym/100623/attachments E题](https://blog.csdn.net/weixin_30820077/article/details/99723867)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [http://codeforces.com/gym/100623/attachments H题](https://blog.csdn.net/weixin_38166726/article/details/99723856)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [CodeforcesPP:Codeforces扩展包](https://download.csdn.net/download/weixin_42101164/18409501)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值