結果
| 問題 |
No.2716 Falcon Method
|
| コンテスト | |
| ユーザー |
inkyaman
|
| 提出日時 | 2024-04-06 20:54:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,407 bytes |
| コンパイル時間 | 1,255 ms |
| コンパイル使用メモリ | 115,972 KB |
| 最終ジャッジ日時 | 2025-02-20 22:39:08 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 WA * 8 |
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;
int N,Q;
string S;
int main() {
cin >> N >> Q >> S;
vector<int> hsum(2*N+1,0), wsum(2*N+1,0);
for(int i = 0; i < 2*N; ++i) {
hsum[i+1] = hsum[i];
wsum[i+1] = wsum[i];
if(S[i%N] == 'D') hsum[i+1]++;
else wsum[i+1]++;
}
int hcnt = hsum[N];
int wcnt = wsum[N];
while(Q--) {
int H, W, P; cin >> H >> W >> P;
ll h = 1e9;
ll w = 1e9;
if(hcnt != 0) {
ll a = (H-1)/hcnt*N;
int b = lower_bound(hsum.begin(),hsum.end(),hsum[P]+H-(H-1)/hcnt*hcnt)-hsum.begin();
b -= P;
h = a+b;
// cout << a << " " << b << endl;
}
if(wcnt != 0) {
ll a = (W-1)/wcnt*N;
int b = lower_bound(wsum.begin(),wsum.end(),wsum[P]+W-(W-1)/wcnt*wcnt)-wsum.begin();
b -= P;
w = a+b;
// cout << a << " " << b << endl;
}
// cout << "h w :" << h << " " << w << endl;
ll mn = min(h,w)-1;
cout << (mn+P+1)%N << endl;
}
}
inkyaman