結果

問題 No.3795 Circular railway
ユーザー Nihonielse
提出日時 2026-11-12 15:28:44
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,198 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,605 ms
コンパイル使用メモリ 354,040 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2026-11-13 22:07:36
合計ジャッジ時間 8,884 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#line 1 "lib/core.hpp"
// Library and Editor Setting is here: https://github.com/Nihonielse/competitive-library

#ifndef CORE_FILE
#define CORE_FILE

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, s) for (int i = s; i < n; i++)

#define vall(v) v.begin(), v.end()

constexpr int INF = 1 << 30;
constexpr int NEG_INF = -INF;
constexpr ll LINF = 1ll << 62;
constexpr ll NEG_LINF = -LINF;

template <typename T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
using min_priority_queue = priority_queue<T,vector<T>,greater<T>>;

#endif
#line 2 "codes/A.cpp"

int main(){
	ll n,q,s,t,c;
	cin>>n>>q>>s>>t>>c;
	s--; t--;
	if(s>t)t+=n;
	while(q--){
		int u,v;
		cin>>u>>v;
		u--; v--;
		if(u==v){
			cout<<0<<endl;
			continue;
		}
		if(u>v)v+=n;

		if(t-s<=c){
			cout<<v-u<<endl;
		}else{
			if(u<=s&&t<=v){
				cout<<s-u+v-t+c<<endl;
			}else{
				cout<<v-u<<endl;
			}
		}
	}
}
0