/ Vijos /

记录详情

Compile Error

foo.cpp:2:9: error: expected constructor, destructor, or type conversion before '(' token
  freopen("salesman.in","r",stdin);  freopen("salesman.out","w",stdout);     scanf("%d",&n);  for(int i=1;i<=n;i++)   scanf("%d",&s[i]);  for(int i=1;i<=n;i++)  {    scanf("%d",&a[i]);   right[i]=i;  }   sort(right+1,right+n+1,cmpr); }   void choose_left(const int i) {   f[i]=f[i-1]+a[left[1]];   pop_heap(left+1,left+l--+1,cmpl); }   void choose_right(const int i) {   f[i]=f[i-1]+2*(s[right[r]]-s[maxi])+a[right[r]];  for(int i=maxi+1;i<right[r];i++)  {    left[++l]=i;    push_heap(left+1,left+l+1,cmpl);  }   maxi=right[r++];   while(r<=n&&right[r]<=maxi)   r++; }   void solve() {   for(int i=1;i<=n;i++)   if(l==0)    choose_right(i);   else if(r>n)    choose_left(i);    else if(a[left[l]]>=2*(s[right[r]]-s[maxi])+a[right[r]])    choose_left(i);   else    choose_right(i); }   void output() 
         ^
foo.cpp:2:44: error: expected constructor, destructor, or type conversion before '(' token
  freopen("salesman.in","r",stdin);  freopen("salesman.out","w",stdout);     scanf("%d",&n);  for(int i=1;i<=n;i++)   scanf("%d",&s[i]);  for(int i=1;i<=n;i++)  {    scanf("%d",&a[i]);   right[i]=i;  }   sort(right+1,right+n+1,cmpr); }   void choose_left(const int i) {   f[i]=f[i-1]+a[left[1]];   pop_heap(left+1,left+l--+1,cmpl); }   void choose_right(const int i) {   f[i]=f[i-1]+2*(s[right[r]]-s[maxi])+a[right[r]];  for(int i=maxi+1;i<right[r];i++)  {    left[++l]=i;    push_heap(left+1,left+l+1,cmpl);  }   maxi=right[r++];   while(r<=n&&right[r]<=maxi)   r++; }   void solve() {   for(int i=1;i<=n;i++)   if(l==0)    choose_right(i);   else if(r>n)    choose_left(i);    else if(a[left[l]]>=2*(s[right[r]]-s[maxi])+a[right[r]])    choose_left(i);   else    choose_right(i); }   void output() 
                                            ^
foo.cpp:2:82: error: expected constructor, destructor, or type conversion before '(' token
  freopen("salesman.in","r",stdin);  freopen("salesman.out","w",stdout);     scanf("%d",&n);  for(int i=1;i<=n;i++)   scanf("%d",&s[i]);  for(int i=1;i<=n;i++)  {    scanf("%d",&a[i]);   right[i]=i;  }   sort(right+1,right+n+1,cmpr); }   void choose_left(const int i) {   f[i]=f[i-1]+a[left[1]];   pop_heap(left+1,left+l--+1,cmpl); }   void choose_right(const int i) {   f[i]=f[i-1]+2*(s[right[r]]-s[maxi])+a[right[r]];  for(int i=maxi+1;i<right[r];i++)  {    left[++l]=i;    push_heap(left+1,left+l+1,cmpl);  }   maxi=right[r++];   while(r<=n&&right[r]<=maxi)   r++; }   void solve() {   for(int i=1;i<=n;i++)   if(l==0)    choose_right(i);   else if(r>n)    choose_left(i);    else if(a[left[l]]>=2*(s[right[r]]-s[maxi])+a[right[r]])    choose_left(i);   else    choose_right(i); }   void output() 
                                                                                  ^
foo.cpp:2:94: error: expected unqualified-id before 'for'
  freopen("salesman.in","r",stdin);  freopen("salesman.out","w",stdout);     scanf("%d",&n);  for(int i=1;i<=n;i++)   scanf("%d",&s[i]);  for(int i=1;i<=n;i++)  {    scanf("%d",&a[i]);   right[i]=i;  }   sort(right+1,right+n+1,cmpr); }   void choose_left(const int i) {   f[i]=f[i-1]+a[left[1]];   pop_heap(left+1,left+l--+1,cmpl); }   void choose_right(const int i) {   f[i]=f[i-1]+2*(s[right[r]]-s[maxi])+a[right[r]];  for(int i=maxi+1;i<right[r];i++)  {    left[++l]=i;    push_heap(left+1,left+l+1,cmpl);  }   maxi=right[r++];   while(r<=n&&right[r]<=maxi)   r++; }   void solve() {   for(int i=1;i<=n;i++)   if(l==0)    choose_right(i);   else if(r>n)    choose_left(i);    else if(a[left[l]]>=2*(s[right[r]]-s[maxi])+a[right[r]])    choose_left(i);   else    choose_right(i); }   void output() 
                                                                                              ^
foo.cpp:2:106: error: 'i' does not name a type
  freopen("salesman.in","r",stdin);  freopen("salesman.out","w",stdout);     scanf("%d",&n);  for(int i=1;i<=n;i++)   scanf("%d",&s[i]);  for(int i=1;i<=n;i++)  {    scanf("%d",&a[i]);   right[i]=i;  }   sort(right+1,right+n+1,cmpr); }   void choose_left(const int 

信息

递交者
类型
递交
题目
P1977 推销员
语言
C++
递交时间
2016-12-03 16:54:02
评测时间
2016-12-03 16:54:28
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes