QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#732093#7747. MemoryCocoderWA 1ms3828kbC++142.0kb2024-11-10 13:11:222024-11-10 13:11:28

Judging History

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

  • [2024-11-10 13:11:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3828kb
  • [2024-11-10 13:11:22]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define ll long long
#define db double
#define P point
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define Fr_(i,a) for(auto i:a)
#define pb push_back
#define fastio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pii pair<int,int> 
#define fir first
#define sec second
#define pq priority_queue
#define mkp make_pair
#define memset(a,b) memset(a,b,sizeof(a))
#define new_opt friend bool operator
#define endl '\n'
#define ok cout<<"ok"<<endl

using namespace std;

const int N=2e6+10;
const int N_=5e3+10;
const int M=998244353;
const int inf=1e18;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9') 
        x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
    return;
}
int qpow(int x,int y)
{
    if(y==0) return 1ll;
    if(y%2==1ll) return x*qpow(x,y-1ll)%M;
    int t=qpow(x,y/2);
    return t*t%M;
}
int gcd(int a,int b)
{
    return b ? gcd(b,a % b) : a;
}

int n,m,k;

db a[N];
int sgn(db x)
{
    if(abs(x)<1e-10) return 0;
    if(x>0) return 1;
    if(x<0) return -1;
}
void slv()
{
    cin>>n;
    db now=0;
    Fr(i,1,n) cin>>a[i];
    Fr(i,1,n)
    {
        db t=now-(int)now;
        if(abs(t)<0.1)
        {
            if(sgn(t)!=0)
            {
                if(t<0) t=-0.1;
                else t=0.1;
            }
        }
        now=(int)now+t;
        now=now/2+a[i];
        if(sgn(now)==0) cout<<'0';
        else if(sgn(now)>0) cout<<'+';
        else if(sgn(now)<0) cout<<'-';
        
    }
}
/*
50 
-1 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 
*/

signed main()
{
    //fastio;
    int o=1;
    //cin>>o;
    while(o--) slv();
}

詳細信息

Test #1:

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

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: 3828kb

input:

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

output:

-++++++++-

result:

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

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3776kb

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:

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