I can run through in the window xp, but all the answers in the Linux is error

#include<iostream>
#include<cstdio>
#include<vector>
#define mp make_pair
#define LL long long
#define maxn 200000+100

using namespace std;

vector<pair<LL,LL> > v[maxn];
pair<LL,LL> mx[maxn][5];
LL ss,s1,s2,s3,s4,s11,s22,s33,s44,s55;
LL gs[maxn];
LL sy2[5];
LL n,ans1,ans2;

LL getint()
{
LL 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;
}
void bj(LL x,LL z)
{
if (z>mx[x][1].first)
{
mx[x][3]=mx[x][2];
mx[x][2]=mx[x][1];
mx[x][1]=mp(z,1);
}
else
if (z==mx[x][1].first) mx[x][1].second++;
else
if (z>mx[x][2].first)
{
mx[x][3]=mx[x][2];
mx[x][2]=mp(z,1);
}
else
if (z==mx[x][2].first) mx[x][2].second++;
else
if (z>mx[x][3].first) mx[x][3]=mp(z,1);
else
if (z==mx[x][3].first) mx[x][3].second++;
}

LL work(LL x)
{
return x*(x-1)/2;
}

int flag1=0,flag2=0;

void work2(LL now,LL nn,LL sy,LL cf)
{
if (mx[now][nn].first>cf||mx[now][nn].first<cf)
{
LL x=mx[now][nn].second;
if (x>=sy)
{
s4+=mx[now][nn].first*sy;
sy2[nn]-=x; return;
}
else
{
s4+=mx[now][nn].first*x;
sy2[nn]=0;
work2(now,nn+1,sy-x,cf);
}
}
else
if (mx[now][nn].first==cf)
{
LL x=mx[now][nn].second;
if (x>1)
{
x--;
if (x>=sy)
{
s4+=mx[now][nn].first*sy; return;
}
else
{
s4+=mx[now][nn].first*x;
work2(now,nn+1,sy-x,cf);
}
}
else
work2(now,nn+1,sy,cf);
}

}

void work3(LL fa, LL son, LL len,LL nn)
{
if (mx[son][nn].first>len||mx[son][nn].first<len)
{
s1+=mx[son][nn].first;return;
}
else
{
if (mx[son][nn].first==len)
{
if (mx[son][nn].second>1)
{
s1+=mx[son][nn].first; return;
}
else
work3(fa,son,len,nn+1);
}
}
}


int pd (int now,int son, int len,int nn)
{
if (nn>3) return 1;
if (len==mx[now][nn].first)
{
if (sy2[nn]>0) return 1; else return 0;
}
else
{
if (len<mx[now][nn].first)
return pd(now,son,len,nn+1);
}
}

int main()
{
n=getint();
for (int i=1;i<n;i++)
{
LL x=getint(),y=getint(),z=getint();
bj(x,z);
bj(y,z);
v[x].push_back(mp(y,z));
v[y].push_back(mp(x,z));
}
for (int i=1;i<=n;i++)
for (int j=0;j<v[i].size();j++)
{
LL son=v[i][j].first;
if (v[son].size()>1)
gs[i]+=v[son].size()-1;
}
for (int i=1;i<=n;i++)
if (v[i].size()>=3)
{
ss=0;
ss=work(v[i].size()-1);
ans1+=ss*gs[i];
s1=s2=s3=s4=s11=s22=s33=s44=0;
for (int j=0;j<v[i].size();j++)
{
s1=v[i][j].second;
work3(i,v[i][j].first,v[i][j].second,1);
if (s1>s2)
{
s2=s1;
s3=v[i][j].second;
}
}
work2(i,1,2,s3);
ans2=max(ans2,s4+s2);
s1=s2=s3=s4=0;
for (int j=1;j<=3;j++)
sy2[j]=mx[i][j].second;
work2(i,1,2,0);
for (int j=0;j<v[i].size();j++)
{
s1=v[i][j].second;
if (pd(i,v[i][j].first,v[i][j].second,1))
{
work3(i,v[i][j].first,v[i][j].second,1);
if (s1>s2) s2=s1;s3=v[i][j].second;
}
}
ans2=max(ans2,s4+s2);
}
cout<<ans1<<endl<<ans2<<endl;
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include<iostream>
#include<cstdio>
#include<vector>
#define mp make_pair
#define LL long long
#define maxn 200000+100

using namespace std;

vector<pair<LL,LL> > v[maxn];
pair<LL,LL> mx[maxn][5];
LL ss,s1,s2,s3,s4,s11,s22,s33,s44,s55;
LL gs[maxn];
LL sy2[5];
LL n,ans1,ans2;

LL getint()
{
LL 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;
}
void bj(LL x,LL z)
{
if (z>mx[x][1].first)
{
mx[x][3]=mx[x][2];
mx[x][2]=mx[x][1];
mx[x][1]=mp(z,1);
}
else
if (z==mx[x][1].first) mx[x][1].second++;
else
if (z>mx[x][2].first)
{
mx[x][3]=mx[x][2];
mx[x][2]=mp(z,1);
}
else
if (z==mx[x][2].first) mx[x][2].second++;
else
if (z>mx[x][3].first) mx[x][3]=mp(z,1);
else
if (z==mx[x][3].first) mx[x][3].second++;
}

LL work(LL x)
{
return x*(x-1)/2;
}

int flag1=0,flag2=0;

void work2(LL now,LL nn,LL sy,LL cf)
{
if (mx[now][nn].first>cf||mx[now][nn].first<cf)
{
LL x=mx[now][nn].second;
if (x>=sy)
{
s4+=mx[now][nn].first*sy;
sy2[nn]-=x; return;
}
else
{
s4+=mx[now][nn].first*x;
sy2[nn]=0;
work2(now,nn+1,sy-x,cf);
}
}
else
if (mx[now][nn].first==cf)
{
LL x=mx[now][nn].second;
if (x>1)
{
x--;
if (x>=sy)
{
s4+=mx[now][nn].first*sy; return;
}
else
{
s4+=mx[now][nn].first*x;
work2(now,nn+1,sy-x,cf);
}
}
else
work2(now,nn+1,sy,cf);
}

}

void work3(LL fa, LL son, LL len,LL nn)
{
if (mx[son][nn].first>len||mx[son][nn].first<len)
{
s1+=mx[son][nn].first;return;
}
else
{
if (mx[son][nn].first==len)
{
if (mx[son][nn].second>1)
{
s1+=mx[son][nn].first; return;
}
else
work3(fa,son,len,nn+1);
}
}
}


int pd (int now,int son, int len,int nn)
{
if (nn>3) return 1;
if (len==mx[now][nn].first)
{
if (sy2[nn]>0) return 1; else return 0;
}
else
{
if (len<mx[now][nn].first)
return pd(now,son,len,nn+1);
}
}

int main()
{
n=getint();
for (int i=1;i<n;i++)
{
LL x=getint(),y=getint(),z=getint();
bj(x,z);
bj(y,z);
v[x].push_back(mp(y,z));
v[y].push_back(mp(x,z));
}
for (int i=1;i<=n;i++)
for (int j=0;j<v[i].size();j++)
{
LL son=v[i][j].first;
if (v[son].size()>1)
gs[i]+=v[son].size()-1;
}
for (int i=1;i<=n;i++)
if (v[i].size()>=3)
{
ss=0;
ss=work(v[i].size()-1);
ans1+=ss*gs[i];
s1=s2=s3=s4=s11=s22=s33=s44=0;
for (int j=0;j<v[i].size();j++)
{
s1=v[i][j].second;
work3(i,v[i][j].first,v[i][j].second,1);
if (s1>s2)
{
s2=s1;
s3=v[i][j].second;
}
}
work2(i,1,2,s3);
ans2=max(ans2,s4+s2);
s1=s2=s3=s4=0;
for (int j=1;j<=3;j++)
sy2[j]=mx[i][j].second;
work2(i,1,2,0);
for (int j=0;j<v[i].size();j++)
{
s1=v[i][j].second;
if (pd(i,v[i][j].first,v[i][j].second,1))
{
work3(i,v[i][j].first,v[i][j].second,1);
if (s1>s2) s2=s1;s3=v[i][j].second;
}
}
ans2=max(ans2,s4+s2);
}
cout<<ans1<<endl<<ans2<<endl;
return 0;
} 

What is the purpose of this program? It compiles with out error on Linux, using both g++ and clang++. However, the program does nothing.
This is a OI test, evaluation system for the window, I was in the AC is Linux off, but the final score of 0 points, in the linux test is also under zero, seeking advice
Topic archived. No new replies allowed.