結果
| 問題 | No.3795 Circular railway |
| ユーザー |
|
| 提出日時 | 2026-11-13 22:56:30 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 417 ms / 2,000 ms |
| + 186µs | |
| コード長 | 995 bytes |
| 記録 | |
| コンパイル時間 | 2,321 ms |
| コンパイル使用メモリ | 336,460 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-11-13 22:56:38 |
| 合計ジャッジ時間 | 8,203 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
#define ull unsigned ll
#define ll long long
#define ld long double
#define INFL (ll)3e18
#define INF (int)2e9
#define MOD (ll)998244353
#define MODO (ll)(1e9+7)
using namespace std;
template<typename T>istream&operator>>(istream&is,vector<T>&v);
template<typename... Ts>istream&operator>>(istream&is,tuple<Ts...>& t);
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename... Ts>istream& operator>>(istream& is, tuple<Ts...>& t) {apply([&](auto&... args) {((is >> args), ...);},t);return is;}
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,q,s,t,c;
cin >> n >> q >> s >> t >> c;
int u,v;
for(int i = 0;i < q;i++){
cin >> u >> v;
int ans = (v-u+n)%n;
ans = min(ans,(s-u+n)%n+(v-t+n)%n+c);
cout << ans << endl;
}
}