Skip to content

Commit

Permalink
struggled on test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ynng committed Jun 12, 2021
1 parent 0650425 commit 15fdf57
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: oly21practice47","url":"c:\\My Files\\GitHub\\Practise\\Olympiad Practise\\week last\\oly21practice47.cpp","tests":[{"id":1623525100682,"input":"world\nword","output":"Yes"},{"id":1623525106799,"input":"snekee\nsnuke","output":"No"},{"id":1623525110835,"input":"hello\nhello","output":"Yes"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\My Files\\GitHub\\Practise\\Olympiad Practise\\week last\\oly21practice47.cpp","group":"local","local":true}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: oly21practice55","url":"c:\\My Files\\GitHub\\Practise\\Olympiad Practise\\week last\\oly21practice55.cpp","tests":[{"id":1623525803447,"input":"banana","output":"c"},{"id":1623525809009,"input":"abcdefghijklmnopqrstuvwxyz","output":"aa"},{"id":1623526010495,"input":"aabbccddeeffgghhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\My Files\\GitHub\\Practise\\Olympiad Practise\\week last\\oly21practice55.cpp","group":"local","local":true}
Binary file added Olympiad Practise/week last/oly21practice47.bin
Binary file not shown.
57 changes: 57 additions & 0 deletions Olympiad Practise/week last/oly21practice47.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define INF 0x3f3f3f3f // for int
#define LL_INF 0x3f3f3f3f3f3f3f3f // for ll
#define sz(x) (int)(x).size()
#define ms(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const int MOD = 1000000007, MX = 100000 + 5;
string A, B;
int main()
{
cin >> A >> B;
if (!(A.size() == B.size() || A.size() - 1 == B.size()))
{
printf("No\n");
return 0;
}

bool err = false;
for (int i = 0; i < B.size(); i++)
{
if (A.at(i + err) != B.at(i))
if (!err)
err = true;
else
{
printf("No\n");
return 0;
}
}

printf("Yes\n");
return 0;
}
Binary file added Olympiad Practise/week last/oly21practice55.bin
Binary file not shown.
85 changes: 85 additions & 0 deletions Olympiad Practise/week last/oly21practice55.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define INF 0x3f3f3f3f // for int
#define LL_INF 0x3f3f3f3f3f3f3f3f // for ll
#define sz(x) (int)(x).size()
#define ms(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const int MOD = 1000000007, MX = 500 + 5;

char str[MX];
vi revmap[256];

bool freq[256];
int freqc;

int main()
{
scanf("%s", str);
int slen = strlen(str);
for (int i = 0; i < slen; i++)
{
char c = str[i];
revmap[c].push_back(i);
}

int len = 1;
for (int c = 'a'; c <= 'z'; c++)
{
if(revmap[c].empty()){
printf("%c\n", c);
return 0;
}
}

for (int c = 'a'; c <= 'z'; c++){
freqc = 0;
for (int c2 = 'a'; c2 <= 'z'; c2++)
freq[c2] = 0;

for(int idx : revmap[c]){
if(idx == slen-1)continue;
if(!freq[str[idx+1]])
freqc++;
freq[str[idx+1]] = true;
if(freqc==26)break;
}
if(freqc==26)continue;
printf("%c", c);
for (int c2 = 'a'; c2 <= 'z'; c2++)
{
if(!freq[c2]){
printf("%c", c2);
break;
}
}
break;
}

printf("\n");

return 0;
}

0 comments on commit 15fdf57

Please sign in to comment.