QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#538040 | #2967. Snowball Fight | stasio6 | TL | 0ms | 3704kb | C++14 | 2.5kb | 2024-08-30 21:25:25 | 2024-08-30 21:25:26 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i,a,b) for(int i = a; i < (b); i++)
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define PB push_back
#define FS first
#define SD second
template<class X, class Y> void cmn(X &a, Y b) { a=min<X>(a, b); }
template<class X, class Y> void cmx(X &a, Y b) { a=max<X>(a, b); }
typedef pair<int, int> pii;
typedef vector<int> vi;
signed main() {
cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
pii s[3];
cin >> s[0].FS >> s[1].FS >> s[2].FS;
for (int i = 0; i < 3; i++) {
s[i].SD = i;
}
while (true) {
sort(s, s+3, greater<>());
// cerr << s[0].FS << " " << s[1].FS << " " << s[2].FS << "\n";
if (s[0].FS == 0) {
cout << "Rubble!\n";
break;
}
if (s[1].FS == 0) {
cout << char('A' + s[0].SD) << " " << s[0].FS << "\n";
break;
}
if (s[2].FS == 0) {
if (s[1].FS == s[0].FS) {
cout << "Rubble!\n";
} else {
cout << char('A' + s[0].SD) << " " << s[0].FS - s[1].FS << "\n";
}
break;
}
if (s[0].FS == s[2].FS) {
cout << "Rubble!\n";
break;
}
int diff1 = s[0].FS - s[1].FS, diff2 = s[1].FS - s[2].FS;
if (diff1 != 0 && diff2 != 0) {
int diff = min({diff1, diff2, s[2].FS});
s[0].FS -= 2*diff;
s[1].FS -= diff;
continue;
}
if (diff1 == 0 && diff2 >= 3) {
int diff = diff2;
diff = diff / 3 * 3;
s[0].FS -= diff;
s[1].FS -= diff;
continue;
}
if (diff2 == 0 && diff1 >= 3 && s[2].FS > 1) {
int diff = diff1 / 3;
s[0].FS -= 4 * diff;
s[1].FS -= diff;
s[2].FS -= diff;
continue;
}
int hp[3] = {0, 0, 0};
int hit[3] = {0, 0, 0};
for (int i = 0; i < 3; i++) {
hp[s[i].SD] = s[i].FS;
}
if (hp[1] < hp[2])
hit[2]++;
else
hit[1]++;
if (hp[2] < hp[0])
hit[0]++;
else
hit[2]++;
if (hp[0] < hp[1])
hit[1]++;
else
hit[0]++;
for (int i = 0; i < 3; i++) {
s[i] = {hp[i] - hit[i], i};
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3684kb
input:
10 3 1
output:
A 3
result:
ok single line: 'A 3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
3 2 1
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
2 3 2
output:
C 1
result:
ok single line: 'C 1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
100 101 100
output:
A 1
result:
ok single line: 'A 1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
100 99 100
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #6:
score: -100
Time Limit Exceeded
input:
1000 5000 1000