Skip to content

Commit f1c8f26

Browse files
author
coderxiang
committed
cf update
1 parent 19ebaed commit f1c8f26

File tree

3 files changed

+71
-57
lines changed

3 files changed

+71
-57
lines changed

Codeforces/156A_110.cpp

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
#include <iostream>
2-
#include <vector>
3-
#include <queue>
4-
#include <string>
5-
#include <list>
6-
#include <set>
7-
#include <map>
8-
#include <sstream>
9-
#include <cstdio>
10-
#include <algorithm>
11-
#include <cstring>
12-
#include <cmath>
13-
#include <ctime>
14-
15-
using namespace std;
16-
17-
char s[2010], u[2010];
18-
19-
int main()
20-
{
21-
int i, j, k;
22-
23-
scanf("%s",s);
24-
scanf("%s",u);
25-
26-
int e1 = strlen(s), e2 = strlen(u);
27-
28-
int ans = -1;
29-
30-
for(i = 0; i < e1; i++)
31-
{
32-
int mch = 0;
33-
for(j = 0; j < e2 && i + j < e1; j++)
34-
if(s[i+j] == u[j]) mch++;
35-
ans = max(ans, mch);
36-
}
37-
38-
for(i = 0; i < e2; i++)
39-
{
40-
int mch = 0;
41-
for(j = 0; j < e1 && i + j < e2; j++)
42-
if(u[i+j] == s[j]) mch++;
43-
ans = max(ans, mch);
44-
}
45-
46-
printf("%d\n", e2 - ans);
47-
return 0;
48-
}
49-
50-
1+
#include <iostream>
2+
#include <vector>
3+
#include <queue>
4+
#include <string>
5+
#include <list>
6+
#include <set>
7+
#include <map>
8+
#include <sstream>
9+
#include <cstdio>
10+
#include <algorithm>
11+
#include <cstring>
12+
#include <cmath>
13+
#include <ctime>
14+
15+
using namespace std;
16+
17+
char s[2010], u[2010];
18+
19+
int main()
20+
{
21+
int i, j, k;
22+
23+
scanf("%s",s);
24+
scanf("%s",u);
25+
26+
int e1 = strlen(s), e2 = strlen(u);
27+
28+
int ans = -1;
29+
30+
for(i = 0; i < e1; i++)
31+
{
32+
int mch = 0;
33+
for(j = 0; j < e2 && i + j < e1; j++)
34+
if(s[i+j] == u[j]) mch++;
35+
ans = max(ans, mch);
36+
}
37+
38+
for(i = 0; i < e2; i++)
39+
{
40+
int mch = 0;
41+
for(j = 0; j < e1 && i + j < e2; j++)
42+
if(u[i+j] == s[j]) mch++;
43+
ans = max(ans, mch);
44+
}
45+
46+
printf("%d\n", e2 - ans);
47+
return 0;
48+
}
49+
50+

Codeforces/288E_177.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ const long long md = 1000000007 ;
1212

1313
long long ten[2*N]; // 10^n mod md
1414

15-
// struct node{
16-
// int s, p;
17-
// int c;
18-
// node () {}
19-
// node (int s1, int p1, int c1) : s(s1), p(p1), c(c1) {}
20-
// };
21-
2215
struct node{
2316
long long s, p;
2417
long long c;

Codeforces/297C_180.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
n = gets.to_i;
2+
c = gets.split(' ').map(&:to_i);
3+
idx = (0..n-1).to_a.sort{|x, y|
4+
c[x] <=> c[y]
5+
}
6+
a = Array.new(n); b = Array.new(n);
7+
cnt = (n+2)/3;
8+
9+
n.times{|i|
10+
j = idx[i];
11+
if i < cnt
12+
a[j] = i; b[j] = c[j] - a[j];
13+
elsif i < 2*cnt
14+
b[j] = i; a[j] = c[j] - b[j];
15+
else
16+
b[j] = n - i - 1; a[j] = c[j] - b[j];
17+
end
18+
}
19+
puts "YES"
20+
puts a.map(&:to_s).join(' ')
21+
puts b.map(&:to_s).join(' ')

0 commit comments

Comments
 (0)