結果

問題 No.1650 Moving Coins
ユーザー rianoriano
提出日時 2021-08-20 21:51:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 2,880 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 176,948 KB
実行使用メモリ 13,808 KB
最終ジャッジ日時 2023-08-04 06:13:27
合計ジャッジ時間 12,653 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 266 ms
8,684 KB
testcase_04 AC 199 ms
9,784 KB
testcase_05 AC 245 ms
8,756 KB
testcase_06 AC 276 ms
9,888 KB
testcase_07 AC 282 ms
10,172 KB
testcase_08 AC 285 ms
12,344 KB
testcase_09 AC 303 ms
11,180 KB
testcase_10 AC 297 ms
11,788 KB
testcase_11 AC 304 ms
10,312 KB
testcase_12 AC 298 ms
9,896 KB
testcase_13 AC 291 ms
10,040 KB
testcase_14 AC 302 ms
10,492 KB
testcase_15 AC 287 ms
9,468 KB
testcase_16 AC 294 ms
10,524 KB
testcase_17 AC 288 ms
10,492 KB
testcase_18 AC 306 ms
10,960 KB
testcase_19 AC 318 ms
13,808 KB
testcase_20 AC 314 ms
13,252 KB
testcase_21 AC 313 ms
13,040 KB
testcase_22 AC 309 ms
11,640 KB
testcase_23 AC 310 ms
11,812 KB
testcase_24 AC 273 ms
9,520 KB
testcase_25 AC 291 ms
9,408 KB
testcase_26 AC 41 ms
6,584 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:92:13: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   92 |         auto[a,b,c] = p;
      |             ^
main.cpp:96:13: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   96 |         auto[a,b,c] = p;
      |             ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Pr pair<ll,ll>
#define Tp tuple<int,int,int>
#define riano_ std::ios::sync_with_stdio(false);std::cin.tie(nullptr);typedef modint<mod> mint
using Graph = vector<vector<int>>;

const ll mod = 1000000007;
template<uint64_t mod>
struct modint{
    uint64_t val;
    constexpr modint(const int64_t val_=0) noexcept:val((val_%int64_t(mod)+int64_t(mod))%int64_t(mod)){}
    constexpr modint operator-() const noexcept{
        return modint(*this)=mod-val;
    }
    constexpr modint operator+(const modint rhs) const noexcept{
        return modint(*this)+=rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept{
        return modint(*this)-=rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept{
        return modint(*this)*=rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept{
        return modint(*this)/=rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept{
        val+=rhs.val;
        val-=((val>=mod)?mod:0);
        return (*this);
    }
    constexpr modint &operator-=(const modint rhs) noexcept{
        val+=((val<rhs.val)?mod:0);
        val-=rhs.val;
        return (*this);
    }
    constexpr modint &operator*=(const modint rhs) noexcept{
        val=val*rhs.val%mod;
        return (*this);
    }
    constexpr modint &operator/=(modint rhs) noexcept{
        uint64_t ex=mod-2;
        modint now=1;
        while(ex){
            now*=((ex&1)?rhs:1);
            rhs*=rhs,ex>>=1;
        }
        return (*this)*=now;
    }
    constexpr bool operator==(const modint rhs) noexcept{
        return val==rhs.val;
    }
    constexpr bool operator!=(const modint rhs) noexcept{
        return val!=rhs.val;
    }
    friend constexpr ostream &operator<<(ostream& os,const modint x) noexcept{
        return os<<(x.val);
    }
    friend constexpr istream &operator>>(istream& is,modint& x) noexcept{
        uint64_t t;
        is>>t,x=t;
        return is;
    }
};

int main() {
    riano_; //ll ans = 0;
    ll N; cin >> N;
    ll a[N],b[N];
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    vector<tuple<ll,ll,char>> opr,opl;
    rep(i,N){
        if(a[i]>b[i]){
            rep(j,a[i]-b[i]){
                opl.push_back(make_tuple((-j+a[i]-1-i)*(-1),(i+1),'L'));
            }
        }
        if(a[i]<b[i]){
            rep(j,b[i]-a[i]){
                opr.push_back(make_tuple((j+a[i]+1-i),(i+1)*(-1),'R'));
            }
        }
    }
    sort(opl.begin(),opl.end()); sort(opr.begin(),opr.end());
    ll ans = opl.size() + opr.size();
    cout << ans << endl;
    for(auto p:opl){
        auto[a,b,c] = p;
        cout << b << " " << c << endl;
    }
    for(auto p:opr){
        auto[a,b,c] = p;
        cout << (-1)*b << " " << c << endl;
    }
}
0