Updating lazy-frog files
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
"main-ac": "ac.cpp",
|
||||
"alternative-ac": ["ac_constant_time_heap.c"],
|
||||
"wrong-answer": [],
|
||||
"time-limit": [],
|
||||
"time-limit": ["tle.cpp", "tle2.cpp","tle3.cpp"],
|
||||
"time-limit-or-ac": [],
|
||||
"time-limit-or-memory-limit": [],
|
||||
"memory-limit": [],
|
||||
|
||||
Binary file not shown.
@@ -35,6 +35,7 @@ Para cada caso de teste na entrada, seu programa deve produzir uma linha de saí
|
||||
Se não houver como o Sr. Rã chegar até a casa da Sra. Sapo, seu programa deve imprimir 'impossible', sem as aspas simples.
|
||||
|
||||
\ExemploEntrada
|
||||
|
||||
\begin{Exemplo}
|
||||
\texttt{4~4} & \texttt{14}\\
|
||||
\texttt{1~1~4~2} & \texttt{impossible}\\
|
||||
|
||||
104
ra-preguicosa/src/tle.cpp
Normal file
104
ra-preguicosa/src/tle.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
#define endl '\n'
|
||||
#define INF 0x3f3f3f3f
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef pair<int, int> pii;
|
||||
|
||||
const int MAXN = 1e3 + 10;
|
||||
|
||||
int C, L, W;
|
||||
int Cr, Lr, Cs, Ls;
|
||||
const int COSTS[5][5] = {
|
||||
{7, 6, 5, 6, 7},
|
||||
{6, 3, 2, 3, 6},
|
||||
{5, 2, 0, 2, 5},
|
||||
{6, 3, 2, 3, 6},
|
||||
{7, 6, 5, 6, 7},
|
||||
};
|
||||
bitset<MAXN> alagado[MAXN];
|
||||
int g[MAXN][MAXN];
|
||||
|
||||
bool valid(int c, int l) {
|
||||
return c > 0 && c <= C && l > 0 && l <= L && alagado[c][l] == 0;
|
||||
}
|
||||
|
||||
int h(int c, int l) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void solve()
|
||||
{
|
||||
for (int i = 1; i <= C; i++){
|
||||
for (int j = 1; j <= L; j++){
|
||||
g[i][j] = INF;
|
||||
}
|
||||
}
|
||||
|
||||
priority_queue<
|
||||
pair<int, pii>,
|
||||
vector<pair<int, pii>>,
|
||||
greater<>
|
||||
> pq;
|
||||
|
||||
g[Cr][Lr] = 0;
|
||||
pq.push({h(Cr, Lr), {Cr, Lr}});
|
||||
|
||||
while (!pq.empty()){
|
||||
auto [curCost, curCoords] = pq.top();
|
||||
pq.pop();
|
||||
|
||||
auto [c, l] = curCoords;
|
||||
|
||||
if (curCost != g[c][l] + h(c,l)) continue;
|
||||
|
||||
if (c == Cs && l == Ls){
|
||||
cout << g[c][l] << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = -2; i <= 2; i++){
|
||||
for (int j = -2; j <= 2; j++){
|
||||
int nc = c + i, nl = l + j;
|
||||
if (!valid(nc, nl)) continue;
|
||||
|
||||
int cost = COSTS[i+2][j+2];
|
||||
int newG = g[c][l] + cost;
|
||||
|
||||
if (newG < g[nc][nl]){
|
||||
g[nc][nl] = newG;
|
||||
pq.push({newG + h(nc, nl), {nc, nl}});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << "impossible" << endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
while (cin >> C >> L, C && L){
|
||||
cin >> Cr >> Lr >> Cs >> Ls;
|
||||
for (int i = 1; i <= C; i++){
|
||||
for (int j = 1; j <= L; j++){
|
||||
alagado[i][j]=0;
|
||||
}
|
||||
}
|
||||
cin >> W;
|
||||
for (int i = 0; i < W; i++){
|
||||
int C1, C2, L1, L2;
|
||||
cin >> C1 >> L1 >> C2 >> L2;
|
||||
for (int k = C1; k <= C2; k++)
|
||||
for (int l = L1; l <= L2; l++)
|
||||
alagado[k][l] = 1;
|
||||
}
|
||||
solve();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
118
ra-preguicosa/src/tle2.cpp
Normal file
118
ra-preguicosa/src/tle2.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
#define endl '\n'
|
||||
#define INF 0x3f3f3f3f
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef pair<int, int> pii;
|
||||
|
||||
inline int get_int(){
|
||||
int ch, i;
|
||||
while (((ch = getchar()) == ' ') || (ch == '\n'));
|
||||
for (i = 0; ch >= '0' && ch <= '9'; ch = getchar() )
|
||||
i = 10 * i + (ch - '0');
|
||||
return i;
|
||||
}
|
||||
|
||||
const int MAXN = 1e3 + 10;
|
||||
|
||||
int C, L, W;
|
||||
int Cr, Lr, Cs, Ls;
|
||||
const int COSTS[5][5] = {
|
||||
{7, 6, 5, 6, 7},
|
||||
{6, 3, 2, 3, 6},
|
||||
{5, 2, 0, 2, 5},
|
||||
{6, 3, 2, 3, 6},
|
||||
{7, 6, 5, 6, 7},
|
||||
};
|
||||
bitset<MAXN> alagado[MAXN];
|
||||
int g[MAXN][MAXN];
|
||||
|
||||
bool valid(int c, int l) {
|
||||
return c > 0 && c <= C && l > 0 && l <= L && alagado[c][l] == 0;
|
||||
}
|
||||
|
||||
int h(int c, int l) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void solve()
|
||||
{
|
||||
for (int i = 1; i <= C; i++){
|
||||
for (int j = 1; j <= L; j++){
|
||||
g[i][j] = INF;
|
||||
}
|
||||
}
|
||||
|
||||
priority_queue<
|
||||
pair<int, pii>,
|
||||
vector<pair<int, pii>>,
|
||||
greater<>
|
||||
> pq;
|
||||
|
||||
g[Cr][Lr] = 0;
|
||||
pq.push({h(Cr, Lr), {Cr, Lr}});
|
||||
|
||||
while (!pq.empty()){
|
||||
auto [curCost, curCoords] = pq.top();
|
||||
pq.pop();
|
||||
|
||||
auto [c, l] = curCoords;
|
||||
|
||||
if (curCost != g[c][l] + h(c,l)) continue;
|
||||
|
||||
if (c == Cs && l == Ls){
|
||||
cout << g[c][l] << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = -2; i <= 2; i++){
|
||||
for (int j = -2; j <= 2; j++){
|
||||
int nc = c + i, nl = l + j;
|
||||
if (!valid(nc, nl)) continue;
|
||||
|
||||
int cost = COSTS[i+2][j+2];
|
||||
int newG = g[c][l] + cost;
|
||||
|
||||
if (newG < g[nc][nl]){
|
||||
g[nc][nl] = newG;
|
||||
pq.push({newG + h(nc, nl), {nc, nl}});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << "impossible" << endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
while (C=get_int(), L=get_int(), C && L){
|
||||
Cr = get_int();
|
||||
Lr = get_int();
|
||||
Cs = get_int();
|
||||
Ls = get_int();
|
||||
for (int i = 1; i <= C; i++){
|
||||
for (int j = 1; j <= L; j++){
|
||||
alagado[i][j]=0;
|
||||
}
|
||||
}
|
||||
W = get_int();
|
||||
for (int i = 0; i < W; i++){
|
||||
int C1, C2, L1, L2;
|
||||
C1 = get_int();
|
||||
L1 = get_int();
|
||||
C2 = get_int();
|
||||
L2 = get_int();
|
||||
for (int k = C1; k <= C2; k++)
|
||||
for (int l = L1; l <= L2; l++)
|
||||
alagado[k][l] = 1;
|
||||
}
|
||||
solve();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
118
ra-preguicosa/src/tle3.cpp
Normal file
118
ra-preguicosa/src/tle3.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
#define endl '\n'
|
||||
#define INF 0x3f3f3f3f
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef pair<int, int> pii;
|
||||
|
||||
inline int get_int(){
|
||||
int ch, i;
|
||||
while (((ch = getchar()) == ' ') || (ch == '\n'));
|
||||
for (i = 0; ch >= '0' && ch <= '9'; ch = getchar() )
|
||||
i = 10 * i + (ch - '0');
|
||||
return i;
|
||||
}
|
||||
|
||||
const int MAXN = 1e3 + 10;
|
||||
|
||||
int C, L, W;
|
||||
int Cr, Lr, Cs, Ls;
|
||||
const int COSTS[5][5] = {
|
||||
{7, 6, 5, 6, 7},
|
||||
{6, 3, 2, 3, 6},
|
||||
{5, 2, 0, 2, 5},
|
||||
{6, 3, 2, 3, 6},
|
||||
{7, 6, 5, 6, 7},
|
||||
};
|
||||
bitset<MAXN> alagado[MAXN];
|
||||
int g[MAXN][MAXN];
|
||||
|
||||
bool valid(int c, int l) {
|
||||
return c > 0 && c <= C && l > 0 && l <= L && alagado[c][l] == 0;
|
||||
}
|
||||
|
||||
int h(int c, int l) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void solve()
|
||||
{
|
||||
for (int i = 1; i <= C; i++){
|
||||
for (int j = 1; j <= L; j++){
|
||||
g[i][j] = INF;
|
||||
}
|
||||
}
|
||||
|
||||
priority_queue<
|
||||
pair<int, pii>,
|
||||
vector<pair<int, pii>>,
|
||||
greater<>
|
||||
> pq;
|
||||
|
||||
g[Cr][Lr] = 0;
|
||||
pq.push({h(Cr, Lr), {Cr, Lr}});
|
||||
|
||||
while (!pq.empty()){
|
||||
auto [curCost, curCoords] = pq.top();
|
||||
pq.pop();
|
||||
|
||||
auto [c, l] = curCoords;
|
||||
|
||||
if (curCost != g[c][l] ) continue;
|
||||
|
||||
if (c == Cs && l == Ls){
|
||||
cout << g[c][l] << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = -2; i <= 2; i++){
|
||||
for (int j = -2; j <= 2; j++){
|
||||
int nc = c + i, nl = l + j;
|
||||
if (!valid(nc, nl)) continue;
|
||||
|
||||
int cost = COSTS[i+2][j+2];
|
||||
int newG = g[c][l] + cost;
|
||||
|
||||
if (newG < g[nc][nl]){
|
||||
g[nc][nl] = newG;
|
||||
pq.push({newG, {nc, nl}});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << "impossible" << endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
while (C=get_int(), L=get_int(), C && L){
|
||||
Cr = get_int();
|
||||
Lr = get_int();
|
||||
Cs = get_int();
|
||||
Ls = get_int();
|
||||
for (int i = 1; i <= C; i++){
|
||||
for (int j = 1; j <= L; j++){
|
||||
alagado[i][j]=0;
|
||||
}
|
||||
}
|
||||
W = get_int();
|
||||
for (int i = 0; i < W; i++){
|
||||
int C1, C2, L1, L2;
|
||||
C1 = get_int();
|
||||
L1 = get_int();
|
||||
C2 = get_int();
|
||||
L2 = get_int();
|
||||
for (int k = C1; k <= C2; k++)
|
||||
for (int l = L1; l <= L2; l++)
|
||||
alagado[k][l] = 1;
|
||||
}
|
||||
solve();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user