Quantcast
Channel: 初心者タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 21077

Atcoder 生活 3日目

$
0
0

前回

3日目

今回はABC042_B,ABC043_Bをやり、さらに今日開催されたABC159に挑戦しました。

ABC042_B

文字列大好きいろはちゃんイージー

#include <bits/stdc++.h>
usingnamespacestd;intmain(){intN,L;cin>>N>>L;vector<string>S(N);for(auto&e:S){cin>>e;}sort(begin(S),end(S));for(constauto&e:S){cout<<e;}}

sortという存在をこれでまなびました.
昨日は、Aしか解いてなかったので、Bの難しさを知りました

ABC043_B

バイナリハックイージー

#include <bits/stdc++.h>
usingnamespacestd;intmain(){stringS,S_="";cin>>S;for(inti=0;i<S.size();i++){if(S[i]=='0')S_+='0';elseif(S[i]=='1')S_+='1';elseif(S[i]=='B')if(S_!="")S_.erase(S_.size()-1);}cout<<S_<<endl;}

これでやっとforの使い方を理解することができました。

ABC159

A-The Number of Even Pairs

#include <bits/stdc++.h>
usingnamespacestd;intmain(){intN,M;cin>>N>>M;if(N>1&&M>1)cout<<N*(N-1)/2+M*(M-1)/2<<endl;elseif(N<=1&&M>1)cout<<M*(M-1)/2<<endl;elseif(N>1&&M<=1)cout<<N*(N-1)/2<<endl;elsecout<<0<<endl;}

これしか解けなかった、、
やっぱA問題とB問題は格が違うと思う

明日もB問題解くため練習だ!


Viewing all articles
Browse latest Browse all 21077

Trending Articles