Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int w, q, x, n, m, i, s, f, t;
cin >> n >> m;
for (i = 0; i < n; i++) {
cin >> s >> f >> t;
q = t;
t++;
if (t <= m)
x = t;
else {
if ((t - m) / (m - 1) % 2 == 1)
x = (t - m) % (m - 1) + 1;
else
x = m -... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int m;
int g(int t, int f) {
int l, d;
t %= 2 * m - 2;
if (0 <= t && t < m - 1) {
l = t;
d = true;
} else {
l = (2 * m - 2) - t;
d = false;
}
if (l < f)
if (d)
return f - l;
else
return l + f;
else if (l > f)
if (!d)
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | n, m = map(int, raw_input().split())
k = 2 * (m - 1)
p = [0] * n
for i in range(n):
s, f, t = map(int, raw_input().split())
d = t % k
if s < f: p[i] = (k if s <= d else 0) + f - 1 + t - d
elif f < s: p[i] = (k if d + s > k + 1 else 0) + k + 1 - f + t - d
else: p[i] = t
print('\n'.join(map(str, p))) | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int gao(int n, int k, int t) {
int m = 2 * (n - 1);
int x = t / m * m;
int y = t % m;
if (k >= 1 + y) {
x += k - 1;
} else if (k <= n - (y - (n - 1))) {
x += (n - 1) + (n - k);
} else {
x += m + k - 1;
}
return x;
}
int main() {
int n, m, a, b, c, i;
scanf("%d%d"... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
long n, m;
cin >> n >> m;
while (--n >= 0) {
long s(0), f(0), t(0), output(0);
cin >> s >> f >> t;
if (s == f) {
output = t;
} else {
long T = 2 * (m - 1);
--s;
--f;
output ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | n,m=map(int,input().split())
m-=1
a=[]
for i in range(n):
s,f,t=map(int,input().split())
s-=1
f-=1
if s==f:
a.append(t)
elif s<f:
c=s
while c<t:
c+=2*m
a.append(c+f-s)
else:
c=m*2-s
while c<t:
c+=2*m
a.append(c+s-f)
... | PYTHON3 |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.*;
import java.util.*;
public class Main {
// static Scanner in; static int next() throws Exception {return in.nextInt();};
static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
// static BufferedReader in;
static PrintWriter out;
public static void ma... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 |
import java.io.*;
import java.util.*;
public class Elevator implements Runnable {
public int nextReach(int t, int pos, int m) {
//System.out.println(t + " " + pos + " " + m);
int del = t / (m * 2) * (m * 2);
t -= del;
int t1 = pos;
int t2 = (m) + (m - pos);
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.*;
public class A {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int n=in.nextInt(),m=in.nextInt();
for (int i=1;i<=n;i++) {
int ans=0;
int s=in.nextInt(),f=in.nextInt(),t=in.nextInt(),v = (t-1)/(m-1);
if (s==f) {System.out.println(t);continue;}
if (v%2==... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | l=lambda _:map(int, raw_input().split())
n,m=l('')
N=m*2 - 2
for s,f,t in map(l, ['']*n):
T = t % N
if s < f and s <= T:
print t + N - T + f - 1
elif s == f:
print t
elif s < f and s > T:
print t + f - T - 1
elif s > f and T <= N - s +1:
print t + N-f - T +1
e... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int main() {
int n, m;
while (scanf("%d %d", &n, &m) != EOF) {
while (n--) {
int s, f, t;
scanf("%d %d %d", &s, &f, &t);
if (s == f) {
printf("%d\n", t);
continue;
}
int row = t / (m - 1) + (t % (m - 1) != 0 ? 1 : 0);
if (t == 0) {
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using std::cerr;
using std::cin;
using std::cos;
using std::cout;
using std::endl;
using std::make_pair;
using std::map;
using std::max;
using std::min;
using std::next_permutation;
using std::pair;
using std::priority_queue;
using std::queue;
using st... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double inf = 1e100;
const int iinf = 1 << 30;
int a[1000][1000];
vector<int> v[1000], v2[1000], vv;
int dfs(int q) {
vv.push_back(q);
if (v[q].size() > 0)
return min(dfs(v[q][0]), a[q][v[q][0]]);
else
return iinf;
}
int main() {
int n, m;
cin >> n >>... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10, inf = 1e10;
int main() {
int n, m, s, f, t, salita;
scanf("%d%d", &n, &m);
salita = 2 * (m - 1);
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &s, &f, &t);
if (s == f) printf("%d\n", t);
if (s < f) {
int tt = t - (s - 1);
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, m;
int s, f, t;
int main() {
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> s >> f >> t;
--s;
--f;
if (s == f) {
cout << t << endl;
continue;
}
if (s < f) {
int num = s;
while (num < t) num += 2 * (m - 1);
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
int s, f, t;
scanf("%d%d%d", &s, &f, &t);
int a = t % (2 * m - 2);
if (s == f) {
printf("%d\n", t);
continue;
}
bool up = 1;
if (a > m - 1) up = 0;
int ans ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:256000000")
template <typename T>
int size(T& a) {
return (int)a.size();
}
template <typename T>
T sqr(T a) {
return a * a;
}
long long getMinStart(int s, int t, int m) {
int l = 0, r = 1000000000;
long long res = r;
while (l <= r) ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& out, const vector<T>& data) {
out << "[";
for (int i = 0; i < data.size(); ++i) out << data[i] << " ";
out << "]";
return out;
}
template <class T>
ostream& operator<<(ostream& out, const set<T>& s) {
out << "{";
f... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int main() {
long n, m, inicio, fin, timein, k, i;
scanf("%ld %ld", &n, &m);
long time[n];
for (i = 0; i < n; i++) {
scanf("%ld %ld %ld", &inicio, &fin, &timein);
if (inicio != fin) {
k = 0;
if (inicio < fin) {
while (timein > (inicio - 1) + 2 * (m - 1) * k) ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt() - 1;
for (int i = 0; i < n; i++) {
int s = sc.nextInt() - 1;
int f = sc.nextInt() - 1;
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1E-7;
int n, m, s, t, f;
int main() {
cin >> n >> m;
for (int(i) = 0; (i) < (n); ++(i)) {
cin >> s >> f >> t;
if (s == f) {
cout << t << endl;
continue;
}
int u = t % (m * 2 - 2) + 1;
if (u... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, m;
cin >> n >> m;
while (n--) {
long long s, f, t;
cin >> s >> f >> t;
long long k;
if (s > f) {
k = m + (m - s);
} else if (s < f) {
k = s;
} else {
cout << t << '\n';
;
continue;
}... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
int s, f, t;
cin >> s >> f >> t;
int x = t % (2 * (m - 1));
int y = t - x;
int ans = 0;
if (s == f) {
ans = t;
} else if (s < f) {
if (x <= s - 1) {
ans... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int person = input.nextInt();
int floor = input.nextInt();
int[] start = new int[person];
int[] end = new int[... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double PI = acos(-1.0);
int n, m;
int get(int i, int s) {
if (i == 1)
return s - 1;
else
return (2 * m - 1 - s) % (2 * m - 2);
}
int dist(int i, int j) {
int res = j - i;
if (res < 0) res += 2 * m - 2;
retur... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.*;
import java.util.*;
import java.util.List;
public class Main2 {
private static StringTokenizer st;
private static BufferedReader br;
public static void print(Object x) {
System.out.println(x + "");
}
public static String join(List<?> x, String space) {
StringBuild... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long at(long long t, long long m) {
long p = (2 * m - 2 + t) % (2 * m - 2) + 1;
if (t == 2 * m - 2) t = 1;
if (p <= m) return p;
return (2 * m - p);
}
int main() {
long long n, m;
long long s, f, t;
cin >> n >> m;
long i, j, k;
for (i = 0; i < n; i++)... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void read(int &x) {
register int c = getchar();
x = 0;
for (; c < 48 || c > 57; c = getchar())
;
for (; c > 47 && c < 58; c = getchar()) x = (x << 1) + (x << 3) + c - 48;
}
int main() {
int n, m, s, f, t;
read(n);
read(m);
m = m * 2 - 2;
while (n--) {
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int maxn = 35;
int n, m, s, f, t;
int once;
int main() {
cin >> n >> m;
once = m - 1;
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &s, &f, &t);
if (s == f) {
printf("%d\n", t);
continue;
}
if (s < f) {
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double dinf = 1e200;
void mytimer(string task) {}
void ext(int c) {}
int main() {
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0; i < (n); ++i) {
int a, b, t;
cin >> a >> b >> t;
if (a == b) {
cout << t << '\n';
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | n,m = map(int, raw_input().split())
def move(fr, to, direct):
global m
cnt = 0
if direct[0] == 0:
if fr <= to:
cnt += to - fr
else:
cnt += ((m-1) - to) + ((m-1) - fr)
direct[0] = 1
else:
if fr >= to:
cnt += fr - to
else:
... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int N, M;
void solve() {
scanf("%d%d", &N, &M);
for (int i = 0; i < N; ++i) {
int s, f, t;
scanf("%d%d%d", &s, &f, &t);
if (s == f) {
printf("%d\n", t);
}
int tm = (M - 1) * 2;
int x = t % tm;
if (s < f) {
if (x <= (s - 1))
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | def g(f, t, m):
x = max((t - f) / (2 * m) + 1, 0)
y = max((t + f - 2) / (2 * m), 0)
return min(2 * m * x + f - 1, 2 * m * y + 2 * m + 1 - f)
n, m = map(int, raw_input().split())
print '\n'.join(`[g(f, g(s, t, m - 1), m - 1), t][s == f]` for s, f, t in [map(int, raw_input().split()) for _ in range(n)]) | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline T pow2(T a) {
return a * a;
}
template <class T>
inline bool mineq(T a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
int n, m;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long const M = 5e5 + 10, M2 = 1e7 + 10, mod = 1e9 + 7, inf = 1e18 + 10;
long long n, m, a[M], siz;
long long fans(long long x, long long t) {
long long res = t / siz;
long long hlp = siz * res;
long long rim = t % siz;
if (x - 1 >= rim) {
return x - 1 + hlp... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.util.StringTokenizer;
public class MyTask{
public static void main(String args[]){
OutputStream outputstream = System.out;
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | n, m = [int(_) for _ in raw_input().split(" ")]
times = []
for x in range(n):
s, f, t = [int(_) for _ in raw_input().split(" ")]
times.append([s, f, t])
for time in times:
s, f, t = time
#print s, f, t
time = abs(s - f)
period = 2*(m-1)
if s == f:
time = t
else:
# 0 -> 1
# m-1 -> m
# m... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long m, n, bd, kt, t;
long cal(long bd, long kt, long t) {
if (bd == kt) return t;
long tmin;
if (bd < kt) {
tmin = bd - 1;
if (tmin < t)
while (tmin < t) tmin += 2 * (m - 1);
return tmin + kt - bd;
} else {
bd = m + (m - bd);
kt = m + (m -... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 |
import java.util.*;
import java.math.*;
import static java.lang.Character.isDigit;
import static java.lang.Character.isLowerCase;
import static java.lang.Character.isUpperCase;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class Solution117A {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok ... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import static java.lang.Math.*;
import java.util.*;
import java.io.*;
public class A {
public void solve() throws Exception {
long n = nextInt(), m = nextInt();
long period = (m-1)*2;
debug(period);
for (int i=0; i<n; ++i) {
long s = nextInt(), f = nextInt(), t = nextI... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int main() {
int n, m;
int a, b, t;
while (scanf("%d%d", &n, &m) != EOF) {
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &a, &b, &t);
if (a == b) {
printf("%d\n", t);
} else if (a < b) {
int r = t / (m - 1);
if (r % 2 == 0) {
int flo... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int tf(int m, int t, int x) {
int te = t % (2 * (m - 1)), e = m - abs(te - m + 1);
if (te < m - 1 && e <= x || te >= m - 1 && e >= x)
return abs(e - x);
else if (te < m - 1)
return m - e + m - x;
else
return e + x - 2;
}
int main(void) {
int n, m;
scanf("%d %d", &n, &m);... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int main() {
long n, m;
scanf("%ld %ld", &n, &m);
while (n--) {
long s, f, t, v, mov = 0;
scanf("%ld %ld %ld", &s, &f, &t);
if (s == f) {
mov = t;
} else {
v = 2 * (m - 1);
--s;
--f;
mov = (t / v) * v;
if (s < f && (mov + s) < t) {
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import static java.util.Arrays.deepToString;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class A {
static int [] liftAt(int time, int m) {
int dir = time / (m - 1);
if (dir % 2 == 0) {
return new int[] {0, time % (m - 1)};
} else {
return new int[] {1, m - 1 - (time % (m -... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int maxn = (1 << 15) + 10;
long long n, m;
long long a[N];
long long ans;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
m = m * 2 - 2;
while (n--) {
int s, f, t;
cin >> s >> f >> t;
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 |
import java.util.Scanner;
public class elevatorrr {
public static void main(String[] args) throws Exception {
int n, m;
Scanner scan = new Scanner(System.in);
n = scan.nextInt();
m = scan.nextInt() - 1;
int period = 2 * m - 2;
int[] s = new int[n], f = new int[n], ... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
public class C117A {
static int m, n;
static class U implements Comparable<U>{
int a, b, c, i, r;
public... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.*;
import java.io.*;
public class elevator
{
static long n , m , s ,f ,t , cur , temp , a;
static boolean up;
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner(System.in);
n = in.nextLong();
m = in.nextLong();
for(in... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.IOException;
import java.util.Scanner;
public class test {
static long m;
static void Run(long s, long f, long t) {
if (s == f) {
System.out.println(t);
return;
}
long time = 0;
if (s < f) {
long loop = t / ((m - 1) * 2);
if (t % ((m - 1) * 2) > s - 1)
loop++;
tim... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a2b(int i, int j, bool dir) {}
int main() {
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
int s, f, t;
cin >> s >> f >> t;
s--, f--;
int tt = t;
t %= 2 * m - 2;
int ans = 0;
if (t < m) {
if ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int main() {
long int n, m, add, s, f, t, s1, s2, choice;
scanf("%ld %ld", &n, &m);
add = (m - 1) << 1;
while (n--) {
scanf("%ld%ld%ld", &s, &f, &t);
if (f == s) {
printf("%d\n", t);
continue;
}
s1 = s - 1;
s2 = 2 * m - 1 - s;
while (1) {
if (s1... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
import java.util.function.*;
@SuppressWarnings("unchecked")
public class P117A {
final static int LU = 1, LD = -1;
int d(int t, int m) {
t %= 2 * (m - 1);
return ((t < (m - 1)) ? LU : LD);
}
int f(int t, int m) {
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout << setprecision(32);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
int s, f, t;
cin >> s >> f >> t;
if (s < f) {
int k = max(0, t - s + 1);
k = (k + 2 * m - 3) / (2 * ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 |
from math import ceil
n, m = [int(i) for i in raw_input().split(" ")]
dm = 2*(m-1)
def tmin(x, t):
global dm
return min(dm*int(ceil(float(t - 1 + x) / dm)) - x + 1, dm*int(ceil(float(t - x + 1) / dm)) + x - 1)
while n:
n -= 1
s, f, t = [int(i) for i in raw_input().split(" ")]
if s == f:
... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import sys
n, m = map(int, sys.stdin.readline().split())
ok = 2*(m-1)
for i in xrange(n):
s, f, t = map(int, sys.stdin.readline().split())
if s == f:
print t
elif s < f:
if t < s:
print s-1+f-s
else:
tot = s-1
while tot < t:
tot... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < (n); i++) {
int s, f, t;
scanf("%d%d%d", &s, &f, &t);
if (s == f)
printf("%d\n", t);
else {
s--;
f--;
int p = 2 * (m - 1);
int delay = 0;
int dr;
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, m, t, x, y, z, num;
int get(int x, int t) {
int t1 = t - x + 1;
int num1 = t1 / (m * 2 - 2) + (t1 % (m * 2 - 2) != 0);
if (t1 <= 0) num1 = 0;
int t2 = t - (m - 1 + m - x);
int num2 = t2 / (m * 2 - 2) + (t2 % (m * 2 - 2) != 0);
if (t2 <= 0) num2 = 0;
ret... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long int s, f, t;
long long int n, m, d;
long long int mp(long long int a) {
if (a < m)
return a;
else
return 2 * m - 2 - a;
}
long long int dist(long long int t, long long int s) {
long long int r = t % (2 * m - 2);
long long int mpt = mp(r) + 1;
if ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | n,m=map(int,raw_input().split())
for i in range(n):
s,f,t=map(int,raw_input().split())
if s!=f:
lpos=lambda: t%(2*m-2)
f_pos=(s-1,2*m-2-s+1)
s_pos=(f-1,2*m-2-f+1)
while not lpos() in f_pos:
if lpos()<=f_pos[0]:
t-=lpos()-f_pos[0]
elif lpos()<=f_pos[1]:
... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
public static boolean bg = true;
public static void main(String[] args) throws Exception {
ST in = new ST();
//LR in = new LR();
int n = in.ni();
m = in.ni();
for (int i=0;i<n;i++){
long s = in.ni();
long f = in.ni();
l... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.*;
import java.io.*;
public class Main implements Runnable {
int floors;
public void solve() throws IOException {
int N = nextInt();
floors = nextInt() - 1;
for(int i = 0; i < N; i++){
int start = nextInt() - 1;
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 |
import java.io.*;
import java.util.*;
public class A{
private BufferedReader in;
private StringTokenizer st;
void solve() throws IOException{
int n = nextInt();
long m = nextLong();
while(n-->0){
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, m, s, f, t, k;
int main() {
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> s >> f >> t;
if (s == f)
cout << t << endl;
else if (s < f) {
if (t < s - 1)
k = 0;
else {
k = (t - (s - 1)) / (2 * (m - 1));
if... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, s, f, t, l, l1, k;
cin >> n;
cin >> m;
vector<long long> a(n, 0);
for (int i = 0; i < n; i++) {
cin >> s;
cin >> f;
cin >> t;
k = 0;
if (s == f) {
a[i] = t;
} else {
l = t / (2 * m - 2);
l1 = t... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;
public class A implements Runnable{
public void run() {
long n = nextInt();
long m = nextInt();
for (int i = 0; i < n; ++i) {
long s = nextInt();
long f = nextInt();
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.*;
import java.util.*;
import java.math.*;
public class Template {
BufferedReader in;
StringTokenizer st;
PrintWriter out;
String _token() throws IOException {
while (in.ready() && !st.hasMoreTokens()) {
st = new StringTokenizer(in.readLine());
}
retu... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
ios_base::sync_with_stdio(0);
cin >> n >> m;
for (int i = 0; i < n; i++) {
int s, f, t;
cin >> s >> f >> t;
if (s == f) {
cout << t << "\n";
continue;
}
int curr = t % (2 * (m - 1));
bool up;
if (curr <= m... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9;
const long long LINF = (long long)1E18;
const long double PI = acos(-1.0);
const long double EPS = 1E-9;
template <typename T>
T gcd(T a, T b) {
return (b == 0) ? abs(a) : gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
return a... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.Scanner;
public class A117 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt(),m=in.nextInt();
for(int x = 0;x<n;x++) {
int a = in.nextInt(),b=in.nextInt(),t=in.nextInt();
int sum = t;
sum+=blah(t,a,m);
sum+=blah(sum,b,m);
if(a==b... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper pl... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author zulkan
*/
public class lift {
public static void main(String p[]) throws Exception {
te... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int calc(int s, int f, int t, int M) {
if (s == f) return 0;
int res = 0;
int m = t / (M - 1);
if (m % 2 == 0) {
int pos = t % (M - 1);
if (s >= pos) {
res += s - pos;
if (f >= s) {
res += f - s;
} else {
res += M - 1 - s + ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.Scanner;
public class A117 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int M = in.nextInt();
StringBuilder output = new StringBuilder();
for (int n=0; n<N; n++) {
int S = in.nextInt();
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import sys
def input():
return tuple(map(lambda x: int(x), sys.stdin.readline().split()))
n, m = input()
for i in range(n):
s, f, t = input()
if s == f:
print t
continue
s -= 1
f -= 1
if t % (m + m - 2) < m - 1:
if t % (m + m - 2) <= s:
t += s - t % (m + m -... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.PrintStream;
import java.util.Scanner;
public class elevator {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
PrintStream out = System.out;
int n = in.nextInt(), m = in.nextInt(),s,f,t,c;
for (int i ... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class st3 {
public static void main(String[] args) {
// TODO Auto-generate... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int solve(int s, int f, int t, int m) {
if (s == f) {
return t;
}
int begin;
int ind = t % (2 * (m - 1));
bool ishead;
if (ind <= m - 1) {
begin = ind + 1;
ishead = true;
} else {
begin = m - (ind - (m - 1));
ishead = false;
}
if (ishead) {
if (s >= beg... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | from sys import stdin
def ints():
return [int(s) for s in stdin.readline().split()]
n, m = ints()
for i in xrange(n):
s, f, t = ints()
round_trip = 2*m-2
if s == f:
rv = t
elif s < f: # Going up
full_rounds = t / round_trip
rv = full_rounds * round_trip
if t <... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long n, m, s, f, t;
int main() {
while (cin >> n >> m) {
for (long long i = 0; i < n; ++i) {
cin >> s >> f >> t;
s--;
f--;
long long r = (t / (2 * (m - 1))) * (2 * (m - 1));
long long ans;
if (f > s) {
if (t % (2 * (m -... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | def elevator():
people_floors = raw_input().split(' ')
people_floors = [ int(people_floors[0]), int(people_floors[1])]
results = list()
for i in xrange(0, people_floors[0]):
user_info = raw_input().split(' ')
user_info = ( int(user_info[0]), int(user_info[1]), int(user_info[2]))
... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class Main implements Runnable {
private void solve() throws Exception {
int n = nextInt(), m = nextInt();
int mod = 2 * (m - 1);
for (int i = 0; i < n; i++) {
... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
for (int test = 0; test < n; test++) {
int s, f, t;
cin >> s >> f >> t;
s--;
f--;
if (s == f) {
cout << t << "\n";
continue;
}
int newt = t % (2 * m - 2);
int btime, ctime;
if (s == ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.* ;
public class CodeForces_2011_Sep_23_A
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in) ;
int N = input.nextInt() ; long M = input.nextLong() ;
for (int i = 0; i < N ; i ++)
{
int S = input.nextInt() ; int F = inpu... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; ++i) {
int s, f, t;
scanf("%d%d%d", &s, &f, &t);
if (s == f) {
printf("%d\n", t);
continue;
}
int k = t % (m + m - 2), ans = 0, dr;
if (k <= m - 1) {
int at = k + 1;
if (s ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
int s, e, t;
scanf("%d%d%d", &s, &e, &t);
long long ans, tmp;
if (s == e) {
ans = t;
} else if (s < e) {
ans = s - 1;
tmp = ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
/**
* @param args
*/
static int up = 1, down = -1;
static long N, M;
static long person[][] = new long[100003][3];
public static void main(String[] args) {
// TODO Auto-generated me... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int M = 210000;
struct Node {
long long si, fi, ti;
} node[M];
int n, m;
long long get_num(long long x, long long y, long long z, int dir) {
long long sum = 0;
if (dir == 1) {
if (x <= y) {
sum += y - x;
if (y <= z) {
sum += z - y;
... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.util.StringTokenizer;
public class ProblemA implements Runnable {
private void solve() throws IOException {
int n = nextInt();
int m = nextInt();
f... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, m;
void output(int x) { printf("%d\n", x); }
int main() {
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++) {
int s, f, t;
scanf("%d%d%d", &s, &f, &t);
if (s == f)
printf("%d\n", t);
else if (s < f) {
int x = t / (m - 1);
int u... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;
int calc(int s, int f, int t, int m) {
if (s == f) return 0;
s--;
f--;
t %= (2 * (m - 1));
int tos;
int stof;
bool up = (t <... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | //package codeforces;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
im... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | a,b=map(int,input().split())
ans=2*(b-1)
ok=[0]*a
for i in range(a):
x,y,z=map(int,input().split())
if x==y:ok[i]=(z)
elif x<y:
if z<x:ok[i]=y-1
else:ok[i]=ans*((z+ans-x)//ans)+y-1
else:
k=b-1
x=b+1-x
y=b+1-y
z-=k
if z < x:ok[i]=k+y - 1
els... | PYTHON3 |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | def updiv(a,b):
if a%b==0:
return a/b
return a/b + 1
n,m = map(int,raw_input().split())
T = 2*m-2
for i in range(n):
s,f,t = map(int,raw_input().split())
s -= 1
f -= 1
if s==f:
print t
elif s<f:
k = updiv(t-s,T)
print k*T+f
else:
k = updiv(t - ((m... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
int x, y, z;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
scanf("%d%d%d", &x, &y, &z);
if (x == y) {
cout << z << endl;
continue;
}
long long int cnt = 0, l = x - 1, r = 1;
while (l < z) {
if (r == ... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
int main() {
int n, m;
while (scanf("%d%d", &n, &m) != EOF) {
int T = 2 * (m - 1);
for (int i = 1; i <= n; i++) {
int s, f, t;
scanf("%d%d%d", &s, &f, &t);
int ans;
if (s == f)
ans = t;
else if (s < f) {
ans = 0;
ans += t / T * T... | CPP |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | """
T = 0
S = 1
V = 2
state = (t, s, v)
"""
# const
T = 0
S = 1
V = 2
def getState(t):
#floor: 1,2,3....m,m-1,m-2,....2,|1
#time: 0,1,2... m-1
t1 = t % (2 * m - 2)
if t1 < m:
return (t, t1 + 1, 1)
else:
return (t, 2 * m - 1 - t1, -1)
def nextArrive(curTime, destFloor):
""" return the state of the next elev... | PYTHON |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Elevator implements Runnable {
private void solve() throws IOException {
int n = nextInt();
long m = ... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | import java.util.Scanner;
public class Elevator {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt() - 1;
int t;
int s;
int f;
int k;
for (int i = 0; i < n; i++){
s = in... | JAVA |
117_A. Elevator | And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is "How about checking out the elevator... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int seed = 131;
const int maxn = 1200;
int main() {
int n, m;
int p, s, f, t, x;
cin >> n >> m;
p = (m - 1) * 2;
while (n--) {
cin >> s >> f >> t;
if (s == f)
cout << t << endl;
else {
x = t / p * p + (s < f ? s - 1 : 2 * m - 1 - s);
... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.