From 9a06d1c022c417c4fe91db7f4cce5ddfb88cfa0d Mon Sep 17 00:00:00 2001 From: sudoinit <56631918+sudoinit@users.noreply.github.com> Date: Fri, 2 Oct 2020 15:21:37 +0530 Subject: [PATCH] Add files via upload --- Codeforces/624A.cpp | 38 +++++++++++++++++++++++++++++++++ Codeforces/624B.cpp | 46 +++++++++++++++++++++++++++++++++++++++ Codeforces/624B2.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++ Codeforces/624C.cpp | 39 +++++++++++++++++++++++++++++++++ Codeforces/624D.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 225 insertions(+) create mode 100644 Codeforces/624A.cpp create mode 100644 Codeforces/624B.cpp create mode 100644 Codeforces/624B2.cpp create mode 100644 Codeforces/624C.cpp create mode 100644 Codeforces/624D.cpp diff --git a/Codeforces/624A.cpp b/Codeforces/624A.cpp new file mode 100644 index 00000000..a33f79c8 --- /dev/null +++ b/Codeforces/624A.cpp @@ -0,0 +1,38 @@ +#include +using namespace std; +typedef long long ll; + +int main(){ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + ll t; cin>>t; + while(t--){ + ll a,b; + cin>>a>>b; + ll ans=0; + ll diff=b-a; + if(diff==0){ + ans=0; + } + else if(diff<0){ + diff*=-1; + if(diff & 1){ + ans=2; + } + else{ + ans=1; + } + } + else{ + if(diff & 1){ + ans=1; + } + else{ + ans=2; + } + } + cout< +using namespace std; +typedef long long ll; + +int main(){ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + ll t; cin>>t; + while(t--){ + ll n,m; cin>>n>>m; + int arr[n]; + int pos[m]; + for(int i=0;i>arr[i]; + } + ll temp; + for(int i=0;i>temp; + pos[i]=temp-1; + } + sort(pos,pos+m); + char s[n-1]; + for(int i=0;iarr[i+1]){ + flag=false; + break; + } + } + if(flag) + cout<<"YES\n"; + else + cout<<"NO\n"; + + } + return 0; +} \ No newline at end of file diff --git a/Codeforces/624B2.cpp b/Codeforces/624B2.cpp new file mode 100644 index 00000000..e90f0348 --- /dev/null +++ b/Codeforces/624B2.cpp @@ -0,0 +1,51 @@ +#include +using namespace std; +typedef long long ll; +void swap(int *xp, int *yp) +{ + int temp = *xp; + *xp = *yp; + *yp = temp; +} +int main(){ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + ll t; cin>>t; + while(t--){ + ll n,m; cin>>n>>m; + int arr[n]; + int pos[m]; + for(int i=0;i>arr[i]; + } + ll temp; + for(int i=0;i>temp; + pos[i]=temp-1; + } + bool flag=true; + sort(pos,pos+m); + int i, j; + for (i = 0; i < n-1; i++){ + for (j = 0; j < n-i-1; j++) + if (arr[j] > arr[j+1]) { + if(! binary_search(pos,pos+m,j)){ + flag=false; + break; + } + else + swap(&arr[j], &arr[j+1]); + } + if(!flag) + break; + } + + if(flag) + cout<<"YES\n"; + else + cout<<"NO\n"; + + } + return 0; +} \ No newline at end of file diff --git a/Codeforces/624C.cpp b/Codeforces/624C.cpp new file mode 100644 index 00000000..42be36a8 --- /dev/null +++ b/Codeforces/624C.cpp @@ -0,0 +1,39 @@ +#include +using namespace std; +typedef long long ll; + +int main(){ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + ll t; cin>>t; + while(t--){ + ll n,m; + cin>>n>>m; + string s; + cin>>s; + ll temp; + ll arr[n]={0}; + for(int i=0;i>temp; + arr[0]++; + if(temp!=n) + arr[temp]--; + } + for(int i=1;i ans; + for(int i=0;i +using namespace std; +typedef long long ll; +void swap(int *xp, int *yp) +{ + int temp = *xp; + *xp = *yp; + *yp = temp; +} +int main(){ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + ll t; cin>>t; + while(t--){ + ll n,m; cin>>n>>m; + int arr[n]; + int pos[m]; + for(int i=0;i>arr[i]; + } + ll temp; + for(int i=0;i>temp; + pos[i]=temp-1; + } + bool flag=true; + sort(pos,pos+m); + int i, j; + for (i = 0; i < n-1; i++){ + for (j = 0; j < n-i-1; j++) + if (arr[j] > arr[j+1]) { + if(! binary_search(pos,pos+m,j)){ + flag=false; + break; + } + else + swap(&arr[j], &arr[j+1]); + } + if(!flag) + break; + } + + if(flag) + cout<<"YES\n"; + else + cout<<"NO\n"; + + } + return 0; +} \ No newline at end of file