/ tabris /

记录详情

Runtime Error

/in/foo.cc:20:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:102400000,102400000")
 
/in/foo.cc: In function 'int main()':
/in/foo.cc:48:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<v.size();i++) printf(" %d",v[i]);
                 ~^~~~~~~~~
# 状态 耗时 内存占用
#1 Accepted 10ms 3.125 MiB
#2 Accepted 22ms 3.625 MiB
#3 Accepted 22ms 3.875 MiB
#4 Accepted 23ms 5.355 MiB
#5 Accepted 203ms 6.617 MiB
#6 Runtime Error 125ms 12.672 MiB
#7 Runtime Error 126ms 12.59 MiB
#8 Runtime Error 141ms 12.605 MiB

代码

#include <bits/stdc++.h>
#define  ms(a,b) memset(a,b,sizeof(a))

using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;

int ls[maxn],rs[maxn];
int ans=0,n,rt,cnt;
bool changed[maxn];
int dfs(int u)
{
    int lmin=(ls[u])?dfs(ls[u]):u;
    int rmin=(rs[u])?dfs(rs[u]):u;
    if(lmin>rmin) changed[u]=true,ans++;
    return min(lmin,rmin);
}vector<int>v;
void Output(int u)
{
#pragma comment(linker, "/STACK:102400000,102400000")
    if(!u) return;
    if(changed[u])
    {
        Output(rs[u]);
        v.push_back(u);
        Output(ls[u]);
    }
    else {
        Output(ls[u]);
        v.push_back(u);
        Output(rs[u]);
    }
    cnt++;
}
int main()
{
    cnt = ans = 0;
    v.clear();
    scanf("%d%d",&n,&rt);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&ls[i],&rs[i]);
    ms(changed,0);
    dfs(rt);

    Output(rt);
    printf("%d\n",ans);
    printf("%d",v[0]);
    for(int i=1;i<v.size();i++) printf(" %d",v[i]);
    printf("\n");
    return 0;
}

信息

递交者
类型
递交
题目
tabris is SirBat 1 (**数据范围有改动**) 在这个oj后三组数据会栈溢出 最好手工栈
语言
C++
递交时间
2017-12-09 17:24:20
评测时间
2017-12-09 17:24:20
评测机
分数
640
总耗时
676ms
峰值内存
12.672 MiB