0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Atcoder 復習 備忘録

Last updated at Posted at 2023-06-04

ABC294 D問題

順序付き集合型 std::set を使う。

D.cpp
set<int> called;
cout << *begin(called)<< "\n";    //begin(called)で先頭をさすイテレータを取得。
                                  //*でイテレータの指す値を取得。

O(log N)で集合の最小値を取得できる。

ABC296 C問題

C.cpp
map<int,int> color;
for(auto x: color){
	ans+=x.second/2; //mapの二つ目の要素にアクセス
}

for (auto [_, cnt]: mp) ans += cnt / 2; //解答の例
	

ABC297 E問題

順序付き集合setを使う

E.cpp
    set<ll> st;
    auto push=[&](ll x){
        rep(i,n){
            ll nx=x+a[i];
            st.insert(nx);
            push(x);
        }
    };
    push(0);
    rep(i,K-1){
        ll x=*st.begin();
        st.erase(x);
        push(x);
    }
    ll ans =*st.begin();

ABC298 C問題

順序付き多重集合std::multiset を使う。実装はstd:setと同じ。

ABC298 D問題

998244353で割った余りを扱う問題ではmodintと呼ばれる構造体を用いる。ACLのmodintのpowでは繰り返し二乗法によって累乗を求める仕様になっている。

D.cpp
using mint = modint998244353;

int main(){
    mint ans=1;

    ans=mint(10)*pow(1000);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?