#include<stdio.h> #include<cstring> using namespace std; struct node { long x,y; } p[10001]; char flag[2001];//<strong><span style="color:#ff0000;">如果是int 超时!!!</span></strong> long st,ed,n,m,i,j,tem,ans,tx,ty,k,tt; <span style="color:#ff0000;"><strong>inline</strong></span> long jug(long x)//inline <strong>用时少一点</strong> { if(x<st) return x+n; return x; } int main() { scanf("%ld%ld",&n,&m); for(i=1; i<=m; i++) { scanf("%ld%ld",&p[i].x,&p[i].y); if(p[i].x>p[i].y) { tt=p[i].x; p[i].x=p[i].y; p[i].y=tt; } } ans=n; for(i=1; i<n; i++)//枚举每一个点 { memset(flag,0,sizeof(flag)); st=i,ed=st+n-1,tem=0;//<span style="font-size:18px;">在枚举到一点时,将该点设为起始点,则相应的终点也在改起始点的基础上增大n-1 </span> for(j=1; j<=m; j++) { tx=jug(p[j].x);//判断 如果点对中的点<起始点 将该点增大n,变成直线中的对应的新点 ty=jug(p[j].y); if(tx>ty)//输入的点对 在起始点不同的时候 相对编号也不同 { tt=tx; tx=ty; ty=tt; } for(k=tx; k<ty; k++)//将每一个点对之间的连线记录 flag[k]=1; } for(j=st; j<=ed; j++) if(flag[j]) tem++; if(ans>tem) ans=tem; } printf("%ld",ans); return 0; } /* F:\temp\16139622.54639\Main.cc:11: error: expected unqualified-id before '<' token F:\temp\16139622.54639\Main.cc: In function 'int main()': F:\temp\16139622.54639\Main.cc:37: error: 'jug' was not declared in this scope */ |
Double click to view unformatted code.