首页 > 其他分享 >AtCoder Beginner Contest 345

AtCoder Beginner Contest 345

时间:2024-03-16 21:56:20浏览次数:24  
标签:longlong AtCoder Beginner Contest int long 345 ans

是这样的,C 的 longlong 只开了 ans 没开全局,AC12 WA 12,调了一个小时,在赛后 1min 发现了该错误。

没开 long long 见祖宗,望周知;

这是 C 的码,简单的小题一只,可怜的 longlong。

#include<bits/stdc++.h>
#define int long long
using namespace std;
string s;
int n,f,ans;
map<char,int> vis;
vector<char> e;
signed main(){
	cin>>s;
	n=s.length();
	ans=n*(n-1)/2;
	for(int i=0;i<n;i++){
		char c=s[i];
		if(!vis[c]) e.push_back(c);
		else f=1;
		vis[c]++;
	}
	for(auto i:e){
		int t=vis[i];
		ans-=t*(t-1)/2;
	}
	cout<<ans+f;
	return 0;
}

记录

标签:longlong,AtCoder,Beginner,Contest,int,long,345,ans
From: https://www.cnblogs.com/Moyyer-suiy/p/18077710

相关文章

  • AtCoder Grand Contest 022 E Median Replace
    洛谷传送门AtCoder传送门考虑对于一个确定的串怎么判断合法性。容易发现删到某个时刻若\(1\)的个数大于\(0\)的个数了,因为我们肯定不会蠢到在不是全\(1\)的时候删\(111\),所以\(c_1-c_0\)在不是全\(1\)的时候至少是不会变小的。所以我们的目标就是让\(c_1-c_0......
  • AtCoder Beginner Contest 344 A-G 题解
    AtCoderBeginnerContest344A-SpoilerQuestion删除两个|之间的字符Solution按照题意模拟即可Code#include<bits/stdc++.h>usingnamespacestd;intmain(){strings;cin>>s;stringp1,p2;for(inti=0;i<s.size();i++){......
  • Toyota Programming Contest 2024#3(AtCoder Beginner Contest 344)
    C先预处理出三个数组能拼出的数,存放到map中。查询的时候只需要看这个数是否出现在map里即可。时间复杂度\(O(n^3\logv+Q\logv)\),\(n\leq100\),\(\logv\)是map的时间复杂度。#include<bits/stdc++.h>usingnamespacestd;#defineintlonglongconstintN=3e......
  • AtCoder Beginner Contest 344
    B-Delimiter难度:⭐题目大意把一个数组倒序输出;解题思路没啥好说的;神秘代码#include<bits/stdc++.h>#defineintlonglong#defineIOSios::sync_with_stdio(false);cin.tie(0);cout.tie(0);#defineendl'\n'usingnamespacestd;constintN=4e6+......
  • AtCoder Beginner Contest 344
    A-Spoiler#include<bits/stdc++.h>usingnamespacestd;usingi32=int32_t;usingi64=int64_t;usingldb=longdouble;#defineinti64usingvi=vector<int>;usingpii=pair<int,int>;constintmod=998244353;constintinf......
  • AtCoder Beginner Contest 344
    AtCoderBeginnerContest344ABCD略EInsertorErase手写链表调了这么久。。链表模板。FEarntoAdvance考虑DP,但是我们发现不是很好转移,然后我们发现\(n\le80\),我们观察一下题目的性质。如果路径确定了,那么我们肯定会在最大值的地方使劲加到终点为止。那么我们考......
  • AtCoder Beginner Contest 344
    基本情况ABCE秒了,D小细节处理出错(太久没写dp)+4。D-StringBagshttps://atcoder.jp/contests/abc344/tasks/abc344_d分组背包,但是字符串的细节要注意signedmain(){intn;std::stringT,str[110][15];intF[110][110],a[110];std::cin>>T>>n;......
  • AtCoder Regular Contest 171
    Preface小补一场ARC,D还是很有意思的但想了半天不会,鉴定为纯纯的彩笔A-NoAttacking考虑怎么放rook能使得留下来能放pawn的格子数量最多,手玩一下会发现先按照\((2,2),(4,4),(6,6),\cdots\)的顺序放,放满后再接着放\((1,1),(3,3),(5,5),\cdots\)是最优的手玩一下可以得出在放......
  • AtCoder Beginner Contest 343
    A-WrongAnswer(abc343A)题目大意给定\(a,b\),输出\(c\),使得\(a+b\neqc\)解题思路从\(0\)开始枚举\(c\)的取值即可。神奇的代码#include<bits/stdc++.h>usingnamespacestd;usingLL=longlong;intmain(void){ios::sync_with_stdio(false);cin.......
  • AtCoder Beginner Contest 321
    \[\large\text{Round12:AtCoderBeginnerContest321}\]一言:只要你在,我便无所不能。——进击的巨人感觉只有最后一道题有点意思,其他的就是时间问题,但是速度还是不够快,思维要跟上啊。有意思的是,周考考了回退背包,这里居然又来一次。。\(\text{G:ElectricCircuit}......