From 696ef7849ddb2bb913245c81235e494267e7adae Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Thu, 14 Dec 2023 00:03:56 +0600 Subject: [PATCH] added 1851C --- 1851C Tiles Comeback/1851C.cpp | 110 +++++++++++++++++++++++++++++++++ Readme.md | 1 + 2 files changed, 111 insertions(+) create mode 100644 1851C Tiles Comeback/1851C.cpp diff --git a/1851C Tiles Comeback/1851C.cpp b/1851C Tiles Comeback/1851C.cpp new file mode 100644 index 0000000..9531ab5 --- /dev/null +++ b/1851C Tiles Comeback/1851C.cpp @@ -0,0 +1,110 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define endl '\n' +#define ff first +#define ss second +#define pb push_back +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n,k; + cin>>n>>k; + vectorv(n); + for(int i=0; i>v[i]; + if(v[0]==v[n-1]) + { + int ct=count(all(v),v[0]); + if(ct=0; --i) + { + if(v[i]==v[n-1]) + cty++; + if(cty==k) + { + y=i; + break; + } + } + for(int i=0; i> TC; + while (TC--) + solve(); +} \ No newline at end of file diff --git a/Readme.md b/Readme.md index e95e4a1..d4f08b1 100644 --- a/Readme.md +++ b/Readme.md @@ -147,6 +147,7 @@ Feel free to check these codes out. | 1850D | Balanced Round | [Question](https://codeforces.com/problemset/problem/1850/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1850D%20Balanced%20Round/1850D.cpp) | 1851A | Escalator Conversations | [Question](https://codeforces.com/problemset/problem/1851/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1851A%20Escalator%20Conversations/1851A.cpp) | 1851B | Parity Sort | [Question](https://codeforces.com/problemset/problem/1851/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1851B%20Parity%20Sort/1851B.cpp) +| 1851C | Tiles Comeback | [Question](https://codeforces.com/problemset/problem/1851/C) | [Solution] | 1853A | Desorting | [Question](https://codeforces.com/contest/1853/problem/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1853A%20Desorting/1853A.cpp) | 1855A | Dalton the Teacher | [Question](https://codeforces.com/contest/1855/problem/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1855A%20Dalton%20the%20Teacher/1855A.cpp) | 1856B | Good Arrays | [Question](https://codeforces.com/problemset/problem/1856/B) | [Solution]