Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
ha4219 committed May 25, 2023
1 parent 135f67d commit c33f49d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 24 deletions.
21 changes: 0 additions & 21 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ int n, m;
string s[N];
bool v[21];
string tmp[N];
// int tmp[N-1];


void input() {
cin>>m>>n;
Expand All @@ -57,23 +55,6 @@ void input() {
}

bool check() {
// cout<<"***************\n";
// for(int i=0;i<m;i++) {
// int idx = tmp[i];
// cout<<s[idx]<<'\n';
// }
// cout<<"***************\n";
// for(int i=0;i<m;i++){
// int x = tmp[i];
// for(int j=0;j<m;j++) {
// int y = tmp[j];
// cout<<x<<" "<<y<<'\n';
// cout<<s[x][y]<<" "<<s[y][x]<<'\n';
// if (s[x][y] != s[y][x]) {
// return false;
// }
// }
// }
for(int i=0;i<m;i++){
for(int j=0;j<m;j++) {
if (tmp[i][j] != tmp[j][i]) {
Expand All @@ -86,7 +67,6 @@ bool check() {

void dfs(int c) {
if (c == N - 1) {
// cout<<tmp.size()<<'\n';
if (check()) {
for(int i=0;i<m;i++) {
cout<<tmp[i]<<'\n';
Expand All @@ -96,7 +76,6 @@ void dfs(int c) {
}
for(int i=0;i<n;i++) {
if(v[i]) continue;
// tmp.push_back(s[i]);
tmp[c] = s[i];
v[i] = true;
dfs(c + 1);
Expand Down
50 changes: 47 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,55 @@
input = stdin.readline

# N, W, T, K = map(int, input().split())
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
# N, M, K = map(int, input().split())
# a = list(map(int, input().split()))
N, p, q, r = map(int, input().split())
s = input().strip()
v = [0] * N

def find_idxs(p: str):
pl = len(p)
arr = []
for i in range(len(s)):
if s[i:i+pl] == p and sum([v[j] for j in range(i, i+pl)]) == 0:
arr.append(i)
i += pl
return arr

def fill_v(p, mm=maxsize):
a = find_idxs(p)
val = min(mm, len(a))
for i in a[:val]:
for j in range(i, i+len(p)):
v[j] = 1
return val

def main():

global p, q, r
res = 0
vv = fill_v('SKH')
res += vv
vv = fill_v('SK', r)
res += vv
r -= vv
vv = fill_v('KH', p)
res += vv
p -= vv
vv = fill_v('SH', q)
res += vv
q -= vv
print(res, v, p, q, r)
vv = fill_v('S', min(q, r))
res += vv
q -= vv; r -= vv
print(res, v, p, q, r)
vv = fill_v('K', min(p, r))
res += vv
p -= vv; r -= vv
vv = fill_v('H', min(p, q))
res += vv
p -= vv; q -= vv
print(res, v, p, q, r)
return


Expand Down

0 comments on commit c33f49d

Please sign in to comment.