-
Notifications
You must be signed in to change notification settings - Fork 1
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
8 changed files
with
255 additions
and
0 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> | ||
|
||
#define MAX 2000 | ||
|
||
using namespace std; | ||
|
||
|
||
int main (void ) { | ||
int caixa[10][10]; | ||
|
||
|
||
while(true){ | ||
int l, c, p; | ||
memset(caixa, 0, sizeof caixa); | ||
scanf("%d %d %d", &l, &c, &p); | ||
|
||
if (l == 0 && c == 0 && p == 0) break; | ||
|
||
for (int i = 0; i < l; i++) { | ||
for (int j = 0; j < c; j++) { | ||
scanf("%d", &caixa[i][j]); | ||
} | ||
} | ||
|
||
bool r = true; | ||
int i; | ||
p--; | ||
for (i = 0; i < l; i++) { | ||
int orig_p = p; | ||
|
||
if(caixa[i][p]) { | ||
r = false; | ||
i--; | ||
break; | ||
} | ||
|
||
|
||
for (int j = p-1; j >= 0; j--) { | ||
if (caixa[i][j] > 0) { | ||
p += caixa[i][j]; | ||
break; | ||
} | ||
} | ||
|
||
for (int j = orig_p+1; j < c; j++) { | ||
if (caixa[i][j] > 0) { | ||
p -= caixa[i][j]; | ||
break; | ||
} | ||
} | ||
|
||
int min_left = p < orig_p ? p : orig_p; | ||
int max_right = p > orig_p ? p : orig_p; | ||
|
||
for (int j = min_left; j <= max_right; j++) { | ||
if (caixa[i][j] > 0) { | ||
r = false; | ||
break; | ||
} | ||
} | ||
|
||
if (!r) break; | ||
} | ||
|
||
if (r) { | ||
printf("OUT %d\n", p); | ||
} else { | ||
printf("BOOM %d %d\n", i+1, p); | ||
} | ||
} | ||
|
||
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,18 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
int main (void ) { | ||
int t; | ||
scanf("%d", &t); | ||
|
||
while(t--) { | ||
int n; | ||
scanf("%d", &n); | ||
|
||
if (n % 2) printf("1\n"); | ||
else (printf("0\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,10 @@ | ||
4 7 6 | ||
3 0 0 0 0 0 5 | ||
2 0 0 0 0 0 4 | ||
1 0 1 0 0 0 1 | ||
3 0 0 0 1 0 1 | ||
3 3 2 | ||
1 0 1 | ||
1 0 1 | ||
2 0 1 | ||
0 0 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,19 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
int main (void ) { | ||
int n; | ||
char name[10000]; | ||
|
||
scanf("%d", &n); | ||
|
||
while (n--) { | ||
scanf("%s %*d", name); | ||
|
||
if (strcmp(name, "Thor")) printf("N\n"); | ||
else printf("Y\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,40 @@ | ||
#include <bits/stdc++.h> | ||
|
||
#define n_rules 10 | ||
|
||
using namespace std; | ||
|
||
string rules[n_rules] = {"tesoura papel", "papel pedra", "pedra lagarto", "lagarto spock", "spock tesoura", "tesoura lagarto", "lagarto papel", "papel spock", "spock pedra", "pedra tesoura"}; | ||
|
||
char l1[1000]; | ||
char l2[1000]; | ||
|
||
char scenario1[1000], scenario2[1000]; | ||
|
||
|
||
int main (void ) { | ||
int t; | ||
scanf("%d", &t); | ||
|
||
while(t--) { | ||
scanf("%s %s", l1, l2); | ||
|
||
string winner = "empate"; | ||
|
||
for (auto rule : rules) { | ||
|
||
sprintf(scenario1, "%s %s", l1, l2); | ||
sprintf(scenario2, "%s %s", l2, l1); | ||
|
||
if (strcmp(rule.c_str(), scenario1) == 0) { | ||
winner = "rajesh"; | ||
} else if (strcmp(rule.c_str(), scenario2) == 0) { | ||
winner = "sheldon"; | ||
} | ||
} | ||
|
||
printf("%s\n", winner.c_str()); | ||
} | ||
|
||
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,26 @@ | ||
4 7 6 | ||
3 0 0 0 0 0 5 | ||
2 0 0 0 0 0 4 | ||
2 0 1 0 0 0 1 | ||
3 0 0 0 1 0 1 | ||
4 7 6 | ||
3 0 0 0 0 0 5 | ||
2 0 0 0 0 0 3 | ||
2 0 1 0 0 0 1 | ||
3 0 0 0 1 0 1 | ||
4 7 6 | ||
3 0 0 0 0 0 55 | ||
2 0 0 0 0 0 4 | ||
2 0 1 0 0 0 1 | ||
3 0 0 0 1 0 1 | ||
4 7 6 | ||
0 0 0 0 0 0 5 | ||
2 0 0 0 0 0 3 | ||
2 0 1 0 0 0 1 | ||
3 0 0 0 1 0 1 | ||
4 7 6 | ||
1 0 0 0 0 0 0 | ||
2 0 0 0 0 0 3 | ||
2 0 1 0 0 0 1 | ||
3 0 0 0 1 0 1 | ||
0 0 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,37 @@ | ||
#include <bits/stdc++.h> | ||
|
||
#define MAX 2000 | ||
|
||
using namespace std; | ||
|
||
int heights[MAX]; | ||
|
||
bool verify(int a, int b, int k) { | ||
int count = 0; | ||
int i = 0; | ||
while (i <= b) { | ||
while (i <= b && heights[i] <= heights[i+1]) i++; | ||
if (i - a == 0) break; | ||
|
||
count++; | ||
|
||
a = i; | ||
while (i <= b && heights[i] >= heights[i+1]) i++; | ||
if (i - a == 0) break; | ||
} | ||
|
||
return count == k; | ||
} | ||
|
||
int main (void ) { | ||
int n, k; | ||
scanf("%d %d", &n, &k); | ||
|
||
for (int i = 0; i < MAX; i++) { | ||
scanf("%d", heights+i); | ||
} | ||
|
||
printf(verify(0, n-1, k) ? "beautiful\n" : "ugly\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,32 @@ | ||
#include <bits/stdc++.h> | ||
|
||
#define MAX 2000 | ||
|
||
using namespace std; | ||
|
||
int main (void ) { | ||
int n1, n2; | ||
int v[20]; | ||
|
||
while (true) { | ||
scanf("%d %d", &n1, &n2); | ||
if (n1 == 0 && n2 == 0) break; | ||
|
||
int v_i = 20; | ||
int r = n1 + n2; | ||
|
||
while (r > 0) { | ||
if (r % 10) { | ||
v[v_i--] = r%10; | ||
} | ||
|
||
r /= 10; | ||
} | ||
|
||
for (int i = v_i+1; i <= 20; i++) { | ||
printf("%d", v[i]); | ||
} | ||
printf("\n"); | ||
} | ||
return 0; | ||
} |