Skip to content

Commit c3e391e

Browse files
author
Jie Feng
committed
haha
1 parent ad4c6c4 commit c3e391e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2330
-1042
lines changed

codechef/Sereja-and-Game

199 KB
Binary file not shown.

codechef/Sereja-and-Game.cpp

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ using namespace std;
2626
#define LINR(i,l,r) (l<=i&&i<=r)
2727
#define LIN(i,l,r) (l<=i&&i<r)
2828
#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--)
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--)
3333
#define char2Int(c) (c-'0')
3434
#define lastEle(vec) vec[vec.size()-1]
3535
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n))
@@ -73,18 +73,14 @@ inline void pisz(int n) { printf("%d\n",n); }
7373
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
7474
#define present(c,x) ((c).find(x) != (c).end())
7575
#define cpresent(c,x) (find(all(c),x) != (c).end())
76-
#define tiny ((double) 1e-15)
76+
#define tiny ((double) 1e-30)
7777
#define close(x,y) (abs(x-y)<tiny)
7878
typedef int elem_t;
7979
typedef vector<int> vi;
8080
typedef vector<vi> vvi;
8181
typedef pair<int,int> ii;
8282
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
8383
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-
const int fx[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}};
8884
vector<char> divd;
8985
map<vector<char>, double> r_pro;
9086
double calc3(int total, bool win){
@@ -100,7 +96,7 @@ double calc3(int total, bool win){
10096
char mac = divd[8];
10197
double pro = 0;
10298
F(i,0,8)if (divd[i] > 0){
103-
double portion = 1.0 * divd[i] / total;
99+
double portion = (double)1.0 * divd[i];
104100
if (mac & i){
105101
divd[i]--;
106102
divd[8] = mac & i;
@@ -111,6 +107,7 @@ double calc3(int total, bool win){
111107
if (!win) pro += portion;
112108
}
113109
}
110+
pro /= total;
114111
if (win) r_pro[divd] = pro;
115112
else r_pro[divd] = 1-pro;
116113
return pro;
@@ -154,46 +151,8 @@ int main ( int argc, char *argv[] ) {
154151
double oppoLose = calc3(n-1, false);
155152
if (close(oppoLose, 1.0)) sureWin = true;
156153
win += oppoLose;
157-
}
154+
}
158155
printf("%d %.4lf\n", sureWin, win/n);
159156
}
160157
return EXIT_SUCCESS;
161158
}
162-
163-
/* double F1[101][101][2];
164-
* double F2[101][101][101][2];
165-
* F1[0][0][0] = 1;
166-
* F1[0][0][1] = 0;
167-
* FE(i,0,100) FE(j,0,100) if (i+j != 0 && i+j <= 100){
168-
* F1[i][j][0] = F1[i][j][1] = 0;
169-
* double total = i + j;
170-
* if (i == 0){
171-
* F1[i][j][1] = 0;
172-
* F1[i][j][0] = 1;
173-
* }else{
174-
* F1[i][j][1] = (i/total) * F1[i-1][j][0];
175-
* F1[i][j][0] = (i/total) * F1[i-1][j][1];
176-
* if (j > 0){
177-
* F1[i][j][0] += (j/total);
178-
* }
179-
* }
180-
* }
181-
* F2[0][0][0][0] = 1;
182-
* F2[0][0][0][1] = 0;
183-
* FE(ij,0,100) FE(i,0,100) FE(j,0,100) if (ij+i+j != 0 && ij+i+j <= 100){
184-
* F2[ij][i][j][0] = F2[ij][i][j][1] = 0;
185-
* double total = i+j+ij;
186-
* if (ij > 0){
187-
* F2[ij][i][j][1] += (ij/total) * F2[ij-1][i][j][0];
188-
* F2[ij][i][j][0] += (ij/total) * F2[ij-1][i][j][1];
189-
* }
190-
* if (i > 0){
191-
* F2[ij][i][j][1] += (i/total) * F1[i-1][j][0];
192-
* F2[ij][i][j][0] += (i/total) * F1[i-1][j][1];
193-
* }
194-
* if (j > 0){
195-
* F2[ij][i][j][1] += (j/total) * F1[j-1][i][0];
196-
* F2[ij][i][j][0] += (j/total) * F1[j-1][i][1];
197-
* }
198-
* }
199-
*/

codechef/Sereja-and-Game.o

372 KB
Binary file not shown.

codechef/in

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
<<<<<<< HEAD
21
5
3-
6
4-
2 3 5 7 11 13
5-
5
6-
6 10 15 22 28
7-
5
8-
2 4 8 16 32
9-
4
10-
2 4 8 16
11-
4
12-
1 2 3 4
13-
13
14-
100 100 100 100 100 100 100 100 100 100 100 100 100
15-
=======
162
3
17-
4 1
18-
1 1
19-
2 1
20-
3 1
21-
4 1
22-
2 2
23-
1 4
24-
2 7
25-
2 1
26-
1 4
27-
2 7
28-
>>>>>>> d82c2ca4e2db4a6ee78544dff90d4c24375575cc
3+
2 3 6
4+
3
5+
2 3 12
6+
3
7+
2 6 12
8+
3
9+
3 6 12
10+
4
11+
2 3 6 12

codechef/temp.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -69,44 +69,8 @@ void deleteOne(){
6969
}
7070
}
7171
int main ( int argc, char *argv[] ) {
72-
int T;
73-
getI(T);
74-
while(T--){
75-
getII(n,m);
76-
FE(i,1,n) link[i].clear();
77-
// clear begin
78-
clr(vis,0);
79-
clr(a,0);
80-
clr(in,0);
81-
// clear end
82-
int u, v;
83-
F(i,0,m){
84-
getII(u,v);
85-
if (!a[u][v]){
86-
in[u]++;
87-
in[v]++;
88-
a[u][v] = a[v][u] = 1;
89-
link[u].push_back(v);
90-
link[v].push_back(u);
91-
}
92-
}
93-
if (n % 2){
94-
printf("NO\n");
95-
continue;
96-
}
97-
deleteOne();
98-
bool ok = true;
99-
FE(i,1,n) if(!vis[i]){
100-
total = 0;
101-
visit(i);
102-
if (total % 2 == 1){
103-
ok = false;
104-
printf("NO\n");
105-
break;
106-
}
107-
}
108-
if (ok) printf("YES\n");
109-
}
72+
printf("%.60f\n", 1.0/911) ;
73+
printf("%.60lf\n", (double)1.0/911) ;
11074
return EXIT_SUCCESS;
11175
}
11276

codechef/temp.o

171 KB
Binary file not shown.

codeforces/1

43.3 KB
Binary file not shown.

codeforces/429A

58.1 KB
Binary file not shown.

codeforces/429A.cpp

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#include <cmath>
2+
#include <list>
3+
#include <climits>
4+
#include <queue>
5+
#include <vector>
6+
#include <map>
7+
#include <set>
8+
#include <cstdlib>
9+
#include <fstream>
10+
#include <iomanip>
11+
#include <iostream>
12+
#include <sstream> // istringstream buffer(myString);
13+
#include <stack>
14+
#include <algorithm>
15+
#include <cstring>
16+
#include <cassert>
17+
using namespace std;
18+
#define bit(x,i) (x&(1<<i))
19+
#define lowbit(x) ((x)&((x)^((x)-1)))
20+
//#define max(a,b) (a<b?b:a)
21+
//#define abs(x) (x<0?-x:x)
22+
#define IN(i,l,r) (l<i&&i<r)
23+
#define LINR(i,l,r) (l<=i&&i<=r)
24+
#define LIN(i,l,r) (l<=i&&i<r)
25+
#define INR(i,l,r) (l<i&&i<r)
26+
#define F(i,L,R) for (int i = L; i < R; i++)
27+
#define FE(i,L,R) for (int i = L; i <= R; i++)
28+
#define FF(i,L,R) for (int i = L; i > R; i--)
29+
#define FFE(i,L,R) for (int i = L; i >= R; i--)
30+
#define char2Int(c) (c-'0')
31+
#define lastEle(vec) vec[vec.size()-1]
32+
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n))
33+
#define clr(a,x) memset(a,x,sizeof(a))
34+
#define getI(a) scanf("%d", &a)
35+
#define getII(a,b) scanf("%d%d", &a, &b)
36+
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
37+
#define getS(x) scanf("%s", x);
38+
#define SZ(x) ((int)((x).size()))
39+
#define REMAX(a,b) (a)=max((a),(b));
40+
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
41+
#define REMIN(a,b) (a)=min((a),(b));
42+
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
43+
#define ALL(t) t.begin(),t.end()
44+
#define ll long long
45+
#define ull unsigned long long
46+
#define ui unsigned int
47+
#define us unsigned short
48+
#define IOS ios_base::sync_with_stdio(0);
49+
#define pb push_back
50+
#define INF 1001001001
51+
#define PI 3.1415926535897932384626
52+
#define mp make_pair
53+
#define ll long long
54+
#define fi first
55+
#define se second
56+
#define root(x) ((int)sqrt((double)x))
57+
#define wez(n) int (n); scanf("%d",&(n));
58+
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
59+
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
60+
inline void pisz(int n) { printf("%d\n",n); }
61+
#define TESTS wez(testow)while(testow--)
62+
#define whileZ int T; getI(T); while(T--)
63+
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
64+
#define printM(a,n,m) F(i,0,n){ F(j,0,m) cout << a[i][j] << ' '; cout << endl;}
65+
#define printV(a) printA(a,0,(int)a.size()-1);
66+
#define printVV(a) F(i,0,a.size()) {F(j,0,a[i].size())cout << a[i][j] << ' '; cout << endl;}
67+
#define MAXN 10000
68+
#define sz(a) int((a).size())
69+
#define pb push_back
70+
#define all(c) (c).begin(),(c).end()
71+
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
72+
#define present(c,x) ((c).find(x) != (c).end())
73+
#define cpresent(c,x) (find(all(c),x) != (c).end())
74+
#define tiny (double)1e-13
75+
#define close(x,y) (abs(x-y)<tiny)
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+
#define maxn (int)(1e5+10)
86+
int n;
87+
vector<int> res;
88+
vector<int> edges[maxn];
89+
bool init[maxn], goal[maxn];
90+
int total = 0;
91+
int countt(int u, int fa, int level, int odd, int even){
92+
if (level&1){
93+
if ((odd&1) ^ (init[u] != goal[u])){
94+
total++;
95+
res.push_back(u);
96+
odd++;
97+
}
98+
}else{
99+
if ((even&1) ^ (init[u] != goal[u])){
100+
total++;
101+
res.push_back(u);
102+
even++;
103+
}
104+
}
105+
F(i,0,edges[u].size()){
106+
int v = edges[u][i];
107+
if (v != fa){
108+
countt(v, u, level+1, odd, even);
109+
}
110+
}
111+
}
112+
int main ( int argc, char *argv[] ) {
113+
getI(n);
114+
F(i,0,n-1){
115+
wez2(x,y);
116+
edges[x].push_back(y);
117+
edges[y].push_back(x);
118+
}
119+
FE(i,1,n) cin >> init[i];
120+
FE(i,1,n) cin >> goal[i];
121+
countt(1, 0, 0, 0, 0);
122+
cout << total << endl;
123+
F(i,0,res.size()) cout << res[i] << endl;
124+
return EXIT_SUCCESS;
125+
}

codeforces/429A.o

120 KB
Binary file not shown.

0 commit comments

Comments
 (0)