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 |
|---|---|---|---|---|---|
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int t[100007], l[100007], r[100007];
int main() {
int n, m, s, f;
cin >> n >> m >> s >> f;
char ch = 'R';
int go = 1;
if (s > f) ch = 'L', go = -1;
for (int i = 0; i < m; ++i) cin >> t[i] >> l[i] >> r[i];
int curr = s, cu = 0, step = 1;
while (curr != f) {
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
import java.io.*;
public class solution
{
public static void main(String ar[])
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int s=sc.nextInt();
int f=sc.nextInt();
int arr[][]=new int[m][3];
for(int i=0;i... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 412345;
const int MAXINT = 2047483098;
const long long int MOD = 1e9 + 7;
const int MAX = 1e4;
const long double pi = 2 * acosl(0);
const long double EPS = 1e-10;
bool compo(pair<long long int, long long int> &a,
pair<long long int, long long int... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
;
long long t = 1;
while (t--) {
long long n, m, s, f;
cin >> n >> m >> s >> f;
string ans = "";
long long stp = 0;
bool chk = 1;
for (long long i = 0; i < m; i++) {
long long a, b... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60777216")
using namespace std;
const double EPS = 1e-9;
const int MOD = int(1e9) + 7;
const double PI = acos(-1.0);
template <class T>
void printV(vector<T> a) {
for (int _n = int((a).size()), i = 0; i < _n; ++i) cout << a[i] << " ";
cout << endl;
}
template... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
inline bool bad(int s, int l, int r) { return s <= r && s >= l; }
int main() {
int n, m, s, f, inc, pascr;
string str;
char lorr;
cin >> n >> m >> s >> f;
if (s > f) {
inc = -1;
lorr = 'L';
} else {
inc = 1;
lorr = 'R';
}
int t, l, r, q;
bo... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f, i, j, curr = 1, t, l, r;
cin >> n >> m >> s >> f;
for (i = 1; i <= m; i++) {
cin >> t >> l >> r;
if (s == f) break;
for (j = curr; j < t; j++) {
if (s < f)
cout << "R", s++;
else if (s > f)
cout << "... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f;
cin >> n >> m >> s >> f;
int ct = 0;
for (int i = 1; i <= m; i++) {
int t, l, r;
scanf("%d %d %d", &t, &l, &r);
while (ct < t - 1) {
ct++;
if (s < f) {
s++;
putchar('R');
} else if (s > f) {
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
struct stof {
int st, fi;
};
int main() {
int n, m, s, f, l, r;
cin >> n >> m >> s >> f;
map<long, struct stof> mp;
long t, i = 1;
while (m--) {
cin >> t >> l >> r;
mp[t].st = l, mp[t].fi = r;
}
map<long, struct stof>::iterator it;
it = mp.begin();... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
vector<char> ve;
struct node {
int t, l, r;
bool operator<(const node& cc) const { return cc.t > t; }
} A[MAXN];
int main() {
int n, m, s, f, t, l, r, i, cur, fl, cnt;
while (scanf("%d%d%d%d", &n, &m, &s, &f) != EOF) {
ve.clear();
cu... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
import java.io.*;
public class Main342B
{
static PrintWriter out=new PrintWriter(System.out);
public static void main(String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int s=sc.nextInt();
int f=sc.nextInt();
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tok;
final static double EPS = 1e-7;
final static long MOD = 1000000007;
static void solve() throws Exception {
int n = nextInt();
int m = nextInt();
i... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
long labs(long input) { return (input < 0) ? -input : input; }
int main() {
long n, m, s, f;
scanf("%ld %ld %ld %ld\n", &n, &m, &s, &f);
long holder(s), dir(0);
char move;
if (s < f) {
dir = 1;
move = 'R';
} else {
dir = -1;
move = 'L';
}
long currentTime(0);
b... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100001;
int l[maxn], r[maxn], t[maxn], n, m, b, e, f[maxn], pt, pp;
int tt, dis;
inline bool underspy(int s) { return ((s >= l[pt]) && (s <= r[pt])); }
int main() {
scanf("%d%d%d%d", &n, &m, &b, &e);
memset(f, -1, n);
for (int i = 0; i < m; i++) scanf... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f, p = 1, v = 1;
cin >> n >> m >> s >> f;
string g;
int t[m], a[m], b[m];
for (int i = 0; i < m; i++) {
cin >> t[i] >> a[i] >> b[i];
}
if (s < f) {
for (int i = 0; i < m; i++) {
if (((a[i] <= s + 1 && s + 1 <= b[i]) || (... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;
import java.util.concurrent.ArrayBlockingQueue;
public class ProblemB {
static final int INF = 100000000;
public stat... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, f, s, l[100011], r[100011], pos, del, ps = 1, timer = 0, l1;
long t[100011];
char sym;
int main() {
cin >> n >> m >> s >> f;
for (int i = 1; i <= m; i++) cin >> t[i] >> l[i] >> r[i];
t[m + 1] = -1;
pos = s;
if (s < f) {
sym = 'R';
del = 1;
l1... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f;
cin >> n >> m >> s >> f;
int w[m][3];
for (int i = 0; i < m; i++) cin >> w[i][0] >> w[i][1] >> w[i][2];
string ans = "";
char d = s > f ? 'L' : 'R';
int watch = w[0][0];
int wi = 0;
for (int i = 1; s != f; i++) {
if (watch ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | def checkKey(dict, key):
if key in dict:
return True
return False
# def helper(s):
# l=len(s)
# if (l==1):
# l=[]
# l.append(s)
# return l
# ch=s[0]
# recresult=helper(s[1:])
# myresult=[]
# myresult.append(ch)
# for st in recresult:
# myresult.append(st)
# ts=ch+st
# myresult.append(ts)
# ret... | PYTHON3 |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
#pragma GCC optimise("Ofast")
using namespace std;
const int mod = 1e+9 + 7;
long long binomialCoeff(long long n, long long k) {
long long res = 1;
if (n < k) return 0;
if (k > n - k) k = n - k;
for (long long i = 0; i < k; ++i) {
res *= (n - i);
res /= (i + 1);
}
return res... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f;
cin >> n >> m >> s >> f;
int t = 1;
char ch = 'R';
if (f < s) {
ch = 'L';
t = -1;
}
int track = 0;
string ans = "";
map<int, pair<int, int> > M;
for (int i = 0; i < m; i++) {
track++;
if (s == f) break;
in... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, s, f;
cin >> n >> m >> s >> f;
long long t[m + 5], l[m + 5], r[m + 5];
memset(t, 0, sizeof(t));
long long pos = 0;
for (int i = 1; i <= m; i++) cin >> t[i] >> l[i] >> r[i];
int current = s;
if (f > s) {
for (int i = 1; i <= m... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, s, f, t[200000], l[200000], r[200000];
int main() {
string ans = "";
int moment = 0, poss;
cin >> n >> m >> s >> f;
for (int i = 0; i < m; i++) {
cin >> t[i] >> l[i] >> r[i];
}
while (true) {
if (s == f) break;
moment++;
poss = lower_bo... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | n,m,s,f=map(int,raw_input().split())
now=s
spy=[]
for i in range(m):
x,l,r=map(int,raw_input().split())
spy.append([x,l,r])
spy.sort(key=lambda x:[x[0],x[1]])
if s>f:
move=-1
x="L"
if s<=f:
move=1
x="R"
cnt=0
tm=0
i=0
ans=''
while i<m:
tm+=1
if now==f:
#print('jo')
... | PYTHON |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f, t, l, r;
cin >> n >> m >> s >> f;
int cur = s, lastt = 1;
for (int i = 0; i < m; i++) {
cin >> t >> l >> r;
if (cur != f) {
for (int i = lastt; i < t; i++) {
if (s < f) {
cur++;
cout << "R";
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, s, f, t = 1, a = 0;
cin >> n >> m >> s >> f;
int arr[m][3];
for (int i = 0; i < m; i++) cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
while (s != f) {
if (s < f) {
if (t == arr[a][... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int t[100005], l[100005], r[100005], n, m, s, f, k;
int main() {
scanf("%d%d%d%d", &n, &m, &s, &f);
for (int i = 0; i < m; ++i) scanf("%d%d%d", &t[i], &l[i], &r[i]);
int p;
if (s < f)
p = 1;
else
p = -1;
for (int i = 0; i < m && s != f; ++i) {
int tt... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f, t, l, r, j = 1, get = 0;
char str[100005] = {'\0'};
scanf("%d %d %d %d", &n, &m, &s, &f);
if (s < f) {
for (int i = 0; i < m; i++) {
scanf("%d %d %d", &t, &l, &r);
if (get == 0) {
if (j != t) {
while (j ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, s, f, l[100014], r[100014], ti[100014], cp, cm, t, d;
string res;
int main(int argc, char* argv[]) {
cin >> n >> m >> s >> f;
for (int i = 0; i < (m); i++) cin >> ti[i] >> l[i] >> r[i];
cp = s;
cm = 0;
t = 1;
while (cp != f) {
++t;
d = (cp > f ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
import java.io.*;
public class Main342B
{
static PrintWriter out=new PrintWriter(System.out);
public static void main(String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int s=sc.nextInt();
int f=sc.nextInt();
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long INF = 1000000007;
long long INFLL = (long long)INF * (long long)INF;
long double EPS = 10e-9;
long double pi = 2 * acos(0.0);
long long n, m, s, f;
map<long long, long long> L, R;
void solve() {
cin >> n >> m >> s >> f;
for (long long i = 1; i <= m; i++) {
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
int main() {
int n, m, s, f;
scanf("%d%d%d%d", &n, &m, &s, &f);
int now = 0, pos = s, g;
g = s < f ? 1 : -1;
char go = s < f ? 'R' : 'L';
int arr = 0;
for (int i = 0; i < m; ++i) {
int t, l, r;
scanf("%d%d%d", &t, &l, &r);
for (int j = now; j < t - 1; ++j) {
pos ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
static const double PI = 3.14159265358979323846264338327950288419716939937511;
int main() {
long long n, m, s, f;
long long l, r, t;
cin >> n >> m >> s >> f;
char c = (s > f) ? 'L' : 'R';
long long cnt = 0, step;
for (long long i = 0; i < m; i++) {
cin >> t ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.*;
import java.util.*;
public class XeniaAndSpies {
public static void main(String[] args) throws IOException {
BufferedReader ff = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(ff.readLine());
int n = Integer.parseInt(st.nextT... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Problem63 {
public static void main(String[] args) {
// TODO Auto-generated method stub
out=new PrintWriter (new BufferedOutputStream(S... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
template <typename... T>
void rd(T&... args) {
((cin >> args), ...);
}
template <typename... T>
void wr(T&... args) {
((cout << args << " "), ...);
}
int gcd(int a, int b);
int lcm(int a, int b);
long long _sum(vector<int> a);
void Amritesh() {
int n, m, s, f;
rd(n,... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
const long long M = 1e9 + 7;
const long long N = 2e5 + 5;
using namespace std;
const double pi = 3.14159265358979323846264338327950;
const long long A = 1e9 + 1;
double esp = 1e-3;
vector<long long> square;
int main() {
ios::sync_with_stdio(0);
;
cin.tie(0);
;
long long n, m, s, f;
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
import java.io.*;
public class File {
public static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null ... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
int main() {
int n, m, s, f, d, ti = 1, t = 1, a, b, x = 0;
scanf("%d%d%d%d", &n, &m, &s, &f);
(s < f) ? d = 1 : d = -1;
scanf("%d%d%d", &t, &a, &b);
x++;
while (s != f) {
if (ti == t) {
if (d == 1) {
if (a <= s + 1 and s <= b)
printf("X");
else
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | /**
* Created by Omar on 2/22/2016.
*/
import java.util.*;
import java.io.*;
public class Xenia {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
//int n=Inte... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
import java.math.BigInteger;
public class Watermelon {
static int x;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int s=sc.nextInt();
int f=sc.nextInt();
int[][] arr=new int[m][... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, s, f;
string ans;
int main() {
cin >> n >> m >> s >> f;
int a;
if (s > f)
a = -1;
else
a = 1;
ans = "";
int t, l, r, last = 0;
bool done = false;
for (int i = 0; i < m; i++) {
cin >> t >> l >> r;
if (done) continue;
for (int j =... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m, s, f;
cin >> n >> m >> s >> f;
map<int, pair<int, int> > ma;
int h = -1;
for (int i = 0; i < m; i++) {
int a, b, c;
cin >> a >> b >> c;... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;
public class Spies {
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String[] ns = bf.readLine().split(" ");
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class XeniaAndSpies {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m ... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect ... | PYTHON3 |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long Min(long long a, long long b) {
if (a >= b)
return b;
else
return a;
}
long long Max(long long a, long long b) {
if (a >= b)
return a;
else
return b;
}
long long n, i, j;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
l... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const long double pi = 3.14159265358979323846;
const int inf = (int)1e9;
const int ss = (int)1e6 + 3;
const int base = inf;
bool pred(const pair<int, int>& i, const pair<int, int>& j) {
if (i.first == j.first) {
return i.seco... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, s, f, t[100000], l[100000], r[100000], step, now, a;
int main(int argc, char** argv) {
int i, j, k;
while (scanf(" %d %d %d %d", &n, &m, &s, &f) == 4) {
for (i = 0; i < m; i++) {
scanf(" %d %d %d", &t[i], &l[i], &r[i]);
}
now = s;
a = 0;
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.Scanner;
public class NotePasser {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
int current = scan.nextInt();
int goal = scan.nextInt();
StringBuilder sb = ... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.concurrent.LinkedBlockingDeque;
public class Main {
static class Par {
public int iz;
public int de;
public int ti;
p... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
public class B {
public static void main(String [] args){
final Scanner reader = new Scanner(System.in);
final int n = reader.nextInt();
final int m = reader.nextInt();
final int s = reader.nextInt();
final int f = reader.nextInt();
final StringBuilder sb = new StringBuilder();
int c... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, s, f, g, t[333333], l[333333], r[333333];
int main() {
scanf("%d %d %d %d", &n, &m, &s, &f);
for (int i = 0; i < m; ++i) scanf("%d %d %d", &t[i], &l[i], &r[i]);
if (s < f) {
for (int i = 0; i < m; ++i) {
if (i == 0)
g = t[i] - 1;
else... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.*;
import java.util.*;
public class second
{
static long fast_power(long a,long n,long m)
{
if(n==1)
{
return a%m;
}
if(n%2==1)
{
long power = fast_power(a,(n-1)/2,m)%m;
return ((a%m) * ((power*power)%m))%m;
}
long power = fast_power(a,n/2,m)%m;
return (power*power)%m;
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
struct node {
int t;
int x;
int y;
} tt[maxn];
int main() {
int n, m, s, f;
while (scanf("%d%d%d%d", &n, &m, &s, &f) != EOF) {
memset(tt, 0, sizeof tt);
for (int i = 0; i < m; i++) {
scanf("%d%d%d", &tt[i].t, &tt[i].x, &... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long int MAX = 1e9, max_int = 1e6;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n, m, s, f, t, i;
string ans = "";
cin >> n >> m >> s >> f;
map<long long, long long> l, r;
for (i = 0; i < m; i++) {
cin >> t... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f;
cin >> n >> m >> s >> f;
int ct = 1;
while (m--) {
int t, l, r;
cin >> t >> l >> r;
while (ct < t && s != f) {
if (s < f) {
cout << "R";
s++;
} else {
cout << "L";
s--;
}
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;
/**
*... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | 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.StringTokenizer;
public class CF {
public static class Stage {
int num;
int left;
int right;
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int watchList[100005][2], t[100005], pos, i, time, s, f, n, m;
char ch;
string result;
scanf("%d %d %d %d", &n, &m, &s, &f);
for (i = 0; i < m; i++)
scanf("%d %d %d", &t[i], &watchList[i][0], &watchList[i][1]);
time = 1, i = 0;
while (s != f) ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.IOException;
import java.util.InputMismatchException;
/**
* Created by jizhe on 2016/1/3.
*/
public class XeniaAndSpies {
public static class FasterScanner {
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public int read() {
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tokenizer=null;
public static void main(String[] args) throws IOException
{
new Main().execute();
}
void debug(Object...os)
{
System.out.p... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t, l, r, n, m, s, f;
cin >> n >> m >> s >> f;
int cnt = 1;
for (int i = 0; i < m; i++) {
cin >> t >> l >> r;
while (t > cnt && s != f) {
cnt++;
if (s < f)
s++, cout << ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
import java.io.*;
public class Main{
BufferedReader in;
StringTokenizer str = null;
PrintWriter out;
private String next() throws Exception{
if (str == null || !str.hasMoreElements())
str = new StringTokenizer(in.readLine());
return str.nextToken();
}
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
template <class T>
bool checkMin(T& a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool checkMax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
const int INF = 1e9;
const int MN = -1;
const int N = 100000;
int ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
int infinite = INT_MAX - 10;
template <typename T>
T power(T x, T y) {
T temp;
if (y == 0) return 1;
temp = power(x, y / 2);
if (y % 2 == 0)
return temp * temp;
else {
if (y > 0)
return x * temp * temp;
else
return (temp ... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
template <class T>
T gcd(T x, T y) {
while (T t = x % y) x = y, y = t;
return y;
}
const double eps = 1e-9;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.71... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | def checkKey(dict, key):
if key in dict:
return True
return False
# def helper(s):
# l=len(s)
# if (l==1):
# l=[]
# l.append(s)
# return l
# ch=s[0]
# recresult=helper(s[1:])
# myresult=[]
# myresult.append(ch)
# for st in recresult:
# myresult.append(st)
# ts=ch+st
# myresult.append(ts)
# ret... | PYTHON3 |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
public class Code {
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer=new PrintWriter(System.out);
int [] readInts()thr... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class cf342b {
static FastIO in = new FastIO(), out = in;
... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int f_max(int x, int y) { return x > y ? x : y; }
int f_min(int x, int y) { return x < y ? x : y; }
void f_swap(int &x, int &y) {
int t;
t = x, x = y, y = t;
}
int f_abs(int x) { return x > 0 ? x : -x; }
string l, r;
struct po {
int ti, l, r;
} a[100009];
int n, m;
bo... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long n, m, st, ed, tem, p, pt;
long long stp;
bool seeked;
string ch;
struct node {
long long t, l, r;
} a[200000];
bool cmp(node aa, node bb) { return aa.t < bb.t; }
long long i;
int main() {
cin >> n >> m >> st >> ed;
if (st > ed) {
ch = "L";
stp = -1;
... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
class step {
public:
int st, r, l;
} step[100005];
int main() {
int n, m, s, f;
int i, j, l, r, t;
while (cin >> n >> m >> s >> f) {
int t_now = 1;
for (i = 0; i < m; i++) cin >> step[i].st >> step[i].l >> step[i].r;
for (i = 0; i < m; i++) {
if (... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | n,m,s,f=list(map(int,input().split()));
d={};
for i in range(m):
t,l,r=list(map(int,input().split()));
d[t]=[l,r];
ans="";
for i in range(1,n+m):
if(s==f):
print(ans);
exit(0);
t=-1;
if(f<s):
t=s-1;
else:
t=s+1;
if i in d:
if((d[i][0]<=s and s<=d[i][1]... | PYTHON3 |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.math.BigInteger;
import java.util.Map;
import java.util.Scanner;
import java.util.S... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, s, f;
int a[100005][3];
int main() {
scanf("%d%d%d%d", &n, &m, &s, &f);
for (int i = 0; i < m; i++) {
scanf("%d%d%d", &a[i][0], &a[i][1], &a[i][2]);
}
int k = 0;
int last = 1;
if (s < f) {
for (int i = 0; i < m; i++) {
if (a[i][0] > last)... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.util.*;
import java.io.*;
import java.math.*;
import static java.lang.Math.*;
public class Solution implements Runnable {
public void solve() throws Exception {
int n = sc.nextInt();
int m = sc.nextInt();
int s = sc.nextInt() - 1;
int f = sc.nextInt() - 1;
int l [] = new int [m];
int r [... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long f = 0, j, q = 1, i, n;
while (q--) {
long long y, k = 1, x, M, s;
cin >> n >> M >> s >> f;
map<int, pair<int, int> > m;
for (i = 0; i < M; i++) {
long long... | CPP |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class Codeforces {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader... | JAVA |
342_B. Xenia and Spies | Xenia the vigorous detective faced n (n β₯ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the ... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, f, x = 0, t = 1, i;
vector<pair<int, pair<int, int> > > v;
scanf("%d %d %d %d", &n, &m, &s, &f);
for (i = 0; i < m; i++) {
int x, y, z;
scanf("%d %d %d", &x, &y, &z);
v.push_back(make_pair(x, make_pair(y, z)));
}
while (1) {... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, d;
int dp[1130000];
int main() {
scanf("%d %d", &n, &d);
int s = 0;
dp[0] = 1;
for (int i = 0; i < n; i++) {
int ci;
scanf("%d", &ci);
s += ci;
for (int v = s; v >= ci; v--) {
dp[v] |= dp[v - ci];
}
}
int lla = -1e9;
int la = 0... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXINT = 1111 * 1111 * 1111;
const long long MAXLINT = MAXINT * 1ll * MAXINT;
const long double EPS = 1e-10;
int n, k;
vector<int> sum;
bool exist[500005];
int main() {
scanf("%d%d", &n, &k);
sum.push_back(0);
for (int i = 0; i < n; i++) {
int x;
sca... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
int f[maxn], tmp, ans, sum, n, d, r, x;
int main() {
scanf("%d %d", &n, &d);
memset(f, 0, sizeof(f));
f[0] = 1;
for (int i = 0; i < n; i++) {
scanf("%d", &x);
for (int j = maxn - 1 - x; j >= 0; j--) f[j + x] |= f[j];
}
r = 1;
s... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 55;
const int D = 10100;
char dp[N * D];
int n, d;
int A[N];
void do_package() {
memset(dp, 0, sizeof(dp));
dp[0] = 1;
for (int i = 0; i < n; i++) {
for (int j = N * D - 1; j >= 0; j--) {
if (dp[j] && j + A[i] < N * D) {
dp[j + A[i]] = ... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const int MOD = 1e9 + 7;
int dp[maxn];
int c[52];
void calc(int n, int maxW) {
for (int i = 1; i <= n; ++i) {
for (int w = maxW; w >= c[i - 1]; --w)
dp[w] = max(dp[w - c[i - 1]] + c[i - 1], dp[w]);
}
}
int main() {
int n, d;
scan... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | import java.util.*;
import java.io.*;
public class Main{
BufferedReader in;
StringTokenizer str = null;
PrintWriter out;
private String next() throws Exception{
if (str == null || !str.hasMoreElements())
str = new StringTokenizer(in.readLine());
return str.nextToken();
}
... | JAVA |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 4e18;
const int inf = 2e9;
const int N = 5e5 + 5;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<int> pos;
bool ada[N];
int ans, day;
int main(void) {
... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class D {
static byte[][] dp;
static int[] ar;
public static void solve(int idx, int sum) {
// System.out.println(idx+" "+sum);
if (dp[idx][sum] != 0)
return;
dp[idx][sum] ... | JAVA |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
const int maxn = 2000000;
int n, m;
long long a[maxn], sum[maxn], cur, d, ans, can[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> d;
for (int i = 1; i <= n; i+... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mx = 600000;
int n, m;
int ans[mx + 5];
bool dp[mx + 5];
multiset<int> q;
int x;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
dp[0] = true;
for (int i = 1; i <= n; ++i) {
cin >> x;
for (int j = mx; j >=... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
bool dp[1000010];
int main() {
int n, d, c;
cin >> n >> d;
dp[0] = 1;
for (int i = 1; i <= n; i++) {
cin >> c;
for (int j = 500000; j >= c; j--) dp[j] |= dp[j - c];
}
int day = 0, now = 0;
bool ok = 1;
while (ok) {
for (int i = now + d; i > now; ... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 29;
const double dinf = 1e30;
const long long linf = 1LL << 55;
const int N = 55 * 10000;
int n, d;
bool dp[N];
int main() {
while (cin >> n >> d) {
memset(dp, false, sizeof(dp));
dp[0] = true;
for (int i = 0, x; i < n; i++) {
cin >>... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
long long ret = 1;
long long b = a;
while (n) {
if (n & 1) ret = (ret * b) % mod;
b = (b * b) % mod;
n >>= 1;
}
return (long long)ret;
}
using namespace std;
bool a[6000001];
int x[51];
int main() {
int n, d, i, j... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
const int inf = 2000000000;
const long long linf = 50000000... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
inline void setmin(int &x, int y) {
if (y < x) x = y;
}
inline void setmax(int &x, int y) {
if (y > x) x = y;
}
inline void setmin(long long &x, long long y) {
if (y < x) x = y;
}
inline void setmax(long long &x, long long y) {
if (y > x) x = y;
}
const int N = 1000... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int N = 10010;
int n, d;
bool f[N * 55];
int c[55];
int main() {
while (~scanf("%d%d", &n, &d)) {
int sum = 0;
for (int i = 0; i < n; ++i) {
scanf("%d", &c[i]);
su... | CPP |
365_D. Free Market | John Doe has recently found a "Free Market" in his city β that is the place where you can exchange some of your possessions for other things for free.
John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that eac... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
int dp[55 * maxn];
int main() {
int n, d, x, cnt = 0, w = 0, i, j;
cin >> n >> d;
memset(dp, 0, sizeof(dp));
dp[0] = 1;
long long sum = 0;
for (i = 1; i <= n; i++) {
cin >> x;
sum += x;
for (j = sum; j >= x; j--)
if (... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.