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<bits/stdc++.h> using namespace std; long long int grid[1001][1001]; long long int prefix[1001][1001]; main() { int t; cin >> t; while(t--) { int n,q; cin >> n >> q; memset(grid,0,sizeof(grid)); memset(prefix,0,sizeof(prefix)); for(int i=...
C++
9e9c7434ebf0f19261012975fe9ee7d0
db48c2107ca3f738b8cf6e9ab91c07aa
1,600
PASSED
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #inc...
C++
9e9c7434ebf0f19261012975fe9ee7d0
4d6b5eb811267cf4fa23f40f8acd2c83
1,600
PASSED
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define fori(n) for(int i = 0; i < n; i++) #define forj(n) for(int j = 0; j < n; j++) using namespace std; void fastIO() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); } int main() { fastIO(); ...
C++
9e9c7434ebf0f19261012975fe9ee7d0
a7a6f7982e713729445c487b27c410b6
1,600
PASSED
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define fori(n) for(int i = 0; i < n; i++) #define forj(n) for(int j = 0; j < n; j++) using namespace std; void fastIO() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); } int main() { fastIO(); ...
C++
9e9c7434ebf0f19261012975fe9ee7d0
cd0580d3c7c5679881004b744f4ff96c
1,600
PASSED
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define fori(n) for(int i = 0; i < n; i++) #define forj(n) for(int j = 0; j < n; j++) using namespace std; void fastIO() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); } int main() { fastIO(); ...
C++
9e9c7434ebf0f19261012975fe9ee7d0
f63fa3431642a0996a3ba420891abd46
1,600
PASSED
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define fori(n) for(int i = 0; i < n; i++) #define forj(n) for(int j = 0; j < n; j++) using namespace std; void fastIO() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); } int main() { fastIO(); ...
C++
9e9c7434ebf0f19261012975fe9ee7d0
8eb1cdf94dbab92ead842a5e48470891
1,600
PASSED
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define fori(n) for(int i = 0; i < n; i++) #define forj(n) for(int j = 0; j < n; j++) using namespace std; void fastIO() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); } int main() { fastIO(); ...
C++
9e9c7434ebf0f19261012975fe9ee7d0
2beb68481ba24e084c62340c4ba6bbc8
1,600
PASSED
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define fori(n) for(int i = 0; i < n; i++) #define forj(n) for(int j = 0; j < n; j++) using namespace std; void fastIO() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); } int main() { fastIO(); ...
C++
9e9c7434ebf0f19261012975fe9ee7d0
b97e6759bbe5f2a4758798e2c00ade81
1,600
PASSED
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define fori(n) for(int i = 0; i < n; i++) #define forj(n) for(int j = 0; j < n; j++) using namespace std; void fastIO() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); } int main() { fastIO(); ...
C++
9e9c7434ebf0f19261012975fe9ee7d0
ffbf7ddde38bad88684c6302b7c23794
1,600
PASSED
#include<bits/stdc++.h> #define ll long long #define test ll n; cin>>n; while(n--) #define all(v) (v.begin() , v.end()) using namespace std; int main() { test { int x; cin>>x; vector<string> v(x*3,""); map<string,ll> m; int sum1=0,sum2=0,sum3=0; for (int i = 0; i < x*3; i++) { cin>>v...
C++
f8a89510fefbbc8e5698efe8a0c30927
308f4fd47668493a051ae26be1cb8343
800
PASSED
#include<iostream> #include<algorithm> #include<vector> #include<map> #include<queue> using namespace std; int main() { string s; int t; cin >> t; int n; while (t--) { cin >> n; vector<vector<string>>v(3); vector<int>ans(3, 0); map<string, int>mp; for (int i ...
C++
f8a89510fefbbc8e5698efe8a0c30927
fad7efc367eb52b91b9221f48cb266eb
800
PASSED
#include<iostream> #include<cmath> #include<algorithm> #include<string> #include<vector> #include<map> #include<stack> #include<queue> #include<set> #include<iomanip> #define ll long long #define loop(n) for (long long i = 0; i < n; i++) #define loop1(n) for (long long j= 0; j <n; j++) #define ts ll t; cin>>t; while(t-...
C++
f8a89510fefbbc8e5698efe8a0c30927
dc6cdf047fc6613d941db344bf691b24
800
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long int #define f first #define s second #define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); const int N = 1e5+10 , mod = 1e9 + 7 ; int n , k ; int main() { speed int t = 1 ; cin >> t; while ( t-- ) { cin >> n ; ...
C++
f8a89510fefbbc8e5698efe8a0c30927
5a1c0039f95e8afd22aa13a41bd01388
800
PASSED
#include<iostream> #include<string> #include<set> #include<algorithm> using namespace std; const int N = 1000l; set<string>a; set<string>b; set<string>c; int main() { int t; scanf ("%d", &t); int suma = 0, sumb = 0, sumc = 0; while (t--) { a.clear(); b.clear(); c.clear(); int n; scanf ("%d", &n); strin...
C++
f8a89510fefbbc8e5698efe8a0c30927
020d084cbd6e99f06c334916ec4d3840
800
PASSED
#include<iostream> #include<string> #include<map> using namespace std; int main() { int t; cin >> t; while (t--) { map<string, int>shop; int n; cin >> n; string arr[1005], brr[1005], crr[1005]; for (int i = 1; i <= n; i++) { cin >> arr[i]; shop[arr[i]]++; } for (int i = 1; i <= n; i++) { ...
C++
f8a89510fefbbc8e5698efe8a0c30927
547c9bf389cf94161f4f39c1e19748b4
800
PASSED
#include <bits/stdc++.h> using namespace std; const int fast_io = []() {ios_base::sync_with_stdio(false); cin.tie(nullptr); return 0;}(); int main() { int t; cin >> t; while (t--) { int n; cin >> n; unordered_set<string> s1, s2, s3, sa; for (int i = 0; i < n; ++i) { ...
C++
f8a89510fefbbc8e5698efe8a0c30927
84d078f4fe475c3c2f1d0bcf5b60d74d
800
PASSED
#include <iostream> #include <cmath> #include <algorithm> #include <cstring> #include <map> using namespace std; const int N = 1e5 + 6; map<string, int> H; int n; string a[6][N]; int main() { // freopen("data.in", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); int T; cin >> ...
C++
f8a89510fefbbc8e5698efe8a0c30927
44d89b479d211bf5ab5777b010a9a66f
800
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; string slo[1002][3]; unordered_map<string, int> mapa; void fun() { mapa.clear(); int n; cin >> n; for (int j = 0; j < 3; j++) { for (int i = 0; i < n; i++) { cin >> slo[i][j]; mapa[slo[i][j]]++; ...
C++
f8a89510fefbbc8e5698efe8a0c30927
99c16c975dd08ca709cc5beeebbb5b1c
800
PASSED
#include <iostream> #include <set> #include <string> using namespace std; int main(void) { set<string>sA; set<string>sB; set<string>sC; int t = 0; cin >> t; while (t--) { int A = 0, B = 0, C = 0; int n = 0; cin >> n; for (int i = 0; i < n; i++) { string str; cin >> str; sA.insert(str); } f...
C++
f8a89510fefbbc8e5698efe8a0c30927
7c2abc58dbc8d048c76ca9dd8a388720
800
PASSED
#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define rep(i, j, k) for(int i = j; i <= k;i++) #define per(i, j, k) for (int i = j; i >= k;i--) #define vi vector<int> #define vl vector<ll> #define pii pair<int, int> #define pll pair<ll, ll> #define all(a) a.begin(),a.end() #define lowbit(x) (x&-x) typedef lo...
C++
52bd5dc6b92b2af5aebd387553ef4076
92e197a73a69f24a410a179a1385b74c
1,500
PASSED
/** * author: 3omar_ahmed * date: 09-09-2022 * Expert When :) */ #include <bits/stdc++.h> using namespace std ; #define endl '\n' const int mod = (1ll << 31); signed main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); srand(time(0)); int t = 1; cin >> t; while(t--){ ...
C++
52bd5dc6b92b2af5aebd387553ef4076
eabb6d15442ae37cb625d163d0a91b9c
1,500
PASSED
/** * author: 3omar_ahmed * date: 09-09-2022 * Expert When :) */ #include <bits/stdc++.h> using namespace std ; #define int long long #define endl '\n' #define all(a) a.begin() , a.end() #define alr(a) a.rbegin() , a.rend() const int mod = (1ll << 31); signed main(){ ios_base::sync_with_stdio(0); c...
C++
52bd5dc6b92b2af5aebd387553ef4076
844529d1a40ee315b4528b804c3c41fb
1,500
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; #define endl '\n' #define ll long long #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statis...
C++
52bd5dc6b92b2af5aebd387553ef4076
21ca7aa36657769d7cd868d5809f11b5
1,500
PASSED
#include <bits/stdc++.h> using namespace std ; #define int long long #define endl '\n' //temxlate<class x> using ordered_set = tree<x, null_tyxe,less<x>, rb_tree_tag,tree_order_statistics_node_uxdate>; #define all(a) a.begin() , a.end() #define alr(a) a.rbegin() , a.rend() signed main(){ ios_base::syn...
C++
52bd5dc6b92b2af5aebd387553ef4076
3e3b530f44f8c3376278b18f554ba879
1,500
PASSED
// just add one conditon that random number is repeating or not #include <bits/stdc++.h> using namespace std; using ll = long long int; void solve(){ ll n;cin>>n; vector <ll> v(n); if(n%4 == 0){ for(ll i=0;i<n;i++)cout << i << " \n"[i==n-1]; return; } else if(n%4 == 3){ for(ll i=1;i<=n;i++)co...
C++
52bd5dc6b92b2af5aebd387553ef4076
f172ceeacf589be1eb07f2cdd34c8baf
1,500
PASSED
#include <bits/stdc++.h> using namespace std; using ll = long long int; void solve(){ ll n;cin>>n; vector <ll> v(n); if(n%4 == 0){ for(ll i=0;i<n;i++)cout << i << " \n"[i==n-1]; return; } else if(n%4 == 3){ for(ll i=1;i<=n;i++)cout << i << " \n"[i==n]; return; } auto get = [&](){ //...
C++
52bd5dc6b92b2af5aebd387553ef4076
126d9fba8d8542b35b0827099afb79df
1,500
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll findXOR(ll n){ ll mod = n % 4; if (mod == 0) return n; else if (mod == 1) return 1; else if (mod == 2) return n + 1; else if (mod == 3) return 0; } ll findXOR(ll l, ll r){ return (findXOR(l - 1) ^ findXOR(r)); } int main() { ...
C++
52bd5dc6b92b2af5aebd387553ef4076
eb2df0f86ff3a006ccfa7f6566f25f5a
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long #define ull unsigned long long int t = 1; int main() { ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); cin >> t; int tt = t; while (t--...
C++
52bd5dc6b92b2af5aebd387553ef4076
6185cf35a0e33c2c1d696efdac1e8ff3
1,500
PASSED
//Mars Sanzhar //marssan07@gmail.com #include <bits/stdc++.h> using namespace std; //#pragma GCC target ("avx2") #pragma GCC optimization ("O3") //#pragma GCC optimization ("unroll-loops") #pragma optimization_level 3 //#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #define all(a) a.begi...
C++
52bd5dc6b92b2af5aebd387553ef4076
82c2bb477f6187829252e87290e7aa79
1,500
PASSED
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; /** * * @Har_Har_Mahadev */ public class F { private static int m, n; private static int[][] vis; public static void process() throws...
Java
6a06ad39dbdd97ca8654023009c89a42
e6268a6922c33f6291ddfa5c5638e016
1,700
PASSED
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintStream; import java.lang.reflect.Array; import java.util.*; import java.util.function.IntFunction; import java.util.function.IntUnaryOperator; import java.util.function.ToIntFunction; import java.ut...
Java
6a06ad39dbdd97ca8654023009c89a42
2180faa941ab0b97247992719ddcc6fb
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.*; public class Main { // static int[] prime = new int[100001]; final static long mod = 1000000007; public static void main(Strin...
Java
6a06ad39dbdd97ca8654023009c89a42
f965ec41d58b4ef33e112b26dc4ea664
1,700
PASSED
import java.util.Scanner; public class problemF { public static int n, m; public static char[][] a; public static int[][] dd; public static boolean isValid(int i, int j) { if (i >= 1 && i <= n && j >= 1 && j <= m) return true; return false; } public st...
Java
6a06ad39dbdd97ca8654023009c89a42
611efc4ecf4054e3424b09e5a3bb7be9
1,700
PASSED
import java.util.*; public class Test1 { static int[] dir = new int[] { 0, 1, 0, -1, 0 }; static int[] diag = new int[] { 1, 1, -1, -1, 1}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); while(tc-->0) { int row = sc.nextInt(),...
Java
6a06ad39dbdd97ca8654023009c89a42
a6ea42e6c3f6d78c087c60c4996399fa
1,700
PASSED
import java.util.*; public class Test1 { static int[] dir = new int[] { 0, 1, 0, -1, 0 }; static int[] diag = new int[] { 1, 1, -1, -1, 1}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); while(tc-->0) { int row = sc.nextInt(),...
Java
6a06ad39dbdd97ca8654023009c89a42
4f4e86d3400bda865e7de191b5bd638f
1,700
PASSED
import java.io.*; import java.util.*; public class CF1722F extends PrintWriter { CF1722F() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1722F o = new CF1722F(); o.main(); o.flush(); } int n, m; byte[][] cc; int count1(int i, int j) { return i >= 0 && i...
Java
6a06ad39dbdd97ca8654023009c89a42
566b3dd9cd40856223cf4086de8712f3
1,700
PASSED
import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class CF1722F { public static void main(String[] args) { Scanner scanner = new Scanner(System.in, StandardCharsets.UTF_8); int t = scanner.nextInt(); for ...
Java
6a06ad39dbdd97ca8654023009c89a42
51c62d8e5b9a7029dea6c4717d41a0b7
1,700
PASSED
import java.io.BufferedInputStream; import java.util.*; public class F { static final int[][] dirs = { {-1, 0}, {-1, -1}, {-1, 1}, {0, 1}, {0, -1}, {1, 0}, {1, -1}, {1, 1} }; static boolean handle(char[][] chess, boolean[][] used, int y, int x) { ...
Java
6a06ad39dbdd97ca8654023009c89a42
d80174830e82c601b1789b031931b1f4
1,700
PASSED
import java.io.*; import java.math.*; import java.util.*; /* * Author: Atuer */ public class Main { // ==== Solve Code ====// static int INF = 2000000010; public static void csh() { } public static void main(String[] args) throws IOException { // csh(); int t = in.nextInt(); while (t-- > 0) { ...
Java
6a06ad39dbdd97ca8654023009c89a42
ea8df0b24731d641c06121a24a1ba664
1,700
PASSED
#include <iostream> #include <cstdio> using namespace std; int main() { int t; cin>>t; while(t--) { int n,m,r,c; cin>>n>>m>>r>>c; int i,j; //iterators int flag=0; int cntb=0; char** arr=new char*[n]; for(int...
C++
4ca13794471831953f2737ca9d4ba853
0adae79478b09cf5767d85321211cf6a
800
PASSED
#include<cstdio> #include<iostream> const int maxn = 55; int t, r, c, m, n; char mp[maxn][maxn]; char enter; int main() { scanf("%d", &t); while (t > 0) { scanf("%d%d%d%d", &m, &n, &r, &c); getchar(); //std::cout << "m:" << m << " " << "n: " << n ; bool flag = false; //标记是否有b块 for (in...
C++
4ca13794471831953f2737ca9d4ba853
fe0dd5a64043ef756cc89970bc1f2c2d
800
PASSED
#include <iostream> #include <algorithm> #include <vector> typedef long long ll; #define fastread()(ios_base:: sync_with_stdio(false),cin.tie(NULL)); using namespace std; int main() { ll t; cin >> t; ll res; ll n = 0, m = 0, r = 0, c = 0; int b = 0; while (t--) { res...
C++
4ca13794471831953f2737ca9d4ba853
24a2b16060ca4a2cd8a004dbdd3b0151
800
PASSED
#include <iostream> #include <string> using namespace std; int main() { bool is_black = 0; bool black_in_rc = 0; bool all_white = 1; int row, col, x, y; string row_chars; int repeat; cin >> repeat; for (int n = 0; n < repeat; n++) { is_black = 0; black_in_rc = 0; ...
C++
4ca13794471831953f2737ca9d4ba853
e022f353cbf02ffb803da04800942d76
800
PASSED
#include<iostream> using namespace std; int main() { int t; cin>>t; while(t--) { int n,m,r,c; int B_avail = 0, one = 0; cin>>n; cin>>m; cin>>r; cin>>c; char* arr = new char[n*m]; for(int i=0;i<n;i++) { for(int j=0;...
C++
4ca13794471831953f2737ca9d4ba853
579c4d40ef02344c578dfab5754d6a67
800
PASSED
#include<stdio.h> int main( ) { char s[55][55]; int T,i,j,n,m,r,c,j1,j2,j3; scanf("%d",&T); while(T--) { j1=j2=j3=0; scanf("%d%d%d%d",&n,&m,&r,&c); getchar(); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%c",&s[i][j]);...
C++
4ca13794471831953f2737ca9d4ba853
f6b810d6d780766ecd8d4f140e110fee
800
PASSED
#include <iostream> #include <cstring> using namespace std; char s[55][55]; int main() { int t, n, m, x, y; while (cin >> t) { while (t--) { cin >> n >> m >> x >> y; int flag = 1, flag2 = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) {...
C++
4ca13794471831953f2737ca9d4ba853
b60359a39fb9d7731dc90fd597f76402
800
PASSED
#include<iostream> #include<stdio.h> using namespace std; int main() { int cishu; cin>>cishu; int i,j,k; char graph[100][100]; for(i=0;i<cishu;i++) { int row,column,r,c; cin>>row>>column>>r>>c; for(j=0;j<row;j++) for(k=0;k<column;k++) cin>>graph[j][k]; if(graph[r-1][c-1]=='B') cout<<"0\n"; else ...
C++
4ca13794471831953f2737ca9d4ba853
e0d85dea4fa110d42f5b3655e5dcab9c
800
PASSED
#include<iostream> #include<cstring> #include<algorithm> using namespace std; char k[150][150]; int main() { int a,b,c,d,e,n,m=0,flag=1,p; char k[150][150]; cin>>a; while(a--) { cin>>b>>c>>d>>e; d--; e--; for(n=0;n<b;n++) for(p=0;p<c;p++) cin>>k[n][p]; m=0; flag=1; for(n=0;n<b;n++) ...
C++
4ca13794471831953f2737ca9d4ba853
220d780b6f2c20c68a63d0e31e54e0eb
800
PASSED
#include <iostream> using namespace std; void solve() { int m,n,r,c; cin>>m>>n>>r>>c; bool f=false,t=false; int ans=10000; for(int i=1;i<=m;i++) { for(int j=1;j<=n;j++) { char ch; cin>>ch; if(ch=='B') { ...
C++
4ca13794471831953f2737ca9d4ba853
d94143a0f0d62b4c2a1a7735802eae46
800
PASSED
def main(): import sys readline=sys.stdin.readline for _ in range(int(readline())): n,m=map(int,readline().split()) ans=[] for a in range(n): for b in range(m): ans.append(max(a+b,a+m-b-1,n-a+m-b-2,n-a-1+b)) print(' '.join(map(str,sorted(ans)))) main()
Python
dc1dc5e5dd17d19760c772739ce244a7
36b53e049ccb682c7eebf86cd2d41b1c
1,300
PASSED
def main(): import sys readline = sys.stdin.readline for _ in range(int(readline())): n, m = map(int, readline().split()) ans = [] for a in range(n): for b in range(m): ans.append(max(a+b, a+m-b-1, n-a+m-b-2, n-a-1+b)) print(' '.join(map(str, sorted(ans)))) main()
Python
dc1dc5e5dd17d19760c772739ce244a7
47d8307c97115cbeceaf50f7d79f0f5a
1,300
PASSED
def main(t): for _ in range(t): n, m = map(int, readline().split()) ans = [] for a in range(n): for b in range(m): ans.append(max(a+b, a+m-b-1, n-a+m-b-2, n-a-1+b)) ans.sort() print(' '.join(map(str, ans))) if __name__ == "__main__": import sys readline = sys.stdin.r...
Python
dc1dc5e5dd17d19760c772739ce244a7
3dacc5f182e3f4f65b44e0b00cfe2b56
1,300
PASSED
def main(t): for _ in range(t): n, m = map(int, readline().split()) ans = [] for a in range(n): for b in range(m): ans.append(max(a+b, a+m-b-1, n-a+m-b-2, n-a-1+b)) ans.sort() print(' '.join(map(str, ans))) if __name__ == "__main__": import sys readline = sys.stdin.r...
Python
dc1dc5e5dd17d19760c772739ce244a7
1fc64bcc8e4362a247578389c50ba8a7
1,300
PASSED
def main(t): for _ in range(t): n, m = map(int, readline().split()) ans = [] for a in range(n): for b in range(m): ans.append(max(a+b, a+m-b-1, n-a+m-b-2, n-a-1+b)) ans.sort() print(*ans) if __name__ == "__main__": import sys readline = sys.stdin.readline T = int(...
Python
dc1dc5e5dd17d19760c772739ce244a7
ff4fb6c6be463caf441be72b7bb34456
1,300
PASSED
def main(): for _ in range(t): n, m = map(int, readline().split()) ans = [] for a in range(n): for b in range(m): ans.append(max(a+b, a+m-b-1, n-a+m-b-2, n-a-1+b)) ans.sort() print(*ans) if __name__ == "__main__": import sys readline = sys.stdin.readline t = int(r...
Python
dc1dc5e5dd17d19760c772739ce244a7
511655a3faabea371bebb760548cf5fc
1,300
PASSED
def main(): for _ in range(t): n, m = map(int, readline().split()) ans = [] for a in range(n): for b in range(m): ans.append(max(a+b, a+m-b-1, n-a+m-b-2, n-a-1+b)) print(' ' .join(map(str, sorted(ans)))) if __name__ == "__main__": import sys readline = sys.stdin.readline ...
Python
dc1dc5e5dd17d19760c772739ce244a7
e7b6bb73a35f8a7495eec31190ce01de
1,300
PASSED
def main(): for _ in range(t): n, m = map(int, readline().split()) arr = [] for a in range(n): for b in range(m): arr.append(max(abs(a-0)+abs(b-0), abs(a-0)+abs(b-(m-1)), abs(a-(n-1))+abs(b-(m-1)), abs(a-(n-1))+abs(b-0))) print(' ' .join(map(str, sorted(arr)))) if __name__ == "...
Python
dc1dc5e5dd17d19760c772739ce244a7
ae2ebb962c01317d9c80a1d9216c4bb5
1,300
PASSED
def main(): for _ in range(t): n, m = map(int, readline().split()) arr = [] ans = 0 for a in range(n): for b in range(m): ans = max(ans, abs(a-0)+abs(b-0)) ans = max(ans, abs(a-0)+abs(b-(m-1))) ans = max(ans, abs(a-(n-1))+abs(b-(m-1))) ans = max(ans, abs...
Python
dc1dc5e5dd17d19760c772739ce244a7
0fb02ebe076f2be2aae4916651c10816
1,300
PASSED
def main(): for _ in range(t): n, m = map(int, readline().split()) # ans = [n-1-(n-1)//2 + m-1-(m-1)//2] flagN, flagM = False, False arr = [] ans= 0 for a in range(n): for b in range(m): ans = max(ans, abs(a-0)+abs(b-0)) ans = max(ans, abs(a-0)+abs(b-(m-1))) ...
Python
dc1dc5e5dd17d19760c772739ce244a7
72de3f377568fbf32664514a1e54a289
1,300
PASSED
from collections import defaultdict class Graph: def __init__(self): self.graph = defaultdict(list) def addEdge(self,u,v): self.graph[u].append(v) self.graph[v].append(u) # 2.DFS from a vertex def DFS(self,vertex): path=[] stack...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
947c08be65b538faad5719f99f375b76
1,400
PASSED
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") for t in range(int(input())): n = int(input()) graph = [[] for __ in range(n + 1)] ans = [-1] * (n - 1) for i in range(n - 1): x, y = map(int, input().split()) graph[x] += [(y, i)] graph[y] += [(x, i)] ...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
9dc15cfb02464a17638d4445873cd39e
1,400
PASSED
def BFS(s,graph,val,answer,n): visited = [False] * (n + 1) queue = [] queue.append([s,val]) visited[s] = True while queue: s = queue.pop(0) for i in graph[s[0]]: if visited[i] == False: ...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
c11ecd7f504429de381d2f4b98d9d254
1,400
PASSED
# from fractions import Fraction # import itertools # from array import array as arr # l = arr('i, f, d', li()) # from math import ceil, gcd import os import sys from io import BytesIO, IOBase # from collections import Counter, OrderedDict, defaultdict, deque # from bisect import bisect_right, bisect_left, ins...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
af01c75735dd4d5f7668992f2d17ebc6
1,400
PASSED
# from fractions import Fraction # import itertools # from array import array as arr # l = arr('i, f, d', li()) # from math import ceil, gcd import os import sys from io import BytesIO, IOBase # from collections import Counter, OrderedDict, defaultdict, deque # from bisect import bisect_right, bisect_left, ins...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
a43426f33c18bb1e514a17e5080b8cf3
1,400
PASSED
t = int(input()) for _ in range(t): n = int(input()) graph = [[] for _ in range(n + 1)] edges = [] for i in range(n - 1): u, v = map(int, input().split()) graph[u] += [(v, i)] graph[v] += [(u, i)] edges.append((u, v)) if max(len(graph[i]) for i in range(n + ...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
9f78ab9b8ec4a618e84fc305c10e006b
1,400
PASSED
from sys import setrecursionlimit setrecursionlimit(10**5 + 100) T = int(input()) for _ in range(T): N = int(input()) adj = [[] for _ in range(N)] for i in range(N-1): A, B = map(int, input().split()) adj[A-1].append((B-1, i)) adj[B-1].append((A-1, i)) for elt in adj: i...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
b7ce6bece32613e9c754e52e1140f8f1
1,400
PASSED
t = int(input()) def solve(n, a): adjl = [[] for i in range(n+1)] for i in a: x, y = i adjl[x].append(y) adjl[y].append(x) dc = {} for i in adjl: if len(i)>2: return -1 def bfs(num, do): pro, line, ct, r = [0]*(n+1), [nu...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
dfed5034e15204c7db968dc239fe2e7e
1,400
PASSED
from heapq import heapify, heappush, heappop from collections import Counter, defaultdict, deque from queue import PriorityQueue from itertools import combinations, product, permutations from bisect import bisect_left, bisect_right from functools import lru_cache from sys import stdin, stdout # for input /output import...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
d3b12f84e154c03b9f662b2421c1e92e
1,400
PASSED
import io, os import sys from sys import stdin from bisect import bisect_left, bisect_right from collections import defaultdict, deque, namedtuple from heapq import heappush, heappop from math import gcd, ceil, floor, factorial, sqrt from itertools import combinations, permutations input = sys.stdin.buffer...
Python
0639fbeb3a5be67a4c0beeffe8f5d43b
bbba7ad392a869efdd43b286b7085e7a
1,400
PASSED
// LUOGU_RID: 94357807 #include<bits/stdc++.h> using namespace std; const int maxn=1e6+11; int n,ans=0; int awa[maxn],a[maxn]; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; awa[a[i]]=a[i];//记录存在 } for(int i=1;i<=1e6;i++){ int ok=0; int gcd=0; for(int j=i;j<=1e6;j+=i){ if(aw...
C++
1a37e42263fdd1cb62e2a18313eed989
1a8b81aa674d7e11511f868d76ad9cc0
1,900
PASSED
// LUOGU_RID: 90401013 #include<bits/stdc++.h> using namespace std; #define int long long int n,a[1000010],b[1000010]; bool d[1000010]; signed main(){ cin>>n; int sw=0; for(int i=1;i<=n;i++)cin>>a[i],d[a[i]]=1; for(int i=1;i<=n;i++)b[a[i]]=a[i]; for(int i=1;i<=1e6;i++){ for(int j=1;i*j<=1e6;j++)b[i]=_...
C++
1a37e42263fdd1cb62e2a18313eed989
cdacd4b1a94ce6eeb6682c2525a8ed06
1,900
PASSED
// LUOGU_RID: 90393365 #include <bits/stdc++.h> #define int long long using namespace std; int n; int a[1000005]; int f[1000005]; bool w[1000005]; vector<int>vec[1000005]; int ans; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; ...
C++
1a37e42263fdd1cb62e2a18313eed989
daf063256039fd8529ac16da9643aa12
1,900
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n,maxv,a[1000005],cnt[1000005],ans; int gcd(int x,int y) { if(y==0) return x; return gcd(y,x%y); } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); cnt[a[i]]++; maxv=max(maxv,a[i]); } for(in...
C++
1a37e42263fdd1cb62e2a18313eed989
86895e727df3633f571bbb71470dccee
1,900
PASSED
#include<bits/stdc++.h> using namespace std; int n,x,cnt,ans; bool b[1000005]; int gcd(int x,int y) { if(!y) return x; return gcd(y,x%y); } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&x); if(!b[x]) cnt++; b[x]=1; } for(int i=1;i<=1000000;i++) { int res=-1; for...
C++
1a37e42263fdd1cb62e2a18313eed989
ee831df531b663f5d6681f4221324f7f
1,900
PASSED
#include <cstdio> #include <iostream> #include <cmath> #include <algorithm> #include <string> #include <cstring> #include <stack> #include <queue> #include <map> #include <vector> #include <list> #include <set> #include <functional> #include <iomanip> #include <cstdlib> #include <cctype> #include <ctime> #include <clim...
C++
1a37e42263fdd1cb62e2a18313eed989
3ea9538ed2ba3437d54ef3e9bed75e3e
1,900
PASSED
#include<iostream> using namespace std; int gcd(int a,int b) { return b==0?a:gcd(b,a%b); } const int N=1e6+10; int maxn,a[N],ans; int lcm(int a,int b) { return a/gcd(a,b)*b; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { int num; cin>>num; a[num]=1;maxn=max(maxn,num); } for(i...
C++
1a37e42263fdd1cb62e2a18313eed989
3626e7d91d0772c5cbd5a9af147c2c52
1,900
PASSED
#include<bits/stdc++.h> using namespace std; #define max(a,b) (a>b?a:b) template<typename G>inline void read(G&x){x=0;G f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+(ch^48),ch=getchar();x*=f;} template<typename G>inline void write(G x){if(x<0) putchar('-'),...
C++
1a37e42263fdd1cb62e2a18313eed989
364b7ff66e94280ed331b0df846f1500
1,900
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; const int maxn=1e6+5; const int mod=1e9+7; const int INF=0x3f3f3f3f; int n,m; int dp[maxn],a[maxn],is[maxn]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]),is[a[i]]=1,dp[a[i]]=a...
C++
1a37e42263fdd1cb62e2a18313eed989
aec59098a085c6d4da1dbc4d8bb6dc48
1,900
PASSED
#include <bits/stdc++.h> using namespace std; int n; int isin[1000010]; int a[1000010]; int f[1000010]; int ans; int main() { cin>>n; for(int i=0;i<n;i++) cin>>a[i],isin[a[i]]=1,f[a[i]]=a[i]; for(int i=1;i<=1e6;i++) { for(int j=1;1ll*i*j<=1e6;j++) f[i]=__gcd(f[i],f[i*j]); if(f[i]==i and isi...
C++
1a37e42263fdd1cb62e2a18313eed989
ed932aec7adf0930d7fa07c6b916e720
1,900
PASSED
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("O3") //#pragma GCC target("avx,avx2") long long dp[220'005]; inline size_t key(int i,int j) {return (size_t) i << 32 | (unsigned int) j;} unordered_map<size_t,int>keys; vector<pair<int,int>>points[100'005]; int x[100'005]; vector<pair<int,long long>...
C++
0c2fd0e84b88d407a3bd583d8879de34
8f10d791c295699459173b14da34e059
2,200
PASSED
/** * * * * * * * * * * * * * * * **\ * * * Author: Haidara Nassour * * Coded in: YYYY\MM\DD HH:MM:SS * * Language: C++ * * * \** * * * * * * * * * * * * * * * **/ #include<bits/stdc++.h> #include<ext/pb_ds/assoc_co...
C++
0c2fd0e84b88d407a3bd583d8879de34
805b0de41ffcd6807f1bad2e6850a7f4
2,200
PASSED
#include <bits/stdc++.h> #define test ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int T;cin >> T;while (T--) #define ll long long #define F first #define S second using namespace std; struct obj { ll fr, sc, th, fo; obj(ll a, ll b, ll c, ll d) { fr = a, sc = b, th = c; fo = d; } }...
C++
0c2fd0e84b88d407a3bd583d8879de34
f657038fd489a1c09702b0b45ab92c33
2,200
PASSED
// #include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' #define int long long mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 1e5+10;//CHANGE IT! const int maxm = maxn*2; const int p = 1e9+7;//CHANGE IT! const int INF = 1E18; ll Pow(ll x...
C++
0c2fd0e84b88d407a3bd583d8879de34
d2c087f7e711c159fa9d058268afa803
2,200
PASSED
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <ca...
C++
0c2fd0e84b88d407a3bd583d8879de34
ca310662bd3ec3b5f7067c690950a5b7
2,200
PASSED
#include <bits/stdc++.h> #define fr first #define sc second #define ll long long #define pb push_back using namespace std; ifstream fin("a.in"); ll md=1000000007; int INF=1e9+1; ll LINF=1e18+1; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll t,ct=0; cin >> t; while(t--) ...
C++
0c2fd0e84b88d407a3bd583d8879de34
c5b7d143e4dc2f3dfba5308e9040ea6a
2,200
PASSED
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<map> #include<set> using namespace std; struct node { int idx; long long h; friend inline bool operator<(const node& lhs, const node& rhs) { return lhs.h < rhs.h; } node(int idx, long long h) : idx(idx), h(h) {} }; st...
C++
0c2fd0e84b88d407a3bd583d8879de34
6f37f924a96552fa16510bea16287902
2,200
PASSED
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<map> #include<set> using namespace std; struct node { int idx; long long h; friend inline bool operator<(const node& lhs, const node& rhs) { return lhs.h < rhs.h; } node(int idx, long long h) : idx(idx), h(h) {} }; st...
C++
0c2fd0e84b88d407a3bd583d8879de34
458c841b4f746b76cab2158b5f07d1e5
2,200
PASSED
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<map> #include<set> using namespace std; struct node { int idx; long long h; friend inline bool operator<(const node& lhs, const node& rhs) { return lhs.h < rhs.h; } node(int idx, long long h) : idx(idx), h(h) {} }; st...
C++
0c2fd0e84b88d407a3bd583d8879de34
4616df4410b464d200a30503d6b582c5
2,200
PASSED
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<map> #include<set> using namespace std; struct node { int idx; long long h; friend inline bool operator<(const node& lhs, const node& rhs) { return lhs.h > rhs.h; } node(int idx, long long h) : idx(idx), h(h) {} }; st...
C++
0c2fd0e84b88d407a3bd583d8879de34
c87d0f9fa9f1e88b2d70aaee1e8fcd70
2,200
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } int t,n,k,...
C++
6c1d534c1066997eb7e7963b4e783708
4da0d9061d5425962da1a31f660633bf
2,700
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } int T,N,K,...
C++
6c1d534c1066997eb7e7963b4e783708
18b2e76f1d38691882f034e9b1df1e5d
2,700
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } int T,N,K,...
C++
6c1d534c1066997eb7e7963b4e783708
66ce206fdc8afeaf77165a78e722b1f0
2,700
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } int T,N,K,...
C++
6c1d534c1066997eb7e7963b4e783708
cbed0d7329af20007d54f9bf99eec14c
2,700
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } int T,N,K,...
C++
6c1d534c1066997eb7e7963b4e783708
4328e15f79b90b50ba4c2ebbe24432a3
2,700
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } int T,N,K,...
C++
6c1d534c1066997eb7e7963b4e783708
e9ab4cac8d7ad4181fbcdc5ab30072b2
2,700
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } int T,N,K,...
C++
6c1d534c1066997eb7e7963b4e783708
77dd944f65b8aca40770991e234c1db1
2,700
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } template <...
C++
6c1d534c1066997eb7e7963b4e783708
b34f514b6f96ca0ebc69aabaeefa99d0
2,700
PASSED
#include<bits/stdc++.h> using namespace std; inline int read() { int ret=0,f=1; char ch=getchar(); while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); } return ret*f; } template <...
C++
6c1d534c1066997eb7e7963b4e783708
3ba8068a5abd3212543db5ecf6faddf1
2,700
PASSED
#include<bits/stdc++.h> using namespace std; int t,n,k; int mp[505][505][5]; const int nxt[4][2]={{-1,0},{0,1},{1,0},{0,-1}}; bool vis[505][505]; int dis[505][505]; int ans; struct edge { int x,y; int w; bool operator <(const edge& o) const{ return w>o.w; } }; priority_queue <edge> q; int main(...
C++
6c1d534c1066997eb7e7963b4e783708
f3f93d1eaa3c10542b5b9f99fd804708
2,700
PASSED
#include <iostream> #include<bits/stdc++.h> using namespace std; int main() { long long t,p,a,b,c; cin>>t; while(t--) { cin>>p>>a>>b>>c; long long temp1=(a-p%a)%a; long long temp2=(b-p%b)%b; long long temp3=(c-p%c)%c; long long ans1=min(temp1,temp2); lon...
C++
293f9b996eee9f76d4bfdeda85685baa
afca0a0068297824213e42f48cdb77f6
800
PASSED