add a few including gcj 2013 first round · algorithmsCode/algorithm@b9c6ee4 · GitHub
Skip to content

Commit b9c6ee4

Browse files
committed
add a few including gcj 2013 first round
1 parent 54c8cc4 commit b9c6ee4

19 files changed

Lines changed: 1846 additions & 0 deletions

File tree

cf/113/E2.cpp

Lines changed: 89 additions & 0 deletions

cf/113/a.out

-3.32 KB
Binary file not shown.

cf/119/A.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
#include <set>
3+
#include <vector>
4+
5+
using namespace std;
6+
7+
const int MAXN = 5000;
8+
const int INF = 99999999;
9+
int dp[MAXN];
10+
int N;
11+
12+
13+
int main(){
14+
cin>>N;
15+
16+
set<int> d;
17+
for(int i=0; i<3; i++){
18+
int t;
19+
cin>>t;
20+
d.insert(t);
21+
}
22+
23+
for(int i=0; i<MAXN; i++)dp[i] = -INF;
24+
dp[0] = 0;
25+
26+
for(int i=0; i<=N; i++){
27+
if(dp[i]!=-INF){
28+
vector<int> tmp(d.begin(), d.end());
29+
for(int j=0; j<tmp.size(); j++){
30+
31+
for(int j=0; j<tmp.size(); j++){
32+
if(i+tmp[j]<=N){
33+
dp[i+tmp[j]] = max( dp[i]+1, dp[i+tmp[j]]);
34+
}
35+
}
36+
}
37+
}
38+
39+
}
40+
cout<<dp[N]<<endl;
41+
return 0;
42+
}
43+

cf/119/a.out

43.6 KB
Binary file not shown.

cf/134/B.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <iostream>
2+
#include <queue>
3+
#include <vector>
4+
5+
using namespace std;
6+
7+
8+
int N, M;
9+
const int MAXN = 10001;
10+
int data[MAXN];
11+
12+
13+
int main(){
14+
cin>>N>>M;
15+
16+
priority_queue<int> max_Q;
17+
priority_queue<int, vector<int> , greater<int> > min_Q;
18+
19+
for(int i=0; i<M; i++){
20+
int t;
21+
cin>>t;
22+
max_Q.push(t);
23+
min_Q.push(t);
24+
}
25+
int cnt = N;
26+
int max_ans = 0;
27+
int min_ans = 0;
28+
while(cnt--){
29+
int cur = max_Q.top();
30+
max_Q.pop();
31+
max_ans += cur;
32+
cur -= 1;
33+
if(cur>0){
34+
max_Q.push(cur);
35+
}
36+
}
37+
38+
cnt = N;
39+
while(cnt--){
40+
int cur = min_Q.top();
41+
min_Q.pop();
42+
min_ans += cur;
43+
cur -= 1;
44+
if(cur>0){
45+
min_Q.push(cur);
46+
}
47+
}
48+
cout<<max_ans<<" "<<min_ans<<endl;
49+
50+
return 0;
51+
}
52+

cf/134/a.out

46.5 KB
Binary file not shown.

cf/169/B.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <cstring>
4+
5+
using namespace std;
6+
7+
string S;
8+
9+
bool dp[1<<26];
10+
int cnt[26];
11+
const int INF = 99999999;
12+
13+
int get_ans(int state){
14+
if(dp[state]!=INF){
15+
return dp[state];
16+
}
17+
int num = __builtin_popcount(state);
18+
if(num== 0 || num == 1){
19+
return 1;
20+
}
21+
int ok = 0;
22+
for(int i=0; i<26; i++){
23+
if( ((state>>i)&1)==1 ){
24+
int ns = (~(1<<i))&state;
25+
int ans = get_ans(ns);
26+
if(ans==0){
27+
ok = 1;
28+
}
29+
}
30+
}
31+
dp[state] = ok;
32+
return ok;
33+
}
34+
35+
36+
void work(){
37+
memset(cnt,0,sizeof(cnt));
38+
for(int i=0; i<S.size(); i++){
39+
cnt[ S[i]-'a' ] += 1;
40+
}
41+
int start = 0;
42+
for(int i=0; i<26; i++){
43+
if(cnt[i]%2==1){
44+
start |= (1<<i);
45+
}
46+
}
47+
for(int i=0; i<(1<<26); i++){
48+
dp[i] = INF;
49+
}
50+
int ans = get_ans(start);
51+
if(ans==1){
52+
cout<<"First"<<endl;
53+
}
54+
else{
55+
cout<<"Second"<<endl;
56+
}
57+
58+
59+
}
60+
61+
62+
63+
int main(){
64+
cin>>S;
65+
work();
66+
67+
return 0;
68+
}
69+

cf/169/C.cpp

Lines changed: 120 additions & 0 deletions

cf/169/a.out

22.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)