Skip to content

Commit ccb4eb7

Browse files
author
Jie Feng
committed
2 parents 7ab5131 + bcbd03a commit ccb4eb7

File tree

11 files changed

+354
-7
lines changed

11 files changed

+354
-7
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<<<<<<< HEAD
21
try.cpp
3-
=======
42
codeforces/in
5-
>>>>>>> 8ea67614540813d9826e3c029eb36e4cc7116fb2
3+
codejam/in
4+
codejam/out

codeforces/.427D.cpp.swp

-20 KB
Binary file not shown.

codeforces/.427E.cpp.swp

-12 KB
Binary file not shown.

codeforces/.in.swp

-12 KB
Binary file not shown.

codejam/4

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#include <cmath>
2+
#include <set>
3+
#include <list>
4+
#include <unordered_set>
5+
#include <hash_map>
6+
#include <climits>
7+
#include <queue>
8+
#include <vector>
9+
#include <map>
10+
#include <set>
11+
#include <cstdlib>
12+
#include <fstream>
13+
#include <iomanip>
14+
#include <iostream>
15+
#include <sstream> // istringstream buffer(myString);
16+
#include <stack>
17+
#include <algorithm>
18+
#include <cstring>
19+
#include <cassert>
20+
using namespace std;
21+
#define bit(x,i) (x&(1<<i))
22+
#define lowbit(x) ((x)&((x)^((x)-1)))
23+
//#define max(a,b) (a<b?b:a)
24+
//#define abs(x) (x<0?-x:x)
25+
#define IN(i,l,r) (l<i&&i<r)
26+
#define LINR(i,l,r) (l<=i&&i<=r)
27+
#define LIN(i,l,r) (l<=i&&i<r)
28+
#define INR(i,l,r) (l<i&&i<r)
29+
#define F(i,L,R) for (int i = L; i < R; i++)
30+
#define FE(i,L,R) for (int i = L; i <= R; i++)
31+
#define FF(i,L,R) for (int i = L; i > R; i--)
32+
#define FFE(i,L,R) for (int i = L; i >= R; i--)
33+
#define char2Int(c) (c-'0')
34+
#define lastEle(vec) vec[vec.size()-1]
35+
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n))
36+
#define clr(a,x) memset(a,x,sizeof(a))
37+
#define getI(a) scanf("%d", &a)
38+
#define getII(a,b) scanf("%d%d", &a, &b)
39+
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
40+
#define getS(x) scanf("%s", x);
41+
#define SZ(x) ((int)((x).size()))
42+
#define REMAX(a,b) (a)=max((a),(b));
43+
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
44+
#define REMIN(a,b) (a)=min((a),(b));
45+
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
46+
#define ALL(t) t.begin(),t.end()
47+
#define ll long long
48+
#define ull unsigned long long
49+
#define ui unsigned int
50+
#define us unsigned short
51+
#define IOS ios_base::sync_with_stdio(0);
52+
#define pb push_back
53+
#define INF 1001001001
54+
#define PI 3.1415926535897932384626
55+
#define mp make_pair
56+
#define ll long long
57+
#define fi first
58+
#define se second
59+
#define wez(n) int (n); scanf("%d",&(n));
60+
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
61+
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
62+
inline void pisz(int n) { printf("%d\n",n); }
63+
#define TESTS wez(testow)while(testow--)
64+
#define whileZ int T; getI(T); while(T--)
65+
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
66+
#define printM(a,n,m) F(i,0,n){ F(j,0,m) cout << a[i][j] << ' '; cout << endl;}
67+
#define printV(a) printA(a,0,a.size()-1);
68+
#define printVV(a) F(i,0,a.size()) {F(j,0,a[i].size())cout << a[i][j] << ' '; cout << endl;}
69+
#define MAXN 10000
70+
#define sz(a) int((a).size())
71+
#define pb push_back
72+
#define all(c) (c).begin(),(c).end()
73+
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
74+
#define present(c,x) ((c).find(x) != (c).end())
75+
#define cpresent(c,x) (find(all(c),x) != (c).end())
76+
typedef int elem_t;
77+
typedef vector<int> vi;
78+
typedef vector<vi> vvi;
79+
typedef pair<int,int> ii;
80+
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
81+
template<typename T> ostream& operator<<(ostream &s,vector<T> t){F(i,0,SZ(t))s<<t[i]<<" ";return s; }
82+
int gcd(int a,int b){return a?gcd(b%a,a):b;}
83+
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}
84+
ll powmod(ll a,ll p,ll m){ll r=1;while(p){if(p&1)r=r*a%m;p>>=1;a=a*a%m;}return r;}
85+
const int fx[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}};
86+
string getOrder(string s){
87+
string order;
88+
F(i,0,s.length()){
89+
if (i == 0 || s[i] != s[i-1]) order.push_back(s[i]);
90+
}
91+
return order;
92+
}
93+
void getItDone(vector<string>& S, string order){
94+
}
95+
int main ( int argc, char *argv[] ) {
96+
wez(T);
97+
FE(cases,1,T){
98+
printf("Case #%d: ", cases);
99+
wez(n);
100+
vector<string> S;
101+
F(i,0,n){
102+
string s;
103+
cin >> s;
104+
S.push_back(s);
105+
getItDone(S, getOrder(S[0]));
106+
}
107+
}
108+
return EXIT_SUCCESS;
109+
}

codejam/R1B2014A

191 KB
Binary file not shown.

codejam/R1B2014A.cpp

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#include <cmath>
2+
#include <set>
3+
#include <list>
4+
#include <unordered_set>
5+
#include <hash_map>
6+
#include <climits>
7+
#include <queue>
8+
#include <vector>
9+
#include <map>
10+
#include <set>
11+
#include <cstdlib>
12+
#include <fstream>
13+
#include <iomanip>
14+
#include <iostream>
15+
#include <sstream> // istringstream buffer(myString);
16+
#include <stack>
17+
#include <algorithm>
18+
#include <cstring>
19+
#include <cassert>
20+
using namespace std;
21+
#define bit(x,i) (x&(1<<i))
22+
#define lowbit(x) ((x)&((x)^((x)-1)))
23+
//#define max(a,b) (a<b?b:a)
24+
//#define abs(x) (x<0?-x:x)
25+
#define IN(i,l,r) (l<i&&i<r)
26+
#define LINR(i,l,r) (l<=i&&i<=r)
27+
#define LIN(i,l,r) (l<=i&&i<r)
28+
#define INR(i,l,r) (l<i&&i<r)
29+
#define F(i,L,R) for (int i = L; i < R; i++)
30+
#define FE(i,L,R) for (int i = L; i <= R; i++)
31+
#define FF(i,L,R) for (int i = L; i > R; i--)
32+
#define FFE(i,L,R) for (int i = L; i >= R; i--)
33+
#define char2Int(c) (c-'0')
34+
#define lastEle(vec) vec[vec.size()-1]
35+
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n))
36+
#define clr(a,x) memset(a,x,sizeof(a))
37+
#define getI(a) scanf("%d", &a)
38+
#define getII(a,b) scanf("%d%d", &a, &b)
39+
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
40+
#define getS(x) scanf("%s", x);
41+
#define SZ(x) ((int)((x).size()))
42+
#define REMAX(a,b) (a)=max((a),(b));
43+
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
44+
#define REMIN(a,b) (a)=min((a),(b));
45+
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
46+
#define ALL(t) t.begin(),t.end()
47+
#define ll long long
48+
#define ull unsigned long long
49+
#define ui unsigned int
50+
#define us unsigned short
51+
#define IOS ios_base::sync_with_stdio(0);
52+
#define pb push_back
53+
#define INF 1001001001
54+
#define PI 3.1415926535897932384626
55+
#define mp make_pair
56+
#define ll long long
57+
#define fi first
58+
#define se second
59+
#define wez(n) int (n); scanf("%d",&(n));
60+
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
61+
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
62+
inline void pisz(int n) { printf("%d\n",n); }
63+
#define TESTS wez(testow)while(testow--)
64+
#define whileZ int T; getI(T); while(T--)
65+
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
66+
#define printM(a,n,m) F(i,0,n){ F(j,0,m) cout << a[i][j] << ' '; cout << endl;}
67+
#define printV(a) printA(a,0,a.size()-1);
68+
#define printVV(a) F(i,0,a.size()) {F(j,0,a[i].size())cout << a[i][j] << ' '; cout << endl;}
69+
#define MAXN 10000
70+
#define sz(a) int((a).size())
71+
#define pb push_back
72+
#define all(c) (c).begin(),(c).end()
73+
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
74+
#define present(c,x) ((c).find(x) != (c).end())
75+
#define cpresent(c,x) (find(all(c),x) != (c).end())
76+
typedef int elem_t;
77+
typedef vector<int> vi;
78+
typedef vector<vi> vvi;
79+
typedef pair<int,int> ii;
80+
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
81+
template<typename T> ostream& operator<<(ostream &s,vector<T> t){F(i,0,SZ(t))s<<t[i]<<" ";return s; }
82+
int gcd(int a,int b){return a?gcd(b%a,a):b;}
83+
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}
84+
ll powmod(ll a,ll p,ll m){ll r=1;while(p){if(p&1)r=r*a%m;p>>=1;a=a*a%m;}return r;}
85+
const int fx[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}};
86+
string getOrder(string s){
87+
string order;
88+
F(i,0,s.length()){
89+
if (i == 0 || s[i] != s[i-1]) order.push_back(s[i]);
90+
}
91+
return order;
92+
}
93+
vector<int> calcDis(string& s){
94+
int c = 0;
95+
vector<int> res;
96+
F(i,0,s.length()){
97+
if (i != 0 && s[i] != s[i-1])
98+
res.push_back(c), c = 0;
99+
else c++;
100+
}
101+
res.push_back(c);
102+
return res;
103+
}
104+
void getItDone(vector<string>& S, string order){
105+
F(i,1,S.size()) if (getOrder(S[i]) != order){
106+
cout << "Fegla Won" << endl;
107+
return;
108+
}
109+
vector<vector<int> > dis;
110+
F(i,0,S.size()) dis.push_back(calcDis(S[i]));
111+
int total = 0;
112+
F(i,0,order.size()){
113+
vector<int> haha;
114+
F(j,0,S.size()) haha.push_back(dis[j][i]);
115+
sort(haha.begin(), haha.end());
116+
int midDis = 0;
117+
midDis = haha[haha.size()/2];
118+
F(j,0,haha.size()){
119+
total += abs(haha[j] - midDis);
120+
}
121+
}
122+
cout << total << endl;
123+
}
124+
int main ( int argc, char *argv[] ) {
125+
wez(T);
126+
FE(cases,1,T){
127+
printf("Case #%d: ", cases);
128+
wez(n);
129+
vector<string> S;
130+
F(i,0,n){
131+
string s;
132+
cin >> s;
133+
S.push_back(s);
134+
}
135+
getItDone(S, getOrder(S[0]));
136+
}
137+
return EXIT_SUCCESS;
138+
}

codejam/R1B2014B

38.3 KB
Binary file not shown.

codejam/R1B2014B.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#include <cmath>
2+
#include <set>
3+
#include <list>
4+
#include <unordered_set>
5+
#include <hash_map>
6+
#include <climits>
7+
#include <queue>
8+
#include <vector>
9+
#include <map>
10+
#include <set>
11+
#include <cstdlib>
12+
#include <fstream>
13+
#include <iomanip>
14+
#include <iostream>
15+
#include <sstream> // istringstream buffer(myString);
16+
#include <stack>
17+
#include <algorithm>
18+
#include <cstring>
19+
#include <cassert>
20+
using namespace std;
21+
#define bit(x,i) (x&(1<<i))
22+
#define lowbit(x) ((x)&((x)^((x)-1)))
23+
//#define max(a,b) (a<b?b:a)
24+
//#define abs(x) (x<0?-x:x)
25+
#define IN(i,l,r) (l<i&&i<r)
26+
#define LINR(i,l,r) (l<=i&&i<=r)
27+
#define LIN(i,l,r) (l<=i&&i<r)
28+
#define INR(i,l,r) (l<i&&i<r)
29+
#define F(i,L,R) for (int i = L; i < R; i++)
30+
#define FE(i,L,R) for (int i = L; i <= R; i++)
31+
#define FF(i,L,R) for (int i = L; i > R; i--)
32+
#define FFE(i,L,R) for (int i = L; i >= R; i--)
33+
#define char2Int(c) (c-'0')
34+
#define lastEle(vec) vec[vec.size()-1]
35+
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n))
36+
#define clr(a,x) memset(a,x,sizeof(a))
37+
#define getI(a) scanf("%d", &a)
38+
#define getII(a,b) scanf("%d%d", &a, &b)
39+
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
40+
#define getS(x) scanf("%s", x);
41+
#define SZ(x) ((int)((x).size()))
42+
#define REMAX(a,b) (a)=max((a),(b));
43+
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
44+
#define REMIN(a,b) (a)=min((a),(b));
45+
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
46+
#define ALL(t) t.begin(),t.end()
47+
#define ll long long
48+
#define ull unsigned long long
49+
#define ui unsigned int
50+
#define us unsigned short
51+
#define IOS ios_base::sync_with_stdio(0);
52+
#define pb push_back
53+
#define INF 1001001001
54+
#define PI 3.1415926535897932384626
55+
#define mp make_pair
56+
#define ll long long
57+
#define fi first
58+
#define se second
59+
#define wez(n) int (n); scanf("%d",&(n));
60+
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
61+
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
62+
inline void pisz(int n) { printf("%d\n",n); }
63+
#define TESTS wez(testow)while(testow--)
64+
#define whileZ int T; getI(T); while(T--)
65+
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
66+
#define printM(a,n,m) F(i,0,n){ F(j,0,m) cout << a[i][j] << ' '; cout << endl;}
67+
#define printV(a) printA(a,0,a.size()-1);
68+
#define printVV(a) F(i,0,a.size()) {F(j,0,a[i].size())cout << a[i][j] << ' '; cout << endl;}
69+
#define MAXN 10000
70+
#define sz(a) int((a).size())
71+
#define pb push_back
72+
#define all(c) (c).begin(),(c).end()
73+
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
74+
#define present(c,x) ((c).find(x) != (c).end())
75+
#define cpresent(c,x) (find(all(c),x) != (c).end())
76+
#define pow2(x) (1<<x)
77+
78+
typedef int elem_t;
79+
typedef vector<int> vi;
80+
typedef vector<vi> vvi;
81+
typedef pair<int,int> ii;
82+
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
83+
template<typename T> ostream& operator<<(ostream &s,vector<T> t){F(i,0,SZ(t))s<<t[i]<<" ";return s; }
84+
int gcd(int a,int b){return a?gcd(b%a,a):b;}
85+
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}
86+
ll powmod(ll a,ll p,ll m){ll r=1;while(p){if(p&1)r=r*a%m;p>>=1;a=a*a%m;}return r;}
87+
ll solve(int a, int b, int k, int x){
88+
if(bit(a,x)){
89+
if (bit(b,x)){
90+
ll total = solve((1<<x)-1), ()
91+
return solve()
92+
}else{
93+
}
94+
}else{
95+
}
96+
}
97+
int main ( int argc, char *argv[] ) {
98+
wez(T);
99+
FE(cases,1,T){
100+
printf("Case #%d: ", cases);
101+
wez3(a,b,k);
102+
cout << solve(a,b,k,29) << endl;
103+
}
104+
return EXIT_SUCCESS;
105+
}

codejam/R1B2014B.o

46.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)