diff --git a/Algo.txt b/Algo.txt new file mode 100644 index 0000000..85d606b --- /dev/null +++ b/Algo.txt @@ -0,0 +1 @@ +sort and bunary search diff --git a/Algorithm.txt b/Algorithm.txt new file mode 100644 index 0000000..93b60d6 --- /dev/null +++ b/Algorithm.txt @@ -0,0 +1,10 @@ +#include +int main() +{ int a[100]; +int k=a[0]; + for(int i=0;i<100;i++) + { if(a[i]>k) + k=a[i]; + } + printf("%d",k); +} diff --git a/Binary Search/16123004.py b/Binary Search/16123004.py index c2eabcf..96a6ce6 100644 --- a/Binary Search/16123004.py +++ b/Binary Search/16123004.py @@ -1,4 +1,5 @@ l = [ 2,3,4,5,6,8] +// This is a code hehehe n = len(l) for i in n: diff --git a/Graph/Permutations.cpp b/Graph/Permutations.cpp new file mode 100644 index 0000000..2db0db2 --- /dev/null +++ b/Graph/Permutations.cpp @@ -0,0 +1,116 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +#define FOR(i, a, b) for(int i=(a);i<(b);i++) +#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i) +#define FILL(A,value) memset(A,value,sizeof(A)) +#define ALL(V) V.begin(), V.end() +#define SZ(V) (int)V.size() +#define PB push_back +#define MP make_pair +#define Pi 3.14159265358979 +#define x0 ikjnrmthklmnt +#define y0 lkrjhkltr +#define y1 ewrgrg +typedef long long Int; +typedef unsigned long long UInt; +typedef vector VI; +typedef pair PII; +typedef complex base; +const int INF = 1000000000; +const int MAX = 100007; +const int MAXE = 5000; +const int MAXV = 20*20; +const int BASE = 1000000007; +const int MOD = 1000000007; +vector g[MAX]; +bool U[MAX]; +VI A , B; +int P[MAX]; +int Q[MAX]; +void dfs(int v) +{ + U[v] = 1; + A.push_back(P[v]); + B.push_back(Q[v]); + FOR(i,0,g[v].size()) + { + if (!U[g[v][i]]) + { + dfs(g[v][i]); + } + } +} +int main() +{ + //freopen("in.txt", "r", stdin); + int t; + cin >> t; + FOR(tt,0,t) + { + int n , m; + cin >> n >> m; + FOR(i,0,n) + { + U[i] = 0; + g[i].clear(); + } + FOR(i,0,n) + { + cin >> P[i]; + } + FOR(i,0,n) + { + cin >> Q[i]; + } + FOR(i,0,m) + { + int a , b; + scanf("%d%d" , &a , &b); + --a;--b; + g[a].push_back(b); + g[b].push_back(a); + } + bool ok = 1; + FOR(i,0,n) + { + if (!U[i]) + { + A.clear(); + B.clear(); + dfs(i); + sort(ALL(A)); + sort(ALL(B)); + if (A != B) ok = 0; + } + } + if (ok) + { + cout << "YES" << endl; + } + else + { + cout << "NO" << endl; + } + } + return 0; +}