結果
問題 | No.1650 Moving Coins |
ユーザー | riano |
提出日時 | 2021-08-20 21:51:17 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 324 ms / 2,000 ms |
コード長 | 2,880 bytes |
コンパイル時間 | 1,938 ms |
コンパイル使用メモリ | 175,508 KB |
実行使用メモリ | 13,336 KB |
最終ジャッジ日時 | 2024-04-22 04:20:00 |
合計ジャッジ時間 | 12,529 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 269 ms
8,948 KB |
testcase_04 | AC | 204 ms
9,400 KB |
testcase_05 | AC | 250 ms
7,896 KB |
testcase_06 | AC | 284 ms
9,248 KB |
testcase_07 | AC | 283 ms
10,060 KB |
testcase_08 | AC | 293 ms
11,100 KB |
testcase_09 | AC | 296 ms
11,152 KB |
testcase_10 | AC | 297 ms
11,292 KB |
testcase_11 | AC | 308 ms
9,748 KB |
testcase_12 | AC | 291 ms
9,144 KB |
testcase_13 | AC | 295 ms
9,108 KB |
testcase_14 | AC | 306 ms
9,584 KB |
testcase_15 | AC | 282 ms
8,784 KB |
testcase_16 | AC | 306 ms
9,932 KB |
testcase_17 | AC | 287 ms
9,852 KB |
testcase_18 | AC | 311 ms
10,248 KB |
testcase_19 | AC | 314 ms
12,692 KB |
testcase_20 | AC | 324 ms
12,820 KB |
testcase_21 | AC | 322 ms
13,336 KB |
testcase_22 | AC | 316 ms
11,164 KB |
testcase_23 | AC | 314 ms
11,036 KB |
testcase_24 | AC | 272 ms
9,440 KB |
testcase_25 | AC | 297 ms
9,436 KB |
testcase_26 | AC | 43 ms
6,528 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:92:13: warning: 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: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 96 | auto[a,b,c] = p; | ^
ソースコード
#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; } }