結果
| 問題 |
No.2716 Falcon Method
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-05 22:41:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,096 ms / 2,000 ms |
| コード長 | 1,796 bytes |
| コンパイル時間 | 5,322 ms |
| コンパイル使用メモリ | 310,672 KB |
| 実行使用メモリ | 8,352 KB |
| 最終ジャッジ日時 | 2024-10-01 02:48:40 |
| 合計ジャッジ時間 | 21,316 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
//*/
#include <atcoder/all>
using namespace atcoder;
//*/
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dbgv(x); for(auto now : x) cout << now << " "; cout << endl;
//using P = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
//*/
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vint;
int op(int a,int b){return a+b;}
int e(){return 0;}
void solve(){
/*/
int n; cin >> n;
vint a(n); rep(i,n) cin >> a[i];
mint ans = 0,two = 2;
rep(i,n) ans += (mint)(a[i])*two.pow(n-1);
cout << ans.val() << endl;
/*/
ll n,q; cin >> n >> q;
string s; cin >> s;
segtree<int,op,e> d(n),r(n);
rep(i,n){
if(s[i] == 'D') d.set(i,1);
else r.set(i,1);
}
rep(ssss,q){
ll h,w,p; cin >> h >> w >> p;
//swap(h,w);
auto f = [&](ll x)->pair<ll,ll>{
x = p+x;
pair<ll,ll> res = {0,0};
res.first = (x/n)*d.all_prod();
res.second = (x/n)*r.all_prod();
if(x%n){
res.first += d.prod(0,x%n);
res.second += r.prod(0,x%n);
}
if(p){
res.first -= d.prod(0,p);
res.second -= r.prod(0,p);
}
return res;
};
ll ac = 4e10,wa = 0;
while(ac-wa>1){
ll mid= (ac+wa)/2;
auto [H,W] = f(mid);
if(H >= h || W >= w) ac = mid;
else wa = mid;
}
cout << (ac+p)%n << endl;
}
//*/
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1; //cin >> t;
rep(_,t) solve();
}