source_code
stringlengths
26
62k
lang_cluster
stringclasses
11 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
difficulty
int32
-1
3.5k
exec_outcome
stringclasses
1 value
#include <iostream> #include <cmath> #include <unordered_map> int main() { int n, m; std::cin >> n; std::unordered_map<int, int> freq; for (int i = 0; i < n; i++) { int l; std::cin >> l; freq[l]++; } std::cin >> m; int audio[m], sub[m]; for (int i = 0; i < m;...
C++
74ddbcf74988940265985ec8c36bb299
c0bdc50b36242dd5bc89da30adc2ae65
1,300
PASSED
#include<bits/stdc++.h> typedef long long ll; using namespace std; ll n,tot,m,num; ll a[600005],b[200005],cnt[200005],x[200005],y[200005]; void discrete() { sort(a+1,a+1+num); tot=unique(a+1,a+num+1)-(a+1); } ll query(ll x) { return lower_bound(a+1,a+tot,x)-a; } int main() { cin>>n; for(int i=1;i<=n...
C++
74ddbcf74988940265985ec8c36bb299
4bd8c2248577b2dfe64b75c44accd9d5
1,300
PASSED
#include <bits/stdc++.h> #define INF 0x3f3f3f3f #define EXP 1e-8 #define MEM(a,x) memset(a,x,sizeof(a)) #define gcd(a,b) __gcd(a,b) #define ll long long #define LL long long #define _for(i,a,b) for(int i = (a); i < (b); i++) #define _fore(i,a,b) for(int i = (a); i <= (b); i++) const double PI = acos(-1.0); using name...
C++
74ddbcf74988940265985ec8c36bb299
60a1078c83b169f45fe6ee376f589f76
1,300
PASSED
#include<iostream> #include<vector> #include<unordered_map> #include<iterator> using namespace std; int main(){ int n,m,x,sub=-1,mx=-1,ans; unordered_map< int, int > num; unordered_map< int, int >::iterator itr; cin>>n; for( int i = 0; i < n; i++ ){ cin>>x; num[x]++; } cin>>m; vector< int > lang(m);...
C++
74ddbcf74988940265985ec8c36bb299
8ef7cc6062379cb063a392d9798b52ca
1,300
PASSED
#include<bits/stdc++.h> using namespace std; const long long mod = 1e9+7; const long long mx = 1e5+5; #define inf INT_MAX #define zero INT_MIN #define PI acos(-1.0) // 3.1415926535897932 #define Case(J) printf("Case %lld: %lld\n",++count,J); ///print case #define max3(a,b,c) max(a,max(b,c)) #define min...
C++
74ddbcf74988940265985ec8c36bb299
47deccd3644e46ff33ceca15fc009a83
1,300
PASSED
#include<bits/stdc++.h> using namespace std; #define int long long #define uset unordered_set #define umap unordered_map #define db(x) cout << #x << " == " << x << ";\n" #define a(x) x.begin(),x.end() #define input(v,n) for(int i=0;i<n;i++)cin>>v[i] typedef vector<int> vi; typedef pair<int,int> pi; const int inf = 1e5...
C++
74ddbcf74988940265985ec8c36bb299
7ad48e342a2cac411a4258107cee202c
1,300
PASSED
#include<bits/stdc++.h> #include<stdint.h> using namespace std; #define IOS {cin.tie(0);ios_base::sync_with_stdio(false);} #define N 300005 #define int int64_t set<int> sc[128]; string s; int32_t main(){ IOS; int n,k; cin >> n >> k; cin >> s; for(int i=0;i<k;i++){ sc[s[i]].insert(i); } while(n--){ cin >> s...
C++
a587188db6f0c17927923a158fdca1be
0782c485722f00d9edab123fd5159bef
1,800
PASSED
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef double D; typedef long double LD; typedef long long LL; typedef pair<int,int> PII; typedef pair<LL,LL> PLL; typedef tree<int, null_type, less<int>, rb_tree_tag,...
C++
a587188db6f0c17927923a158fdca1be
9c73692362724c429b48c2660f6005da
1,800
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; set<int> s[26], ss[26]; int main (int argc, char *argv[]) { cin >> n >> k; string str; cin >> str; for(int i = 0; str[i]; ++i) { s[(str[i] - 'a')].insert(i); ss[(str[i] - 'a')].insert(-i); } while(n--) { cin >> str; ll ans =...
C++
a587188db6f0c17927923a158fdca1be
ce7ca65835b9517f1fe9af01883a5a97
1,800
PASSED
#include <bits/stdc++.h> #define sd(x) scanf("%d",&x) #define sd2(x,y) scanf("%d%d",&x,&y) #define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z) #define pf(x) printf("%d\n",x) #define pf2(x,y) printf("%d %d\n",x,y) #define pf3(x,y,z) printf("%d %d %d\n",x,y,z) #define tr(x) cout<<x<<endl #define tr2(x,y) cout<<x<<" "<<y<<endl #d...
C++
a587188db6f0c17927923a158fdca1be
8eb8cb514200fa6e48858e7bc18dd3c1
1,800
PASSED
#include <bits/stdc++.h> #define pb(x) push_back(x) using namespace std; typedef long long int lli; int n,k,i; lli c; string s; int main(){ std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>k; cin>>s; vector<lli> arr[27]; for(i=0;i<k;i++) arr[s[i]-'a'].pb(i); ...
C++
a587188db6f0c17927923a158fdca1be
833d29a9127afea281efb915a03eae3b
1,800
PASSED
#include <bits/stdc++.h> #define sd(x) scanf("%d",&x) #define sd2(x,y) scanf("%d%d",&x,&y) #define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z) #define pf(x) printf("%d\n",x) #define pf2(x,y) printf("%d %d\n",x,y) #define pf3(x,y,z) printf("%d %d %d\n",x,y,z) #define tr(x) cout<<x<<endl #define tr2(x,y) cout<<x<<" "<<y<<endl #d...
C++
a587188db6f0c17927923a158fdca1be
f1be9ff53bf6c0974f01353ad91e6fdb
1,800
PASSED
#include <bits/stdc++.h> #define sd(x) scanf("%d",&x) #define sd2(x,y) scanf("%d%d",&x,&y) #define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z) #define pf(x) printf("%d\n",x) #define pf2(x,y) printf("%d %d\n",x,y) #define pf3(x,y,z) printf("%d %d %d\n",x,y,z) #define tr(x) cout<<x<<endl #define tr2(x,y) cout<<x<<" "<<y<<endl #d...
C++
a587188db6f0c17927923a158fdca1be
a961eee7ecf76d044669da3f6b600af3
1,800
PASSED
#include<bits/stdc++.h> using namespace std; vector<int> id[256]; int n, k; string s; int main() { cin >> n >> k >> s; for (int i = 0; i < k; i++) { id[s[i]].push_back(i); } for (int i = 0; i < n; i++) { cin >> s; long long f = 0; for (int j = 0; j < s.size(); j++) { int Min = 1e9; ...
C++
a587188db6f0c17927923a158fdca1be
bc9f4cccd134572c3fbd353132ed509e
1,800
PASSED
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include <cmath> #define LL long long #define pb push_back #define mp make_pair #define Inf (1<<29) #define rep(i,x) for(LL (i)=1;(i)<=(x);(i)++) #define repp(i,x,y) for(LL (i)=(x);(i)<=(y);(i)++) #define forn(i,x) for(LL (i...
C++
a587188db6f0c17927923a158fdca1be
18a9c7282944b5d8b968f87b8206bd4e
1,800
PASSED
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; #define int long long #define double long double #define _ << ' ' << #define For(i,z) for(int i=0;i<(z);i++) #define sqr(a) ((a)*(a)) #define pii pair<int, int> #define pdd pair<double, double> #define f first #define s second template<typena...
C++
a587188db6f0c17927923a158fdca1be
d2db7b980c207e9e7a7e94a9f7ad2dfc
1,800
PASSED
import java.util.*; public class MakeItOne { static int LIM = 300001; public static void main (String [] arg) throws Throwable { int [] sieveprimes = new int [LIM]; int [] factorization = new int [LIM+1]; int [] prev = new int [LIM+1]; int [] primecount = new int [LIM+1]; boolean [] composite = new boolean ...
Java
3baa00206d3bf03ce02a414747e2a633
46a9826ce55d05d2fadd493e6122f742
2,500
PASSED
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; imp...
Java
3baa00206d3bf03ce02a414747e2a633
554ea0aeea708640121ce5ab1b940756
2,500
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; /** * @author Don Li */ public class MakeItOne2 { int N = (int) 3e5 + 10; int SQRT = (int) (Math.sqrt(N) + .5); int[] fp = new int[N]; int[][] ...
Java
3baa00206d3bf03ce02a414747e2a633
64800aedf1c54849798f93c95e9167db
2,500
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class MakeItOne { int N = (int) 3e5 + 10; int MOD = (int) 1e9 + 7; int[] fac = new int[N], ifac = new int[N],...
Java
3baa00206d3bf03ce02a414747e2a633
cedaa7838bf885f2abfbafd0f62b9f05
2,500
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Java
3baa00206d3bf03ce02a414747e2a633
8f9022ffabb1cf9600c05b1660d0e6f6
2,500
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution ...
Java
3baa00206d3bf03ce02a414747e2a633
963e02cfe25f460376382aec2da9bbb6
2,500
PASSED
import java.io.*; import java.util.*; public class C { FastReader scn; PrintWriter out; String INPUT = ""; void solve() { int n = scn.nextInt(); int[] arr = new int[300001]; for(int i = 0; i < n; i++) { int x = scn.nextInt(); arr[x] = 1; } int[] a = new int[n]; int pos = 0; for(int i = 1; i < ...
Java
3baa00206d3bf03ce02a414747e2a633
343f4af2d59ff5555905ae01378232ae
2,500
PASSED
import java.io.*; import java.util.*; public class C { FastReader scn; PrintWriter out; String INPUT = ""; void solve() { int n = scn.nextInt(); int[] arr = new int[300001]; for(int i = 0; i < n; i++) { int x = scn.nextInt(); arr[x] = 1; } int[] a = new int[n]; int pos = 0; for(int i = 1; i < ...
Java
3baa00206d3bf03ce02a414747e2a633
a55e7dc3ca20e9e27eddfb58dd7926de
2,500
PASSED
import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.System.exit; import static java.util.Arrays.fill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; im...
Java
3baa00206d3bf03ce02a414747e2a633
809e22f43d7442dc9a3b263b01590c06
2,500
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /**...
Java
3baa00206d3bf03ce02a414747e2a633
6273b8cd600e83dce2c543cf3a091a99
2,500
PASSED
#include<iostream> #include<cstring> #include<cstdio> #include<set> #include<vector> #include<algorithm> using namespace std; #define LL long long #define fgx cerr<<"--------------"<<endl; #define dgx cerr<<"=============="<<endl; inline int read(){ int x=0,f=1;char c=getchar(); for(;!isdigit(c);c=getchar()) if(c=...
C++
01111a3c76767d3d136ec54df3d59100
0a2edf399c8a0b595f92176255f6161a
3,300
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define mp make_pair #define PI pair<ll,ll> #define poly vector<ll> #define mem(a) memset((a),0,sizeof(a)) #define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++) #define Rep(i,r,l) for(int i=(int)(...
C++
01111a3c76767d3d136ec54df3d59100
621a49d1bb874d3ad24c2e765de24912
3,300
PASSED
#include <algorithm> #include <cassert> #include <cstdio> #include <set> int n,ans[500001],t[500001],i,type[500001],fin; std::pair<int,int>num[500001]; int v[3][2][4000001]; std::set<int>rest; int min(int a,int b){return a<b?a:b;} int max(int a,int b){return a>b?a:b;} void pushup(int x){ for(register int i=0,j;i<3;+...
C++
01111a3c76767d3d136ec54df3d59100
5156803bf584a185967775689e8361e4
3,300
PASSED
#include<bits/stdc++.h> #define llong long long #define mkpr make_pair #define x first #define y second #define iter iterator #define riter reversed_iterator #define y1 Lorem_ipsum_dolor #define pii pair<int,int> using namespace std; inline int read() { int x = 0,f = 1; char ch = getchar(); for(;!isdigit(ch);ch=get...
C++
01111a3c76767d3d136ec54df3d59100
0cbf5d64442edb1a02ca75af0c496d0d
3,300
PASSED
#include<bits/stdc++.h> #define maxn 1000010 #define inf 2000000000 using namespace std; template<typename T> inline void read(T &x) { x=0;char c=getchar();bool flag=false; while(!isdigit(c)){if(c=='-')flag=true;c=getchar();} while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();} if(flag)x=-x; } int n,a...
C++
01111a3c76767d3d136ec54df3d59100
927743afe7d3c8baf0674af331cdc81f
3,300
PASSED
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> const int N = 5e5 + 55, LN = 20; template <typename comp> struct ST { inline static int lg2(int n) { return 31 - __builtin_clz(n); } inline static int _(int x, int y) { return comp()(x, y) ? x : y; } int st[LN][N]; void init(int *a, i...
C++
01111a3c76767d3d136ec54df3d59100
1b65b9c3dc18f3c7f8a5098ccf2699b9
3,300
PASSED
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> const int N = 5e5 + 55, LN = 20; template <typename comp> struct ST { inline static int lg2(int n) { return 31 - __builtin_clz(n); } inline static int _(int x, int y) { return comp()(x, y) ? x : y; } int st[LN][N]; void init(int *a, i...
C++
01111a3c76767d3d136ec54df3d59100
9d446a9df859dc5f1311c732fedb2c11
3,300
PASSED
#include<bits/stdc++.h> using namespace std; const int N=5e5+100; int n,a[N],id[N],mx,ans[N],sta[N]; set<int> equ,ed0; struct dsu { int fa[N]; void init() { for(int i=1;i<=n;++i) fa[i]=i; } int getfa(int x) { return x==fa[x]?x:fa[x]=getfa(fa[x]); } void merge(int x,int y) { fa[getfa(x)]=getfa(y); } } L,R; void mdf...
C++
01111a3c76767d3d136ec54df3d59100
265584414f2e2103110e6092ea14c97e
3,300
PASSED
#include<bits/stdc++.h> #define ld long double #define pint pair<int,int> #define mk(x,y) make_pair(x,y) #define fir first #define sec second #define Rep(x,y,z) for(int x=y;x<=z;++x) #define Red(x,y,z) for(int x=y;x>=z;--x) using namespace std; const int MAXN=5e5+5; inline int read(){ int p=1,x=0;char ch=getchar(); w...
C++
01111a3c76767d3d136ec54df3d59100
6d697bbc837b36c7e4dc4c7c6807c00a
3,300
PASSED
#include<bits/stdc++.h> #define ld long double #define pint pair<int,int> #define mk(x,y) make_pair(x,y) #define fir first #define sec second #define Rep(x,y,z) for(int x=y;x<=z;++x) #define Red(x,y,z) for(int x=y;x>=z;--x) using namespace std; const int MAXN=5e5+5; inline int read(){ int p=1,x=0;char ch=getchar(); w...
C++
01111a3c76767d3d136ec54df3d59100
444d97f3ea5368ad56501da9df6490b5
3,300
PASSED
import java.util.*; import java.io.*; public class Main { // static LinkedList<Integer> adj[]; // static boolean cats[]; // static boolean visited[]; public static void main(String[] args) { FastScanner sc = new FastScanner(); long n = sc.nextLong(); long m = sc.nextLong(); ...
Java
959709bfe7b26a4b9f2e7430350650a9
f30c1a3d211a17086b7a46cf3d5317bf
1,700
PASSED
import java.util.*; import java.io.*; public class Main { // static LinkedList<Integer> adj[]; // static boolean cats[]; // static boolean visited[]; public static void main(String[] args) { FastScanner sc = new FastScanner(); long n = sc.nextLong(); long m = sc.nextLong(); ...
Java
959709bfe7b26a4b9f2e7430350650a9
5ec6f2e851fa7024a99b96f7332e40c7
1,700
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class system{ public static void main (String[]args) throws IOException{ PrintWriter out=new PrintWriter(System.out); Scanne...
Java
959709bfe7b26a4b9f2e7430350650a9
51297ece827c06da9285b0194881bbde
1,700
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.Iterator; import java.util.TreeSet...
Java
959709bfe7b26a4b9f2e7430350650a9
277f550027c2928392c0a184fc281592
1,700
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays...
Java
959709bfe7b26a4b9f2e7430350650a9
525854291f3ea1033fdb300639306790
1,700
PASSED
import java.io.*; import java.util.*; public class CF22C { static int swap(int x, int a, int b) { if (x == a) return b; if (x == b) return a; return x; } public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); i...
Java
959709bfe7b26a4b9f2e7430350650a9
e5018af40dddaae0ab9173ade504a557
1,700
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Stack; import java.util.StringTokenizer; public class Main { private static MyScanner sc; ...
Java
959709bfe7b26a4b9f2e7430350650a9
4d82e7f7bdc3c1bd24dab7a960a40dcf
1,700
PASSED
import java.io.*; import java.util.*; public class Main { static PrintWriter out; static InputReader in; static InputStream inputs; public static void main(String[] args) { inputs = System.in; in = new InputReader(inputs); out = new PrintWriter(new BufferedOutputStrea...
Java
959709bfe7b26a4b9f2e7430350650a9
74464dab8fba4572492c06a6cb6b31ba
1,700
PASSED
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.Random; import java.util.StringTokeniz...
Java
959709bfe7b26a4b9f2e7430350650a9
12f48b89f1b41ceacdc0f4a5a235ecc2
1,700
PASSED
import java.io.*; import java.util.*; public class A { public static void main(String[] args)throws Throwable { MyScanner sc=new MyScanner(); PrintWriter pw=new PrintWriter(System.out); int n=sc.nextInt(); int m=sc.nextInt(); int v=sc.nextInt()-1; long max=1+(1L*(n-2)*(n-1))/2; if(max<m || m<n-1){ ...
Java
959709bfe7b26a4b9f2e7430350650a9
68ba5c40bf87911eb7f3eb9d58a5c7b4
1,700
PASSED
#include <bits/stdc++.h> using namespace std; const int N=2010; int d[N][N], vis[N][N] ; int n, m, ex, ey, k, x, y ; bool check(int x, int y) { int l = max(x - d[x][y], 1), r = min(x + d[x][y], n) ; for (int i = l; i <= r; i++) { int t = d[x][y] - abs(i - x) ; if (y - t > 0 && !vis[i][y - t]) {...
C++
f1dab2869df5bdffb522b313db684e1f
d4520bb944f706cd9a047efc67932f1b
2,400
PASSED
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) int n,m,k,x,y,a,b,d[2010][2010],v[2010][2010]; bool solve(int x,int y,int k) { int l=max(1,x-k),r=min(x+k,n),t; rep(i,l,r+1) { t=k-abs(i-x); if (y-t>0&&!v[i][y-t]) return a=i,b=y-t,1; if (y+t<=m&&!v[i][y+t]) return a=i,b=y+t,...
C++
f1dab2869df5bdffb522b313db684e1f
a2f0d8f91628ce77ee50993d16ca4096
2,400
PASSED
#include <bits/stdc++.h> using namespace std; int c[2010][2010],c1[2010][2010],n,m,k,x,y,a,b; bool check(int x,int y, int k){ int l=max(1,x-k),r=min(x+k,n),t; for(int i=l; i<r+1; i++){ t=k-abs(i-x); if(y-t>0 && !c[i][y-t]) return a=i,b=y-t,1; if(y+t<=m && !c[i][y+t]) ...
C++
f1dab2869df5bdffb522b313db684e1f
df42e38fab933e390ab8b7db8bd056ba
2,400
PASSED
#include <bits/stdc++.h> using namespace std; int c1[2010][2010],c2[2010][2010],n,m,k,x,y,a,b; bool Problem(int x,int y, int k) { int l=max(1,x-k),r=min(x+k,n),t,i; for(i=l;i<r+1;i++){ t=k-abs(i-x); if(y-t>0 && !c1[i][y-t]) return a=i,b=y-t,1; if(y+t<=m && !c1[i][y+t]) ...
C++
f1dab2869df5bdffb522b313db684e1f
3cc4be4840bc6663a9826b162ab6e4a1
2,400
PASSED
#include <bits/stdc++.h> using namespace std; int c1[2010][2010],c2[2010][2010],n,m,k,x,y,a,b; bool check(int x,int y, int k){ int l=max(1,x-k),r=min(x+k,n),t,i; for(i=l;i<r+1;i++){ t=k-abs(i-x); if(y-t>0 && !c1[i][y-t]) return a=i,b=y-t,1; if(y+t<=m && !c1[i][y+t]) ...
C++
f1dab2869df5bdffb522b313db684e1f
2a19d860141d9aa1fb62a36e4e4b927c
2,400
PASSED
#include <algorithm> #include <cstdio> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) int n,m,k,x,y,a,b,d[2010][2010],v[2010][2010]; bool solve(int x,int y,int k) { int l=max(1,x-k),r=min(x+k,n),t; rep(i,l,r+1) { t=k-abs(i-x); if (y-t>0&&!v[i][y-t]) return a=i,b=y-t,1; if (y+t<=m&&!v[i][y+t]) ret...
C++
f1dab2869df5bdffb522b313db684e1f
8f7c0222f813126065d388de977242b7
2,400
PASSED
#include <bits/stdc++.h> #include <ext/hash_map> #include <ext/numeric> using namespace std; using namespace __gnu_cxx; typedef long long ll; typedef unsigned long long ull; void fastInOut(); const int OO = 1e9; int n, m; set<pair<int, int> > rng[2000]; struct Node { int dis, fx, fy, x, y; void update(int...
C++
f1dab2869df5bdffb522b313db684e1f
312940beb6a3299da3a59652d5215283
2,400
PASSED
#include <bits/stdc++.h> #include <ext/hash_map> #include <ext/numeric> using namespace std; using namespace __gnu_cxx; typedef long long ll; typedef unsigned long long ull; void fastInOut(); const int OO = 1e9; int n, m, sx, sy; set<pair<int, int> > rng[2000]; void init() { for (int i = 0; i < n; ++i) ...
C++
f1dab2869df5bdffb522b313db684e1f
3f7c493252171fc8890b4f0bc4d684e3
2,400
PASSED
// Gotta Do the 100th one. I'll come back with required knowledge! #include<bits/stdc++.h> using namespace std; int dis(int x1,int y1,int x2,int y2) { return abs(x1-x2)+abs(y1-y2); } int sete[2005][2005]; struct near { int dis; int last; }sit[2005][2005]; struct guanzhong { int x; int y; }gz[100005]...
C++
f1dab2869df5bdffb522b313db684e1f
18747ac0661d27673feb96697d8b91c3
2,400
PASSED
#include<cstdio> #include<cstring> #include<algorithm> #define maxn 2005 #define inf 0x7fffffff using namespace std; bool flag = false; int n,m,K; int up[maxn][maxn],down[maxn][maxn]; int Find(int p[],int x){ return p[x] != x?p[x]=Find(p,p[x]):x; } void check(int x,int y,int i,int &g,i...
C++
f1dab2869df5bdffb522b313db684e1f
ef515545401bf790ea4e4d816e2f9906
2,400
PASSED
n,m = map(int,input().split()) a = list(map(int,input().split())) unique = set() l = [] for i in range(m): l.append(int(input())) l = list(enumerate(l)) l = sorted(l,key=lambda x: x[1],reverse=True) final=[] for i in range(len(l)): if i==0: unique.update(a[l[i][1]-1:]) else: unique.update(a[...
Python
1e156dfc65ef88f19ca1833f75192259
c04abf5497c3dd852b03ff5ed4651e6c
1,100
PASSED
n,m = map(int,input().split()) a = list(map(int,input().split())) unique = set() l = [] for i in range(m): l.append(int(input())) l = list(enumerate(l)) l = sorted(l,key=lambda x: x[1],reverse=True) final=[] for i in range(len(l)): posi=l[i][1]-1 if i==0: unique.update(a[posi:]) else: pr...
Python
1e156dfc65ef88f19ca1833f75192259
cdbdf519ce44c5bbcdc14c59116a6780
1,100
PASSED
#https://codeforces.com/problemset/problem/368/B n, m = map(int, input().split()) a = list(map(int, input().split())) a.reverse() aHash = {a[0]:1} amounts = [1] for i in range(1,n): if a[i] in aHash: amounts.append(amounts[i-1]) else: aHash[a[i]] = 1 amounts.append(amounts[i-1]+1) for i ...
Python
1e156dfc65ef88f19ca1833f75192259
e55e68ad42e4a7debc5ab207623c69bb
1,100
PASSED
#https://codeforces.com/problemset/problem/368/B n, m = map(int, input().split()) a = list(map(int, input().split())) a.reverse() aHash = {a[0]:1} amounts = [1] for i in range(1,n): if a[i] in aHash: amounts.append(amounts[i-1]) else: aHash[a[i]] = 1 amounts.append(amounts[i-1]+1) amount...
Python
1e156dfc65ef88f19ca1833f75192259
56deb9898365b1821fde6fde54b4649f
1,100
PASSED
# You lost the game. n, m = map(int, input().split()) A = list(map(int, input().split())) L = [int(input()) for _ in range(m)] T = [0 for _ in range(n)] T[n-1] = 1 R = [0 for _ in range(10**5+1)] R[A[n-1]] = 1 for i in range(n-2,-1,-1): if R[A[i]]: T[i] = T[i+1] else: T[i] = T[i+1]+1 R[A...
Python
1e156dfc65ef88f19ca1833f75192259
d111e693d80cb4dcb562c5180a92d7fb
1,100
PASSED
def solve(n, m, a, l): a = a[::-1] l = l[::-1] l = list(map(lambda x: n - x, l)) ar = [False] * 100001 lar = [] c = 0 out = '' for i in range(n): if ar[a[i]] == False: c += 1 ar[a[i]] = True lar.append(c) for e in l[::-1]: out += str...
Python
1e156dfc65ef88f19ca1833f75192259
4d3a2abd201d15ebb6e3189525cdddbd
1,100
PASSED
n,m =map(int,input().split());l=list(input().split()) a=set({}) for i in range(n): a.add(l[n-i-1]) l[n-i-1]=len(a) for j in range(m): print(l[int(input())-1])
Python
1e156dfc65ef88f19ca1833f75192259
165ddbe57a8b74851cdfa412e12811a4
1,100
PASSED
n,m = map(int, input().split()) a = input().split() visited = set() for i in range(n -1,-1,-1): visited.add(a[i]) a[i] = str(len(visited)) print("\n".join(a[int(input()) - 1] for x in range(m)))
Python
1e156dfc65ef88f19ca1833f75192259
69d9219bf27c2d807e6eed239b7771d4
1,100
PASSED
def solve(): from collections import Counter n,m=map(int,input().strip().split()) l=list(map(int,input().strip().split())) c=Counter(l) lc=list(c) lcl=len(lc) #print(c) r=[lcl]*n #print(r) for i in range(n): #print(c) c[l[i]]-=1 if c[l[i]]>=1: ...
Python
1e156dfc65ef88f19ca1833f75192259
b1e77a3a1efa14aa5fb4f602f092e144
1,100
PASSED
n,q=map(int,input().split()) arr=list(map(int,input().split())) brr=[0]*n d=set() for i in range(n-1,-1,-1): if(arr[i] not in d): d.add(arr[i]) brr[i]=len(d) for i in range(q): print(brr[int(input())-1])
Python
1e156dfc65ef88f19ca1833f75192259
1a0d6376493cb195d275c5859e4ec583
1,100
PASSED
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 3e5 + 5; ll k, ans = -1e17; vector<ll> adj[N]; ll arr[N]; ll dfs1(int start, int par){ ll sum = arr[start]; for(auto v : adj[start]){ if(v != par){ sum += max(0LL, dfs1(v, start)); } } ans = max(ans, sum); return sum; } ll dfs2...
C++
2a113b51334d56ba7d82dd48eb506002
356032a94a29d8c5072005b8fde27e4a
2,400
PASSED
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 3e5 + 5; vector<int> adj[N]; ll k, arr[N], ans = -1e17; ll dfs1(int start, int par){ ll sum = arr[start]; for(auto v : adj[start]){ if(v != par){ sum += max(0LL, dfs1(v, start)); } } ans = max(ans, sum); return sum; } ll dfs2(...
C++
2a113b51334d56ba7d82dd48eb506002
23a1f661ddc9322aa4de7e7c18ff7d2e
2,400
PASSED
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 2; vector<int> adj[MAXN]; long long mx, dp[MAXN], wt[MAXN]; int vist[MAXN], used[MAXN], k = 0; long long dfs(int u, bool bld) { dp[u] = wt[u]; vist[u] = 1; for(auto v : adj[u]) { if(vist[v]) continue; ...
C++
2a113b51334d56ba7d82dd48eb506002
4cdaadf12f420e158a6848b13303e5a6
2,400
PASSED
#include "bits/stdc++.h" using namespace std; const int MAX_RANGE = 1e6; int node_weight[MAX_RANGE]; long long maximum_weight = LONG_MIN; long long Distance[MAX_RANGE]; vector< int > Graph[MAX_RANGE]; int k; void dfs( int node, int parent, int flag ) { Distance[node] = node_weight[node]; for(auto adj...
C++
2a113b51334d56ba7d82dd48eb506002
9b455138c6b7eeae71c7fb3be2bb89bd
2,400
PASSED
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define fi first #define se second #define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k)) #define forn(i,n) for (int i = 0; i < n; i++) #define forr(i,a,b) for (int i = a; i <= b; i++) #define all(v) v.begin(), v.end() #define pb(x) push_back(x) typedef long l...
C++
2a113b51334d56ba7d82dd48eb506002
08c18ed8de0d9b075d8384a3deef05b2
2,400
PASSED
#include "bits/stdc++.h" #define FILE_IN freopen("in", "r", stdin); #define FILE_OUT freopen("out", "w", stdout); #define fr(i,a,b) for(int i =a;i<b;i++) bool debug = 0; #define prin(a) if(debug) cout << #a << " = " << (a) << endl #define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b)) #define separa() if(debug) cou...
C++
2a113b51334d56ba7d82dd48eb506002
bc4afe1ca5c09118d4a43654913ab004
2,400
PASSED
#include "bits/stdc++.h" #define FILE_IN freopen("in", "r", stdin); #define FILE_OUT freopen("out", "w", stdout); #define fr(i,a,b) for(int i =a;i<b;i++) bool debug = 0; #define prin(a) if(debug) cout << #a << " = " << (a) << endl #define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b)) #define separa() if(debug) cou...
C++
2a113b51334d56ba7d82dd48eb506002
1a8c6f201264316ce9dd8bdb4fd12d57
2,400
PASSED
#include "bits/stdc++.h" #define FILE_IN freopen("in", "r", stdin); #define FILE_OUT freopen("out", "w", stdout); #define fr(i,a,b) for(int i =a;i<b;i++) bool debug = 0; #define prin(a) if(debug) cout << #a << " = " << (a) << endl #define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b)) #define separa() if(debug) cou...
C++
2a113b51334d56ba7d82dd48eb506002
422f6c3e68f9d9318b134e154e1c531d
2,400
PASSED
#include "bits/stdc++.h" #define FILE_IN freopen("in", "r", stdin); #define FILE_OUT freopen("out", "w", stdout); #define fr(i,a,b) for(int i =a;i<b;i++) bool debug = 0; #define prin(a) if(debug) cout << #a << " = " << (a) << endl #define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b)) #define separa() if(debug) cou...
C++
2a113b51334d56ba7d82dd48eb506002
c896a6fef6ca0196d0fcf072940460d2
2,400
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long vector <ll> adj[300005]; ll a[300005]; ll dp[300005]; ll k = 0; ll ans = 0; void dfs(ll idx,ll parent) { dp[idx] = a[idx]; for(int i = 0;i<adj[idx].size();i++) { ll cur = adj[idx][i]; if(cur!=parent) { dfs(cur,idx); dp[idx] += m...
C++
2a113b51334d56ba7d82dd48eb506002
f5f9629d206fa8c5c840670167ade313
2,400
PASSED
#pragma GCC target("avx2,avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //using i128 = __int128_t; using ll = long long; using ull = unsign...
C++
70dba833cd107fe780e736ff4597d36f
3e1c8c6994915845838d76a71528bb17
2,800
PASSED
#include<bits/stdc++.h> #define ll long long #define For(i,x,y) for(ll i=(x);i<=(y);++i) using namespace std; const ll N=205,M=120005; ll n,m,ind,S,T,tot,ans,head[M],dis[M],id[N][N],q[M]; char s[N][N]; struct edge{ ll to,next,f; }e[M*10]; ll min(ll x,ll y){return x<y?x:y;} void insert(ll x,ll y,ll f){ e[++tot]=(edge)...
C++
70dba833cd107fe780e736ff4597d36f
853acaedc46c3ca40c77d2a5e18f66a6
2,800
PASSED
#include <bits/stdc++.h> using Int = long long; // clang-format off #define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++) #define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) #define ALL(v) std::begin(v), std::end(v) struct SetupIO { SetupIO() { std::cin.tie(nullptr), std...
C++
70dba833cd107fe780e736ff4597d36f
cfc9bc6a28c6a86076ebf99ae1528f40
2,800
PASSED
#include <bits/stdc++.h> using namespace std; template <typename T> struct moyasu_umeru { int N; T margin; const int R, B; // R:red, B:blue const T INF; vector<tuple<int, int, T>> edges; moyasu_umeru(int V, T INF = numeric_limits<T>::max() / 10) : N(V + 2), margin(0), R(V), B(V + 1), I...
C++
70dba833cd107fe780e736ff4597d36f
c1f880b152309fd9c6032d2be97888a4
2,800
PASSED
#include <bits/stdc++.h> using namespace std; #define LOCAL #pragma region Macros typedef long long ll; #define ALL(x) (x).begin(),(x).end() const long long MOD=1e9+7; // const long long MOD=998244353; const int INF=1e9; const long long IINF=1e18; const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; const char dir[4]={'D','R',...
C++
70dba833cd107fe780e736ff4597d36f
4d1e8d71efac77e78c45a49626feb676
2,800
PASSED
#include <bits/stdc++.h> using namespace std; template<typename T,bool directed> struct Dinic{ struct edge{ int to,rev; T cap; edge(int to,T cap,int rev):to(to),cap(cap),rev(rev){} }; vector<vector<edge>> G; vector<int> level,iter; Dinic(int n):G(n),level(n),iter(n){} int add_ed...
C++
70dba833cd107fe780e736ff4597d36f
b63ddb8f9b6018a1f4afecea44bd8155
2,800
PASSED
#include <algorithm> #include <array> #include <cassert> #include <iostream> #include <queue> #include <vector> using namespace std; template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template<typena...
C++
70dba833cd107fe780e736ff4597d36f
f1194ad1d1046ae101080475a1373c82
2,800
PASSED
#include <algorithm> #include <array> #include <cassert> #include <iostream> #include <queue> #include <vector> using namespace std; template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template<typena...
C++
70dba833cd107fe780e736ff4597d36f
e13515442e9bf32c00f96e0336cb9d7c
2,800
PASSED
#include <algorithm> #include <array> #include <cassert> #include <iostream> #include <queue> #include <vector> using namespace std; template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template<typena...
C++
70dba833cd107fe780e736ff4597d36f
a4bcfb648ced306c92c495e138859ff0
2,800
PASSED
#include <algorithm> #include <array> #include <cassert> #include <iostream> #include <queue> #include <vector> using namespace std; template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template<typena...
C++
70dba833cd107fe780e736ff4597d36f
736d057301f0ea2cb54fed0002e6a093
2,800
PASSED
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; import javafx.scene.input.TouchPoint.State; import static java.l...
Java
6a2fe1f7e767a508530e9d922740c450
ff2fdfb96536e8aba0e0476f3e14ae92
2,000
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * @author Don Li */ public class VanyaField { void solve() { int n = in.nextInt(), m = in.nextI...
Java
6a2fe1f7e767a508530e9d922740c450
93bddaa79cb75c388ee0d309972f9598
2,000
PASSED
// practice with rainboy import java.io.*; import java.util.*; public class CF492E extends PrintWriter { CF492E() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF492E o = new CF492E(); o.main(); o.flush(); } static class V { int x, y, z; V(int x, in...
Java
6a2fe1f7e767a508530e9d922740c450
911d996da4a17a3b281f2dcbd5a4f0f4
2,000
PASSED
import java.io.*; import java.util.*; public class A{ public static void main(String[] args)throws Throwable { MyScanner sc=new MyScanner(); PrintWriter pw=new PrintWriter(System.out); int n=sc.nextInt(); int m=sc.nextInt(); int dx=sc.nextInt(); int dy=sc.nextInt(); int [] Y=new int [n]; int lastx=0...
Java
6a2fe1f7e767a508530e9d922740c450
c890abfb86595b66355c5dc985a411fe
2,000
PASSED
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main extends PrintWriter { BufferedReader in; StringTokenizer stok; final Random rand = new Random(31); final int inf = (int) 1e9; final long linf = (long) 1e18; class Item implements Comparable<Item> { ...
Java
6a2fe1f7e767a508530e9d922740c450
1f46fa7e72110c16094c45fe9c20d1a6
2,000
PASSED
import java.util.*; import java.io.*; public class E { public static void main(String[] args) { FastScanner sc = new FastScanner(); int n = sc.nextInt(); int m = sc.nextInt(); long dx = sc.nextInt(); long dy = sc.nextInt(); long[] rs = gcdexarr(n, dx); long d = dy * rs[1] % (long)n; ArrayList<Pair>[] ...
Java
6a2fe1f7e767a508530e9d922740c450
5eb5e7b91cd1b09e257c26a6ce888d1e
2,000
PASSED
import java.io.*; import java.util.*; class exteuclid { public long g,x,y; public long gcd(long a,long b) { if (b==0) { g=a; x=1; y=0; return g; } else { long g_=gcd(b,a%b); long tem=x; x=y; y=tem-(long)(a/b)*y; return g_; } } exteuclid() { g=x=y=0; } }; public class Ma...
Java
6a2fe1f7e767a508530e9d922740c450
bd32df9808f6c367eb5ccb13a88b62fa
2,000
PASSED
import java.io.*; import java.util.*; class exteuclid { public long g,x,y; public long gcd(long a,long b) { if (b==0) { g=a; x=1; y=0; return g; } else { long g_=gcd(b,a%b); long tem=x; x=y; y=tem-(long)(a/b)*y; return g_; } } exteuclid() { g=x=y=0; } }; public class ye...
Java
6a2fe1f7e767a508530e9d922740c450
961b0ef0a4f38c584b285359aed4d144
2,000
PASSED
import java.util.Scanner; public class Main { public static int[] Y, K; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int dx = sc.nextInt() % n; int dy = sc.nextInt() % n; Y = new int[n]...
Java
6a2fe1f7e767a508530e9d922740c450
406d5d5b53d691d2db5c249922ebb5bf
2,000
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pradyumn */ public class M...
Java
6a2fe1f7e767a508530e9d922740c450
8ab4ba76b7b0087e8e31cd590795db0b
2,000
PASSED
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { //Nhap int n, x; vector<long long>c; cin >> n >> x; long long temp; for (int i = 0; i < n; i++) { cin >> temp; c.push_back(temp); } //Xu ly sort(c.begin(), c.end()); long long res = 0; for (int i = 0; i < n; i++...
C++
ce27e56433175ebf9d3bbcb97e71091e
9f359a000f8fd733bd991391fcf711c8
1,200
PASSED
#include<iostream> #include<vector> #include <fstream> #include <algorithm> using namespace std; void NhapMang(istream &in, vector<long long>&ArrA) { for (int i = 0; i < ArrA.size(); i++) { in >> ArrA[i]; } } bool Option(int a, int b) { return a > b; } void XuLy(vector<long long>&ArrN, int x) { sort(ArrN.begin...
C++
ce27e56433175ebf9d3bbcb97e71091e
22b9473fc02e7f4f0db3b91d45762b5c
1,200
PASSED
#include<bits/stdc++.h> #define ll long long #define in freopen("input.txt", "r", stdin) #define out freopen("output.txt", "w", stdout) #define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) using namespace std ; ll z , o , ans ; ll N = 1e4 + 7 ; int code( ){ int n , x ; cin >> n >>...
C++
ce27e56433175ebf9d3bbcb97e71091e
88421e0953f72e5b843eb58896e24e94
1,200
PASSED
#include <bits/stdc++.h> using namespace std; int main(){ int n,x; cin >> n >> x; vector<long long> C(n); for(long long &c : C){ cin >> c; } sort(C.begin(), C.end()); long long sum = 0; for(long long i : C){ sum += i*x; if(x != 1)x--; } cout << sum; }
C++
ce27e56433175ebf9d3bbcb97e71091e
50f4a47fb07723b6cbc099d83d22e75f
1,200
PASSED