QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595184#7747. MemoryAmiyaCastWA 4ms7608kbC++142.2kb2024-09-28 12:55:032024-09-28 12:55:03

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 12:55:03]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:7608kb
  • [2024-09-28 12:55:03]
  • 提交

answer

#include<bits/stdc++.h>
#define ll __int128
#define pii make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
const ll inf = 1145141919810;
using namespace std;
inline ll read() {
	ll x=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9') {
		if (c=='-')  f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
inline void print(ll x) {
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + '0');
	return ;
}
inline void pprint(ll x) {
	print(x);
	puts("");
}
const int N = 2e5 + 7;
ll a[N], b[100], n;
ll qm(ll a, ll b) {
	ll base = 1;
	while(b) {
		if(b & 1) base *= a;
		a *= a;
		b >>= 1;
	}
	return base;
}
const int Block = 32;
void slv1() {
	vector<ll> f;
	f.resize(n + 1, 0ll);
	for(int i = 1; i <= n; ++i) {
		f[i] = f[i - 1] + a[i] * b[i - 1];
		if(f[i] > 0) {
			putchar('+');
		} else if(f[i] == 0) {
			putchar('0');
		} else if(f[i] < 0) {
			putchar('-');
		}
	}
}
void slv2() { //Block
	vector<ll> f;
	vector<int> g;
	f.resize(n + 1);
	g.resize(n + 1);
	for(int i = 1; i <= Block; ++i) {
		f[i] = f[i - 1] + a[i] * b[i - 1];
		if(f[i] > 0) {
			putchar('+');
		} else if(f[i] == 0) {
			putchar('0');
		} else if(f[i] < 0) {
			putchar('-');
		}
		if(f[i] > 0) g[i] = 1;
		if(f[i] == 0) g[i] = 0;
		if(f[i] < 0) g[i] = -1;
		
	}
	for(int i = Block + 1; i <= n; ++i){
		f[i - Block] = 0ll;
		for(int j = i - Block + 1, k = 0; j <= i; ++j, ++k){//计算连续的31个
			f[j] = f[j - 1] + a[j] * b[k];
		}
		
		if(f[i] > 0){
			putchar('+');
		}else if(f[i] == 0){
			if(g[i - Block] > 0){
				putchar('+');
			}else if(g[i - Block] == 0){
				putchar('0');
			}else if(g[i - Block] < 0){
				putchar('-');
			}
		}else if(f[i] < 0){
			putchar('-');
		}
		
		if(f[i] > 0) g[i] = 1;
		if(f[i] == 0) g[i] = 0;
		if(f[i] < 0) g[i] = -1;
	}
}
int main() {
	n = read();
	rep(i, 1, n) a[i] = read();
	for(int i = 0; i <= Block; ++i) b[i] = qm(2, i);
	if(n <= Block) {
		slv1();
	} else {
		slv2();
	}
	return 0;
}

/*
 10
 2 -1 4 -7 4 -8 3 -6 4 -7
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

10
2 -1 4 -7 4 -8 3 -6 4 -7

output:

+0+-+---+-

result:

ok single line: '+0+-+---+-'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

10
-1 36 18 18 18 18 18 18 18 -18

output:

-++++++++-

result:

ok single line: '-++++++++-'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

1000
-1 193552 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 967...

output:

-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

result:

ok single line: '-+++++++++++++++++++++++++++++...++++++++++++++++++++++++++++++-'

Test #4:

score: 0
Accepted
time: 4ms
memory: 7608kb

input:

100000
-1 696082628 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 348041314 ...

output:

-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...

result:

ok single line: '-+++++++++++++++++++++++++++++...++++++++++++++++++++++++++++++-'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

10
-1 70 -35 -72 36 12 -6 42 -21 -84

output:

-+---+-+--

result:

ok single line: '-+---+-+--'

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

1000
-1 -120742 60371 -567374 283687 -507718 253859 -579246 289623 21402 -10701 539474 -269737 -681332 340666 -746052 373026 -993382 496691 -333880 166940 -632724 316362 909690 -454845 86680 -43340 236688 -118344 -29102 14551 6252 -3126 -440612 220306 -878460 439230 649538 -324769 -651632 325816 882...

output:

---------+-+-----------+-+-+---+-----+---+-+-+---+-+-+-+-+---+--0-0+0-0-0+0-0+0+0-0-0+0-0-0+0+0+0-0+0-0+0+0-0-0+0-0-0-0+0+0-0+0-0-0+0+0+0-0-0-0+0+0+0+0+0-0-0-0+0-0-0+0+0+0-0-0-0+0-0-0-0+0+0+0-0-0-0+0-0+0+0-0+0+0-0+0+0+0+0-0+0+0+0+0+0-0-0-0-0+0-0-0+0-0-0+0+0+0+0+0+0+0+0-0+0+0+0-0-0-0+0-0+0+0+0+0+0+0-...

result:

wrong answer 1st lines differ - expected: '---------+-+-----------+-+-+--...+---+-+-+-+-+-----+-+---------+', found: '---------+-+-----------+-+-+--...+0-0+0+0+0+0+0-0-0+0+0-0-0-0-0+'