-
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
Showing
25 changed files
with
872 additions
and
174 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <sstream> | ||
#include <vector> | ||
#include <set> | ||
#include <map> | ||
#include <list> | ||
#include <queue> | ||
#include <stack> | ||
#include <memory> | ||
#include <iomanip> | ||
#include <numeric> | ||
#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); | ||
} | ||
|
||
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; | ||
|
||
typedef long long Int; | ||
typedef unsigned uint; | ||
|
||
const int MAXN = 507; | ||
|
||
int N; | ||
int L[MAXN], W[MAXN], H[MAXN]; | ||
|
||
int dp[MAXN][MAXN]; | ||
|
||
int fit (int x, int y) { | ||
int buff[3] = {L[x], W[x], H[x]}; | ||
|
||
sort (buff, buff + 3); | ||
|
||
do { | ||
if (buff[0] < L[y] && buff[1] < W[y] && buff[2] < H[y]) return 1; | ||
} while (next_permutation(buff, buff + 3)); | ||
|
||
return 0; | ||
} | ||
|
||
int func(int index, int last) { | ||
if (index == N + 1) return 0; | ||
|
||
int& ans = dp[index][last]; | ||
|
||
if (ans != -1) return ans; | ||
|
||
ans = func(index + 1, last); | ||
|
||
if (fit(last, index)) { | ||
ans = max(ans, 1 + func(index + 1, index)); | ||
} | ||
|
||
return ans; | ||
} | ||
|
||
int main(void) { | ||
int i, j; | ||
|
||
L[0] = W[0] = H[0] = 0; | ||
|
||
for ( ; scanf("%d", &N) == 1 && N != -1; ) { | ||
for (i = 1; i <= N; i++) { | ||
L[i] = in(); | ||
W[i] = in(); | ||
H[i] = in(); | ||
} | ||
|
||
for (i = 1; i <= N; i++) { | ||
for (j = i + 1; j <= N; j++) { | ||
int vol_i = L[i] * W[i] * H[i]; | ||
int vol_j = L[j] * W[j] * H[j]; | ||
|
||
if (vol_i > vol_j) { | ||
swap(L[i], L[j]); | ||
swap(W[i], W[j]); | ||
swap(H[i], H[j]); | ||
} | ||
} | ||
} | ||
|
||
memset(dp, -1, sizeof(dp)); | ||
|
||
printf("%d\n", func(1, 0)); | ||
} | ||
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,9 +1,18 @@ | ||
3 3 | ||
0 1 2 | ||
1 0 2 | ||
2 1 0 | ||
3 3 | ||
0 1 2 | ||
1 2 0 | ||
2 0 1 | ||
0 0 | ||
5 | ||
145 472 812 | ||
827 133 549 | ||
381 371 900 | ||
271 389 128 | ||
718 217 491 | ||
4 | ||
432 123 139 | ||
942 844 783 | ||
481 487 577 | ||
677 581 701 | ||
5 | ||
5 5 5 | ||
4 4 4 | ||
3 3 3 | ||
2 2 5 | ||
1 1 4 | ||
-1 |
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
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,54 +1,58 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
#include <vector> | ||
#include <math.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
using namespace std; | ||
|
||
int f, to, i, j, k, n, m, graph[500][500], vis[500], t = 1; | ||
|
||
void dfs(int n, int s) { | ||
vis[n] = true; | ||
for(int tmp = 1; tmp <= n; tmp++) { | ||
if(graph[n][tmp] && tmp != s) { | ||
dfs(tmp, s); | ||
} | ||
} | ||
} | ||
|
||
int main(void) { | ||
freopen("i.in", "r", stdin); | ||
while(cin >> n >> m && n > 0 && m > 0) { | ||
memset(graph, 0, sizeof(graph)); | ||
for(i = 0; i < m; i++) { | ||
cin >> f >> to; | ||
graph[f][to] = graph[to][f] = 1; | ||
} | ||
int count = 0; | ||
printf("Teste %d\n", (t++)); | ||
for(i = 1; i <= n; i++) { | ||
bool ok = true; | ||
for(j = 1; j <= n; j++) if(i != j) { | ||
memset(vis, 0, sizeof(vis)); | ||
dfs(j, i); | ||
for(k = 1; k <= n; k++) { | ||
if(!vis[k] && k != i) { | ||
ok = false; | ||
break; | ||
} | ||
} | ||
} | ||
if(!ok) { | ||
printf("%d ", i); | ||
count += 1; | ||
} | ||
} | ||
if(!count) { | ||
printf("nenhum"); | ||
} | ||
printf("\n\n"); | ||
} | ||
return 0; | ||
} | ||
#include <iostream> | ||
#include <vector> | ||
#include <set> | ||
#include <algorithm> | ||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
#define REP(i, n) for(i = 0; i < (n); i++) | ||
|
||
using namespace std; | ||
|
||
int a, b, i, n, m, times, teste, vis[410]; | ||
vector<int> graph[410]; | ||
set<int> ans; | ||
set<int>::iterator it; | ||
|
||
int dfs(int u){ | ||
int less = vis[u] = times++; | ||
int filhos = 0; | ||
for(int i = 0; i< graph[u].size(); i++){ | ||
if(vis[graph[u][i]]==0){ | ||
filhos++; | ||
int m = dfs(graph[u][i]); | ||
less = min(less,m); | ||
if(vis[u] <= m && (u != 0 || filhos >= 2)){ | ||
ans.insert(u); | ||
} | ||
}else{ | ||
less = min(less, vis[graph[u][i]]); | ||
} | ||
} | ||
return less; | ||
} | ||
int main(void) { | ||
teste = 1; | ||
for( ; scanf("%d%d", &n, &m) == 2 && !(n + m) == 0; ) { | ||
REP(i, n+1) { graph[i].clear(); vis[i] = 0; } | ||
REP(i, m) { | ||
scanf("%d%d", &a, &b); a -= 1; b -= 1; | ||
graph[a].push_back(b); | ||
graph[b].push_back(a); | ||
} | ||
times = 1; | ||
ans.clear(); | ||
dfs(0); | ||
printf("Teste %d\n", teste++); | ||
if(ans.size() == 0) { | ||
printf("nenhum\n"); | ||
} else { | ||
for(it = ans.begin(); it != ans.end(); it++) { | ||
printf("%d ", (*it) + 1); | ||
} | ||
printf("\n"); | ||
} | ||
printf("\n"); | ||
} | ||
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,17 +1,18 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
typedef long long ll; | ||
|
||
int n, p, q, r, s, x, y, ni, nj; | ||
|
||
int main(void) { | ||
cin >> n >> p >> q >> r >> s >> x >> y >> ni >> nj; | ||
for(i = 1; i <= n; i++) { | ||
|
||
} | ||
cout << ans << endl; | ||
return 0; | ||
} | ||
|
||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
typedef long long ll; | ||
|
||
ll n, p, q, r, s, x, y, ni, nj, ans = 0; | ||
|
||
int main(void) { | ||
for ( ; cin >> n >> p >> q >> r >> s >> x >> y >> ni >> nj; ) { | ||
ans = 0LL; | ||
for(int z = 1; z <= n; z++) { | ||
ans += (ll) ((p*ni + q*z)%x) * ((r*z + s*nj)%y); | ||
} | ||
cout << ans << endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.