제출 #1095740

#제출 시각아이디문제언어결과실행 시간메모리
1095740MMihalev도시들 (IOI15_towns)C++14
컴파일 에러
0 ms0 KiB
#include "towns.h" #include<iostream> #include<algorithm> #include<set> #include<cmath> using namespace std; const int MAX_N=2e2+2; int diam; int tov[MAX_N]; int tou[MAX_N]; int to0[MAX_N]; int n; bool check(int a,int b) { if(tou[a]+tov[b]-diam==getDistance(a,b))return 0; return 1; } int hubDistance(int N, int sub) { n=N; int u=0; int far=0,v; for(int i=1;i<n;i++) { int cur=getDistance(u,i); to0[i]=cur; if(cur>far) { far=cur; v=i; } }//0->v diam=0; for(int i=0;i<n;i++) { if(i==v)continue; int cur; if(i==0)cur=to0[v]; else cur=getDistance(i,v); tov[i]=cur; if(cur>diam) { diam=cur; u=i; } }//v->u for(int i=0;i<n;i++) { if(i==u)continue; if(i==0)tou[i]=to0[u]; if(i==v)tou[i]=tov[u]; tou[i]=getDistance(u,i); }//u->all int cntneg=1,cntpos=1,cntbase=0; int mindif=1e9; set<int>nodes; for(int i=0;i<n;i++) { if(i==u or i==v)continue; int x=tou[i]; int y=tov[i]; int com=((x+y)-diam)/2; x-=com; y-=com; int res=x-y; mindif=min(mindif,abs(res)); } for(int i=0;i<n;i++) { if(i==u or i==v)continue; int x=tou[i]; int y=tov[i]; int com=((x+y)-diam)/2; x-=com; y-=com; int res=x-y;        if(abs(res)==mindif){cntbase++;nodes.insert(i);} else if(res<0)cntneg++; else cntpos++; } int R=(diam-mindif)/2+mindif;    if(sub==4 or sub<=2) { if(cntbase*2<=n && cntpos*2<=n && cntneg*2<=n)R*=1; else R*=-1; return R; }    if(cntbase*2>n or cntneg*2>n or cntpos*2>n)return -R; while(1) { int cnt=1; int uu=(*(nodes.begin())); nodes.erase(u); auto it=nodes.begin(); while(it!=nodes.end()) { if(check(uu,(*it))) { cnt++; it=nodes.erase(it); } else it++; } if(2*cnt>n)return -R; } return R; }

컴파일 시 표준 에러 (stderr) 메시지

towns.cpp:93:2: error: extended character   is not valid in an identifier
   93 |         if(abs(res)==mindif){cntbase++;nodes.insert(i);}
      |  ^
towns.cpp:93:5: error: extended character   is not valid in an identifier
   93 |         if(abs(res)==mindif){cntbase++;nodes.insert(i);}
      |    ^
towns.cpp:93:8: error: extended character   is not valid in an identifier
   93 |         if(abs(res)==mindif){cntbase++;nodes.insert(i);}
      |      ^
towns.cpp:93:11: error: extended character   is not valid in an identifier
   93 |         if(abs(res)==mindif){cntbase++;nodes.insert(i);}
      |        ^
towns.cpp:100:2: error: extended character   is not valid in an identifier
  100 |     if(sub==4 or sub<=2)
      |  ^
towns.cpp:100:5: error: extended character   is not valid in an identifier
  100 |     if(sub==4 or sub<=2)
      |    ^
towns.cpp:108:2: error: extended character   is not valid in an identifier
  108 |     if(cntbase*2>n or cntneg*2>n or cntpos*2>n)return -R;
      |  ^
towns.cpp:108:5: error: extended character   is not valid in an identifier
  108 |     if(cntbase*2>n or cntneg*2>n or cntpos*2>n)return -R;
      |    ^
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:93:2: error: '\U000000a0' was not declared in this scope
   93 |         if(abs(res)==mindif){cntbase++;nodes.insert(i);}
      |  ^
towns.cpp:94:9: error: 'else' without a previous 'if'
   94 |         else if(res<0)cntneg++;
      |         ^~~~
towns.cpp:100:2: error: '\U000000a0' was not declared in this scope
  100 |     if(sub==4 or sub<=2)
      |  ^
towns.cpp:108:4: error: expected ';' before '\U000000a0if'
  108 |     if(cntbase*2>n or cntneg*2>n or cntpos*2>n)return -R;
      |   ^~~~
      |   ;
towns.cpp:61:27: warning: unused variable 'cntbase' [-Wunused-variable]
   61 |     int cntneg=1,cntpos=1,cntbase=0;
      |                           ^~~~~~~
towns.cpp:18:28: warning: unused parameter 'sub' [-Wunused-parameter]
   18 | int hubDistance(int N, int sub)
      |                        ~~~~^~~