首页 > 其他分享 >atcoder集

atcoder集

时间:2024-04-28 13:22:22浏览次数:17  
标签:atcoder ver cout int namespace back ++

AtCoder Beginner Contest 351

A - The bottom of the ninth(签到题)

 

Code:

#include<bits/stdc++.h>
    
using namespace std;
#define debug(x) cerr << #x << ": " << x << '\n';
    
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int ans = 0;
    for (int i = 1; i <= 9; i++) {
        int x; cin >> x;
        ans += x;
    }
    for (int i = 1; i <= 8; i++) {
        int x; cin >> x;
        ans -= x;
    }
    cout << ans + 1 << '\n';
    return 0;
}

B - Spot the Difference

思路:

给你两个网格进行比较 只有一个字符不一样输出这个索引的位置 索引从1开始

Code:

#include<bits/stdc++.h>
	
using namespace std;
#define debug(x) cerr << #x << ": " << x << '\n';
	
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector <string> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		string b; cin >> b;
		for (int j = 0; j < n; j++) {
			if (a[i][j] != b[j]) {
				cout << i + 1 << ' ' << j + 1 << '\n';
			}
		}
	}
	return 0;
} 

  

C - Merge the balls 

Code:

#include<bits/stdc++.h>
	
using namespace std;
#define debug(x) cerr << #x << ": " << x << '\n';
	
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector <int> ver;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		ver.push_back(x);
		while (ver.size() >= 2 && ver.back() == ver[ver.size() - 2]) {
			ver.pop_back();
			ver.back() ++;
		}
	}
	cout << ver.size() << '\n';
	return 0;
} 

  

 

标签:atcoder,ver,cout,int,namespace,back,++
From: https://www.cnblogs.com/youhualiuh/p/18163546

相关文章

  • [atcoder 349] [F - Subsequence LCM]
    SOSDP学习笔记Linkhere:代码:importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;importjava.math.BigInteger;importjava.util.*;publicclassMain{staticintn;staticlongm;staticlong[]a;......
  • AtCoder Beginner Contest 350 A - G 题解
    AtCoderBeginnerContest350A-PastABCsSolution把最后三个字符转成数字判断即可Code#include<bits/stdc++.h>usingnamespacestd;intmain(){strings;cin>>s;s=s.substr(3,3);intx=0;x=(s[0]-'0')*100+(s[1]-�......
  • atcoder regular 176 (ARC176) A、B题解
     A很容易有一个错误想法,就是行从1~n,列从1~n拿,这样,第三个样例,最后,第7行,第7列,需要都增加两个数,但是(7,7)这个位置只能有一个数。我的做法是优先队列/set队列,每次选择行、列之中当前已经有的数目最少的(这样它们最需要添加),这样能保证,行列需要添加的,不会出现只能选择多个行列一样的......
  • AtCoder Beginner Contest 350 G - Mediator
    链接:https://atcoder.jp/contests/abc350/tasks/abc350_g大致题意:给出n个点,q个询问1号询问要求u,v之前加一条无向边图始终是一个森林2号询问询问是否有一个点与u,v都相邻,若有则输出该点,若无则输出0。询问强制在线。思路:在题目要求的图中,满足2号询问的点只有三种情况:要么这个......
  • AtCoder Beginner Contest 350
    B-DentistAoki难度:⭐题目大意现在有数列1~n,现在有m次操作,每次给出一个x,如果x存在就是删去,不存在就加上;问最后数列还剩多少个;解题思路数据很小,暴力就行;神秘代码#include<bits/stdc++.h>#defineintlonglong#defineIOSios::sync_with_stdio......
  • Atcoder ABC 350 全题解
    题外话别以为博主之前几场ABC都咕咕咕了,最近状态不好,这次ABC终于回来了(也有可能是题目变容易了,有图为证)P.S.请耐心看到最后!!否则后果自负!!!AB这年头谁不会AB啊当然有。不学OI的人。C考虑选择排序,依次将$1,2,3\cdots$与它们应该在的位置进行交换。那如果真的......
  • AtCoder Beginner Contest 350
    A-PastABCs(abc350A)题目大意给定一个形如ABCXXX的字符串。问XXX是否是\(001\to349\)之间,且不能是\(316\)。解题思路将后三位转换成数字后判断即可。神奇的代码a=int(input().strip()[3:])ifa>=1anda<=349anda!=316:print("Yes")else:p......
  • AtCoder Beginner Contest 350 (小白来了)
    A-PastABCs思路:题意需要计算已经结束的比赛其中1~349属于已经结束的比赛,其中316没有计算进去模拟即可Code:#include<bits/stdc++.h>usingnamespacestd;intmain(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);strings;cin>......
  • AtCoder Beginner Contest 350 解题报告
    AtCoderBeginnerContest350A-PastABCs当且仅当串为\(\texttt{ABC000},\texttt{ABC316},\texttt{ABC350}\sim\texttt{ABC999}\)时输出\(\texttt{No}\)。(本人因\(000\)挂了一发。)#include<bits/stdc++.h>usingnamespacestd;intmain(){ ios::sync_with_......
  • AtCoder Beginner Contest 319
    A-LegendaryPlayers#include<bits/stdc++.h>usingnamespacestd;intmain(){map<string,string>h;h["tourist"]="3858";h["ksun48"]="3679";h["Benq"]="3658"......