-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
aajjbb
committed
Sep 17, 2015
1 parent
4c45cb1
commit 9989dc1
Showing
12 changed files
with
400 additions
and
1,000,107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <bits/stdc++.h> | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } | ||
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } | ||
int in() { int x; scanf("%d", &x); return x; } | ||
|
||
using namespace std; | ||
|
||
#ifdef ONLINE_JUDGE | ||
#define debug(args...) | ||
#else | ||
#define debug(args...) fprintf(stderr,args) | ||
#endif | ||
|
||
typedef long long Int; | ||
typedef unsigned long long uInt; | ||
typedef unsigned uint; | ||
|
||
const int MAXN = 1100; | ||
|
||
int N; | ||
int A[MAXN][MAXN]; | ||
bool used[MAXN]; | ||
|
||
int main(void) { | ||
cin >> N; | ||
|
||
for (int i = 2; i <= 2 * N; i++) { | ||
for (int j = 1; j < i; j++) { | ||
cin >> A[i][j]; | ||
A[j][i] = A[i][j]; | ||
} | ||
} | ||
|
||
vector<int> M_ans(2 * N + 1, 0); | ||
|
||
for (int a = 1; a <= N; a++) { | ||
int best = 0; | ||
int ia = 0, ib = 0; | ||
|
||
for (int i = 1; i <= 2 * N; i++) { | ||
if (used[i]) continue; | ||
for (int j = 1; j <= 2 * N; j++) { | ||
if (i != j && used[j]) continue; | ||
|
||
if (A[i][j] > best) { | ||
best = A[i][j]; | ||
ia = i; | ||
ib = j; | ||
} | ||
} | ||
} | ||
|
||
used[ia] = used[ib] = true; | ||
M_ans[ia] = ib; | ||
M_ans[ib] = ia; | ||
} | ||
|
||
for (int i = 1; i <= 2 * N; i++) { | ||
cout << M_ans[i] << " "; | ||
} | ||
cout << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <bits/stdc++.h> | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } | ||
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } | ||
int in() { int x; scanf("%d", &x); return x; } | ||
|
||
using namespace std; | ||
|
||
#ifdef ONLINE_JUDGE | ||
#define debug(args...) | ||
#else | ||
#define debug(args...) fprintf(stderr,args) | ||
#endif | ||
|
||
typedef long long Int; | ||
typedef unsigned long long uInt; | ||
typedef unsigned uint; | ||
|
||
const int MAXN = 200002; | ||
|
||
int N, K, X; | ||
Int P[MAXN]; | ||
Int dp[MAXN][20]; | ||
|
||
Int func(int pos, int used) { | ||
if (pos == N) { | ||
return 0; | ||
} else { | ||
Int& ans = dp[pos][used]; | ||
|
||
if (ans == -1) { | ||
ans = P[pos] | func(pos + 1, used); | ||
|
||
Int curr = P[pos]; | ||
|
||
for (int i = 1; i <= used; i++) { | ||
curr *= X; | ||
chmax(ans, curr | func(pos + 1, used - i)); | ||
} | ||
} | ||
|
||
return ans; | ||
} | ||
} | ||
|
||
int main(void) { | ||
cin >> N >> K >> X; | ||
|
||
for (int i = 0; i < N; i++) { | ||
cin >> P[i]; | ||
} | ||
|
||
memset(dp, -1, sizeof(dp)); | ||
|
||
cout << func(0, K) << "\n"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <bits/stdc++.h> | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } | ||
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } | ||
int in() { int x; scanf("%d", &x); return x; } | ||
|
||
using namespace std; | ||
|
||
#ifdef ONLINE_JUDGE | ||
#define debug(args...) | ||
#else | ||
#define debug(args...) fprintf(stderr,args) | ||
#endif | ||
|
||
typedef long long Int; | ||
typedef unsigned long long uInt; | ||
typedef unsigned uint; | ||
|
||
int N; | ||
|
||
int main(void) { | ||
cin >> N; | ||
cout << __builtin_popcount(N) << endl; | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
7 2 | ||
3 1 2 2 3 3 7 | ||
1 7 | ||
3 4 | ||
3 2 6 | ||
724148075 828984987 810015532 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,88 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <sstream> | ||
#include <vector> | ||
#include <set> | ||
#include <map> | ||
#include <list> | ||
#include <queue> | ||
#include <stack> | ||
#include <memory> | ||
#include <iomanip> | ||
#include <functional> | ||
#include <new> | ||
#include <algorithm> | ||
#include <cmath> | ||
#include <cstring> | ||
#include <cstdlib> | ||
#include <cstdio> | ||
#include <climits> | ||
#include <cctype> | ||
#include <ctime> | ||
|
||
#define REP(i, n) for(int (i) = 0; i < n; i++) | ||
#define FOR(i, a, n) for(int (i) = a; i < n; i++) | ||
#define FORR(i, a, n) for(int (i) = a; i <= n; i++) | ||
#define for_each(q, s) for(typeof(s.begin()) q=s.begin(); q!=s.end(); q++) | ||
#define sz(n) n.size() | ||
#define pb(n) push_back(n) | ||
#define all(n) n.begin(), n.end() | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
using namespace std; | ||
|
||
typedef long long ll; | ||
typedef long double ld; | ||
|
||
const int MAXN = 25; | ||
int T, N, M; | ||
char c[MAXN][MAXN]; | ||
|
||
int dx[8] = {0, 0, 1, -1, 1, -1, 1, -1}; | ||
int dy[8] = {1, -1, 0, 0, 1, -1, -1, 1}; | ||
|
||
#include <bits/stdc++.h> | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } | ||
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } | ||
int in() { int x; scanf("%d", &x); return x; } | ||
|
||
using namespace std; | ||
|
||
#ifdef ONLINE_JUDGE | ||
#define debug(args...) | ||
#else | ||
#define debug(args...) fprintf(stderr,args) | ||
#endif | ||
|
||
typedef long long Int; | ||
typedef unsigned long long uInt; | ||
typedef unsigned uint; | ||
|
||
const int MAXN = 60; | ||
|
||
int T, N, M; | ||
string S[MAXN]; | ||
int cnt[MAXN][MAXN]; | ||
|
||
int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0}; | ||
int dy[8] = {1, 0, -1, -1, -1, 0, 1, 1}; | ||
|
||
int main(void) { | ||
freopen("i.in", "r", stdin); | ||
scanf("%d", &T); | ||
for(int x = 0; x < T; x++) { | ||
scanf("%d%d", &N, &M); | ||
REP(i, N) { | ||
scanf("%s ", c[i]); | ||
} | ||
bool ok = true; | ||
REP(i, N) REP(j, M) { | ||
if (!ok) break; | ||
if(c[i][j] != 'F') { | ||
int num = c[i][j] - '0', check = 0; | ||
REP(k, 8) { | ||
int nx = i + dx[k], ny = j + dy[k]; | ||
if(nx >= 0 && ny >= 0 && nx < N && ny < M && c[nx][ny] == 'F') { | ||
check += 1; | ||
} | ||
} | ||
if(num != check) ok = false; | ||
} | ||
} | ||
if(ok) printf("Well done Clark!"); | ||
else printf("Please sweep the mine again!"); | ||
if (x != T - 1) printf("\n"); | ||
} | ||
return 0; | ||
} | ||
cin >> T; | ||
|
||
while (T--) { | ||
cin >> N >> M; | ||
|
||
memset(cnt, 0, sizeof(cnt)); | ||
|
||
for (int i = 0; i < N; i++) { | ||
cin >> S[i]; | ||
|
||
for (int j = 0; j < M; j++) { | ||
if (S[i][j] != 'F') { | ||
cnt[i][j] = (S[i][j] - '0'); | ||
} | ||
} | ||
} | ||
|
||
for (int i = 0; i < N; i++) { | ||
for (int j = 0; j < M; j++) { | ||
if (S[i][j] == 'F') { | ||
for (int k = 0; k < 8; k++) { | ||
int di = i + dx[k]; | ||
int dj = j + dy[k]; | ||
|
||
if (di >= 0 && dj >= 0 && di < N && dj < M) { | ||
cnt[di][dj] -= 1; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
bool ok = true; | ||
|
||
for (int i = 0; i < N; i++) { | ||
for (int j = 0; j < M; j++) { | ||
if (S[i][j] != 'F' && cnt[i][j] != 0) { | ||
ok = false; | ||
} | ||
} | ||
} | ||
|
||
if (ok) { | ||
cout << "Well done Clark!\n"; | ||
} else { | ||
cout << "Please sweep the mine again!\n"; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
Binary file not shown.
Oops, something went wrong.