結果
| 問題 |
No.2716 Falcon Method
|
| コンテスト | |
| ユーザー |
applejam
|
| 提出日時 | 2025-10-06 16:28:33 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,558 bytes |
| コンパイル時間 | 5,320 ms |
| コンパイル使用メモリ | 335,240 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-06 16:28:45 |
| 合計ジャッジ時間 | 12,296 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 WA * 18 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vmi = vector<mint>;
using vvmi = vector<vmi>;
using vvvmi = vector<vvmi>;
#define all(a) (a).begin(), (a).end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
void solve(){
}
int main(){
int n, q; cin >> n >> q;
string s; cin >> s;
vvi pos(2);
rep(i, s.length()){
int c = (s[i] == 'D') ? 0 : 1;
pos[c].push_back(i);
}
while(q--){
int h, w, p; cin >> h >> w >> p;
if(pos[0].size() == 0){
cout << (p+w)%n << endl;
continue;
}
if(pos[1].size() == 0){
cout << (p+h)%n << endl;
continue;
}
int zh = pos[0].size() - (lower_bound(all(pos[0]), p) - begin(pos[0])), zw = pos[1].size() - (lower_bound(all(pos[1]), p) - begin(pos[1]));
if(zh >= h && zw >= w){
auto ith = lower_bound(all(pos[0]), p), itw = lower_bound(all(pos[1]), p);
ith += h-1; itw += w-1;
cout << (min(*ith, *itw) + 1)%n << endl;
}else if(zh >= h){
auto ith = lower_bound(all(pos[0]), p);
ith += h-1;
cout << ((*ith) + 1)% n << endl;
}else if(zw >= w){
auto itw = lower_bound(all(pos[1]), p);
itw += w-1;
cout << ((*itw) + 1)% n << endl;
}else{
h -= zh; w -= zw;
int lh = (h + pos[0].size() - 1)/pos[0].size(), lw = (w+pos[1].size() - 1)/pos[1].size();
if(lh > lw){
auto itw = pos[1].begin();
itw += (lw%pos[1].size()-1);
cout << ((*itw) + 1)% n << endl;
}else if(lh < lw){
auto ith = pos[0].begin();
ith+= (lh%pos[0].size()-1);
cout << ((*ith) + 1)% n << endl;
}else{
auto ith = pos[0].begin();
auto itw = pos[1].begin();
ith+= (lh%pos[0].size()-1);
itw += (lw%pos[1].size()-1);
cout << (min(*ith, *itw) + 1)%n << endl;
}
}
}
return 0;
}
applejam