一直运行错误怎么回事 本地都编译得起来啊

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int ans=0;
struct line
{
int t,p;
}c[100010];
bool comp(const line&a,const line&b)
{
return a.t<b.t;
}
void gb_(int l,int r)
{
int p[100010];
if(l==r)
return ;
int mid,i,j,k;
mid=(l+r)>>1;
gb_(l,mid);
gb_(mid+1,r);
i=l;
j=mid+1;
k=i;
while(i<=mid && j<=r)
{
if(c[i].p>c[j].p)
{
p[k++]=c[j++].p;
ans+=mid-i+1;
}
else
{
p[k++]=c[i++].p;
}
}
while(i<=mid)
{
p[k++]=c[i++].p;
}
while(j<=r)
{
p[k++]=c[j++].p;
}
for(int i=l;i<=r;i++)
c[i].p=p[i];
}
int abs(int x)
{
return x>0?:x,-x;
}
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&c[i].t);
c[i].p=i;
}
sort(c+1,c+n+1,comp);
int maxn=-1,s;
for(int i=1;i<=n;i++)
{
if(abs(c[i].p-i)>maxn)
{
maxn=abs(c[i].p-i);
s=i;
}
}
/* cout<<maxn<<" "<<s<<endl;*/
int maxn1=0x7fffffff,s1;
for(int i=1;i<=n;i++)
{
if(i==s)
continue;
if(abs(abs(c[i].p-s)+abs(i-c[s].p))<maxn1)
maxn1=abs(abs(c[i].p-s)+abs(i-c[s].p)),s1=i;
}
/* cout<<maxn1<<" "<<s1<<endl;*/
swap(c[s].p,c[s1].p);
/* for(int i=1;i<=n;i++)
cout<<c[i].p<<" ";
cout<<endl;*/
gb_(1,n);
printf("%d",ans);
return 0;
}

6 条评论

  • @ 2015-08-19 10:22:10

    把警告里的错误改掉。。

  • @ 2014-11-02 10:56:06

    abs函数写错了……编译有提示……虽然不知道导致RE的原因……

  • @ 2014-11-02 08:18:15

    运行错误跟编译有什么关系吗....

  • @ 2014-10-31 21:56:48

    JOI官网上有数据。。。自己扒拉吧。。。

  • @ 2014-10-26 09:59:11

    编译成功

    foo.cpp: In function 'int abs(int)':
    foo.cpp:51:13: warning: the omitted middle operand in ?: will always be 'true', suggest explicit middle operand [-Wparentheses]
    return x>0?:x,-x;
    ^
    foo.cpp: In function 'int main()':
    foo.cpp:63:14: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
    int maxn=-1,s;
    ^
    错误提示是这样

    • @ 2014-10-26 10:10:23

      没错误啊.. 这是warning

    • @ 2014-10-31 20:54:51

      warning...
      那为什么运行错误
      测试数据 #0: RuntimeError, time = 0 ms, mem = 3312 KiB, score = 0
      测试数据 #1: RuntimeError, time = 31 ms, mem = 3316 KiB, score = 0
      测试数据 #2: RuntimeError, time = 62 ms, mem = 3312 KiB, score = 0
      测试数据 #3: RuntimeError, time = 78 ms, mem = 3312 KiB, score = 0
      测试数据 #4: RuntimeError, time = 78 ms, mem = 3312 KiB, score = 0
      测试数据 #5: RuntimeError, time = 46 ms, mem = 3316 KiB, score = 0
      测试数据 #6: RuntimeError, time = 62 ms, mem = 3312 KiB, score = 0
      测试数据 #7: RuntimeError, time = 62 ms, mem = 3316 KiB, score = 0
      测试数据 #8: RuntimeError, time = 46 ms, mem = 3316 KiB, score = 0
      测试数据 #9: RuntimeError, time = 46 ms, mem = 3312 KiB, score = 0

    • @ 2014-11-01 09:40:44

      运行错误是程序的问题呀0 0

  • @ 2014-10-26 00:35:13

    爆数组了吧……

    • @ 2014-10-26 09:58:27

      数据不是才10w 爆数组应该也有点分数吧%>_<%

  • 1

信息

ID
1893
难度
9
分类
(无)
标签
(无)
递交数
460
已通过
29
通过率
6%
被复制
3
上传者