Skip to content

Commit 8ea6761

Browse files
author
Jie Feng
committed
haha
2 parents eeea7e0 + 4a54b37 commit 8ea6761

File tree

15 files changed

+458
-24
lines changed

15 files changed

+458
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
codeforces/in

codeforces/.makefile.swp

-12 KB
Binary file not shown.

codeforces/418A

31.4 KB
Binary file not shown.

codeforces/418A.cpp

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

codeforces/418A.o

41.5 KB
Binary file not shown.

codeforces/418B

90.7 KB
Binary file not shown.

codeforces/418B.cpp

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#include <cmath>
2+
#include <set>
3+
#include <list>
4+
#include <climits>
5+
#include <queue>
6+
#include <vector>
7+
#include <map>
8+
#include <set>
9+
#include <cstdlib>
10+
#include <fstream>
11+
#include <iomanip>
12+
#include <iostream>
13+
#include <sstream> // istringstream buffer(myString);
14+
#include <stack>
15+
#include <algorithm>
16+
#include <cstring>
17+
#include <cassert>
18+
using namespace std;
19+
#define bit(x,i) (x&(1<<i))
20+
#define lowbit(x) ((x)&((x)^((x)-1)))
21+
//#define max(a,b) (a<b?b:a)
22+
//#define abs(x) (x<0?-x:x)
23+
#define IN(i,l,r) (l<i&&i<r)
24+
#define LINR(i,l,r) (l<=i&&i<=r)
25+
#define LIN(i,l,r) (l<=i&&i<r)
26+
#define INR(i,l,r) (l<i&&i<r)
27+
#define F(i,L,R) for (int i = L; i < R; i++)
28+
#define FE(i,L,R) for (int i = L; i <= R; i++)
29+
#define FF(i,L,R) for (int i = L; i > R; i--)
30+
#define FFE(i,L,R) for (int i = L; i >= R; i--)
31+
#define char2Int(c) (c-'0')
32+
#define lastEle(vec) vec[vec.size()-1]
33+
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n))
34+
#define clr(a,x) memset(a,x,sizeof(a))
35+
#define getI(a) scanf("%d", &a)
36+
#define getII(a,b) scanf("%d%d", &a, &b)
37+
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
38+
#define getS(x) scanf("%s", x);
39+
#define SZ(x) ((int)((x).size()))
40+
#define REMAX(a,b) (a)=max((a),(b));
41+
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
42+
#define REMIN(a,b) (a)=min((a),(b));
43+
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
44+
#define ALL(t) t.begin(),t.end()
45+
#define ll long long
46+
#define ull unsigned long long
47+
#define ui unsigned int
48+
#define us unsigned short
49+
#define IOS ios_base::sync_with_stdio(0);
50+
#define pb push_back
51+
#define INF 1001001001
52+
#define PI 3.1415926535897932384626
53+
#define mp make_pair
54+
#define ll long long
55+
#define fi first
56+
#define se second
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,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+
typedef int elem_t;
75+
typedef vector<int> vi;
76+
typedef vector<vi> vvi;
77+
typedef pair<int,int> ii;
78+
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
79+
template<typename T> ostream& operator<<(ostream &s,vector<T> t){F(i,0,SZ(t))s<<t[i]<<" ";return s; }
80+
int gcd(int a,int b){return a?gcd(b%a,a):b;}
81+
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}
82+
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;}
83+
const int fx[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}};
84+
struct node{
85+
ll money, monitor, solve;
86+
}a[100];
87+
ll f[2][1 << 20];
88+
ll n,k,b;
89+
ll solve(ll M){
90+
clr(f, -1);
91+
ll KK = 1 << k;
92+
f[0][0] = f[1][0] = 0;
93+
for (ll i = 0; i < n; i++) if (a[i].monitor <= M){
94+
for (ll s = 0; s < KK; s++) if (f[0][s] != -1){
95+
ll t = s | a[i].solve;
96+
if (f[1][t] == -1 || f[0][s] + a[i].money < f[1][t])
97+
f[1][t] = a[i].money + f[0][s];
98+
}
99+
memcpy(f[0], f[1], sizeof(f[0]));
100+
}
101+
if (f[0][KK-1] == -1) return LONG_LONG_MAX;
102+
else return f[0][KK-1] + b * M;
103+
}
104+
int main( int argc, char *argv[] ) {
105+
cin >> n >> k >> b;
106+
for (ll i = 0; i < n; i++){
107+
ll num;
108+
cin >> a[i].money >> a[i].monitor >> num;
109+
a[i].solve = 0;
110+
F(j,0,num){
111+
wez(x);
112+
x--;
113+
a[i].solve |= 1 << x;
114+
}
115+
}
116+
ll minM = LONG_LONG_MAX;
117+
set<ll> visited;
118+
for (ll i = 0; i < n; i++) if (visited.find(a[i].monitor) == visited.end()){
119+
visited.insert(a[i].monitor);
120+
minM = min(minM, solve(a[i].monitor));
121+
}
122+
if (minM == LONG_LONG_MAX) cout << -1 << endl;
123+
else cout << minM << endl;
124+
return EXIT_SUCCESS;
125+
}

codeforces/418B.o

146 KB
Binary file not shown.

codeforces/418C

81 KB
Binary file not shown.

codeforces/418C.cpp

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#include <cmath>
2+
#include <set>
3+
#include <list>
4+
#include <climits>
5+
#include <queue>
6+
#include <vector>
7+
#include <map>
8+
#include <set>
9+
#include <cstdlib>
10+
#include <fstream>
11+
#include <iomanip>
12+
#include <iostream>
13+
#include <sstream> // istringstream buffer(myString);
14+
#include <stack>
15+
#include <algorithm>
16+
#include <cstring>
17+
#include <cassert>
18+
using namespace std;
19+
#define bit(x,i) (x&(1<<i))
20+
#define lowbit(x) ((x)&((x)^((x)-1)))
21+
//#define max(a,b) (a<b?b:a)
22+
//#define abs(x) (x<0?-x:x)
23+
#define IN(i,l,r) (l<i&&i<r)
24+
#define LINR(i,l,r) (l<=i&&i<=r)
25+
#define LIN(i,l,r) (l<=i&&i<r)
26+
#define INR(i,l,r) (l<i&&i<r)
27+
#define F(i,L,R) for (int i = L; i < R; i++)
28+
#define FE(i,L,R) for (int i = L; i <= R; i++)
29+
#define FF(i,L,R) for (int i = L; i > R; i--)
30+
#define FFE(i,L,R) for (int i = L; i >= R; i--)
31+
#define char2Int(c) (c-'0')
32+
#define lastEle(vec) vec[vec.size()-1]
33+
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n))
34+
#define clr(a,x) memset(a,x,sizeof(a))
35+
#define getI(a) scanf("%d", &a)
36+
#define getII(a,b) scanf("%d%d", &a, &b)
37+
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
38+
#define getS(x) scanf("%s", x);
39+
#define SZ(x) ((int)((x).size()))
40+
#define REMAX(a,b) (a)=max((a),(b));
41+
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
42+
#define REMIN(a,b) (a)=min((a),(b));
43+
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
44+
#define ALL(t) t.begin(),t.end()
45+
#define ll long long
46+
#define ull unsigned long long
47+
#define ui unsigned int
48+
#define us unsigned short
49+
#define IOS ios_base::sync_with_stdio(0);
50+
#define pb push_back
51+
#define INF 1001001001
52+
#define PI 3.1415926535897932384626
53+
#define mp make_pair
54+
#define ll long long
55+
#define fi first
56+
#define se second
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,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+
typedef int elem_t;
75+
typedef vector<int> vi;
76+
typedef vector<vi> vvi;
77+
typedef pair<int,int> ii;
78+
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
79+
template<typename T> ostream& operator<<(ostream &s,vector<T> t){F(i,0,SZ(t))s<<t[i]<<" ";return s; }
80+
int gcd(int a,int b){return a?gcd(b%a,a):b;}
81+
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}
82+
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;}
83+
const int fx[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}};
84+
#define N 10000
85+
bool vis[N+1];
86+
vector<int> a[N+1];
87+
int sqrt(int x, int y){
88+
return sqrt(x*x+y*y);
89+
}
90+
bool searchPath(vector<int>&path, int lev, int x){
91+
if (lev == path.size()) return true;
92+
for (int i = 0; i < a[x].size(); i++){
93+
int y = a[x][i];
94+
path[lev] = a[x][i];
95+
if (searchPath(path, lev+1, sqrt(x,y))) return true;
96+
}
97+
return false;
98+
}
99+
int main ( int argc, char *argv[] ) {
100+
int n, m;
101+
cin >> n >> m;
102+
FE(i,1,10000)
103+
FE(j,i+1,10000){
104+
int x = sqrt(i*i+j*j);
105+
if (x*x == i*i + j*j){
106+
a[i].push_back(j);
107+
a[j].push_back(i);
108+
}
109+
}
110+
vector<int> path1(n), path2(m);
111+
112+
path1[0] = 3;
113+
searchPath(path1, 1, 3);
114+
path2[0] = 3;
115+
searchPath(path2, 1, 3);
116+
printV(path1);
117+
printV(path2);
118+
return EXIT_SUCCESS;
119+
}

0 commit comments

Comments
 (0)