結果
問題 | No.1650 Moving Coins |
ユーザー | riano |
提出日時 | 2021-08-20 21:51:17 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 298 ms / 2,000 ms |
コード長 | 2,880 bytes |
コンパイル時間 | 1,745 ms |
コンパイル使用メモリ | 179,732 KB |
実行使用メモリ | 13,212 KB |
最終ジャッジ日時 | 2024-10-14 03:21:31 |
合計ジャッジ時間 | 11,960 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 250 ms
8,776 KB |
testcase_04 | AC | 194 ms
9,272 KB |
testcase_05 | AC | 230 ms
7,904 KB |
testcase_06 | AC | 258 ms
9,252 KB |
testcase_07 | AC | 273 ms
10,192 KB |
testcase_08 | AC | 281 ms
11,104 KB |
testcase_09 | AC | 287 ms
11,028 KB |
testcase_10 | AC | 292 ms
11,040 KB |
testcase_11 | AC | 284 ms
9,648 KB |
testcase_12 | AC | 275 ms
9,016 KB |
testcase_13 | AC | 285 ms
9,072 KB |
testcase_14 | AC | 283 ms
9,384 KB |
testcase_15 | AC | 263 ms
8,660 KB |
testcase_16 | AC | 290 ms
9,864 KB |
testcase_17 | AC | 262 ms
9,732 KB |
testcase_18 | AC | 294 ms
10,124 KB |
testcase_19 | AC | 292 ms
12,696 KB |
testcase_20 | AC | 298 ms
12,568 KB |
testcase_21 | AC | 298 ms
13,212 KB |
testcase_22 | AC | 289 ms
11,036 KB |
testcase_23 | AC | 295 ms
11,040 KB |
testcase_24 | AC | 258 ms
9,448 KB |
testcase_25 | AC | 277 ms
9,296 KB |
testcase_26 | AC | 38 ms
6,400 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; } }