QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#500575 | #3817. Generating Polygons | PetroTarnavskyi# | WA | 5ms | 3640kb | C++20 | 1.6kb | 2024-08-01 15:20:20 | 2024-08-01 15:20:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const string nie = "NIE";
void print(char c, int k)
{
FOR(i, 0, k)
cout << c;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int p;
LL s;
cin >> p >> s;
if (p % 2 == 1 || s < p / 2 - 1)
{
cout << nie << "\n";
return 0;
}
FOR(a, 1, p / 2)
{
int b = p / 2 - a;
if ((LL)a * b == s)
{
print('B', a);
print('P', 1);
print('B', b - 1);
print('P', 1);
print('B', a - 1);
print('P', 1);
print('B', b - 1);
cout << "\n";
return 0;
}
if ((LL)a * b > s)
{
assert(a >= 2);
int cnt = (s - b) / (a - 1);
int x = (s - b) % (a - 1);
if (x == 0)
{
print('B', a);
print('P', 1);
print('B', cnt - 1);
print('P', 1);
print('B', a - 2);
print('L', 1);
print('B', b - cnt - 1);
print('P', 2);
print('B', b - 1);
cout << "\n";
return 0;
}
print('B', a);
print('P', 1);
print('B', cnt - 1);
print('P', 1);
print('B', a - 2 - x);
print('L', 1);
print('P', 1);
print('B', x - 1);
print('L', 1);
print('B', b - cnt - 2);
print('P', 2);
print('B', b - 1);
cout << "\n";
return 0;
}
}
cout << nie << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
14 6
output:
BPBBBBBPPBBBBB
result:
ok Correct solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
20 26
output:
NIE
result:
ok No solution
Test #3:
score: 0
Accepted
time: 5ms
memory: 3584kb
input:
686930 197495762
output:
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
ok Correct solution
Test #4:
score: 0
Accepted
time: 2ms
memory: 3632kb
input:
687524 1478498130
output:
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
ok Correct solution
Test #5:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
92052 92891828
output:
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
ok Correct solution
Test #6:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
266589 204096933962
output:
NIE
result:
ok No solution
Test #7:
score: -100
Wrong Answer
time: 2ms
memory: 3640kb
input:
229384 1970864753
output:
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
wrong answer Incorrect solution: not a polygon