QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#254867 | #7755. Game on a Forest | ucup-team346# | WA | 1ms | 3508kb | C++20 | 1.7kb | 2023-11-18 14:05:47 | 2023-11-18 14:05:48 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define db double
#define ve vector<int>
#define pa pair<int,int>
#define fr first
#define sd second
#define pb push_back
#define mp make_pair
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
inline ll read()
{
char ch = getchar();
ll s = 0, w = 1;
while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
return s * w;
}
#define N 100010
int n;
ll a[N];
int b[N];
void sol()
{
cin >> n;
for (int i = 1; i <= n; i ++)cin >> a[i];
ll s = 0, t = 0; int tg = 0;
for (int i = 1; i <= n; i ++)
{
t = (t | (s % 2 != 0));
s /= 2;
if (tg == 0)
{
if (a[i] > 0) {tg = +1; s += a[i];}
if (a[i] < 0) {tg = -1; s -= a[i];}
}
else if (tg == +1)
{
if (a[i] > 0)s += a[i];
if (a[i] < 0)
{
if (s + a[i] + t <= 0)
{
s += a[i] + t;
s = -s; tg = -1;
}
else {s += a[i];}
}
}
else if (tg == -1)
{
if (a[i] < 0)s -= a[i];
if (a[i] > 0)
{
if (s - a[i] + t <= 0)
{
s -= a[i] - t;
s = -s; tg = +1;
}
else {s -= a[i];}
}
}
if (s == 0 && t == 0)tg = 0;
// cout << "GG:" << i << ' ' << s << ' ' << t << " " << tg << endl;
b[i] = tg;
}
for (int i = 1; i <= n; i ++)
{
if (b[i] > 0)cout << '+';
if (b[i] < 0)cout << '-';
if (b[i] == 0)cout << '0';
}
cout << '\n';
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T = 1;
while (T --)sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3508kb
input:
3 1 1 2
output:
+++
result:
wrong output format Expected integer, but "+++" found