1、离散化写一次挂一次
cin>>n;
for(int i=1;i<=n;i++){
a[i]=read();b[i]=read();
o[++ont]=a[i];o[++ont]=b[i];
}
sort(o+1,o+1+ont);
int ok=unique(o+1,o+1+ont)-o;
for(int i=1;i<=n;i++){
a[i]=lower_bound(o+1,o+1+ok,a[i])-o-1;
b[i]=lower_bound(o+1,o+1+ok,b[i])-o-1;
}但是这是错的!!!
正确代码:
cin>>n;
for(int i=1;i<=n;i++){
a[i]=read();b[i]=read();
o[++ont]=a[i];o[++ont]=b[i];
}
sort(o+1,o+1+ont);
int ok=unique(o+1,o+1+ont)-o-1;//这里!!!要减一!!!
for(int i=1;i<=n;i++){
a[i]=lower_bound(o+1,o+1+ok,a[i])-o;//这里!!
b[i]=lower_bound(o+1,o+1+ok,b[i])-o;//没有减一!!
}2、小数“-0.000”
这得特判……
好吧,终于记得特判了,但是……
cout<<0.000<<endl;
不负众望,输出是:
0
3、万恶的Dinic
3.1、bfs的时候……
d[ss]=0;
但是会shi循环
应该是:
d[ss]=1;
3.2、建图的时候……
tot=1
忘了加这个,调了一年……
3.3、加边的时候……
void adde(int u,int v,int w){
tot++;
e[tot].nxt=head[u];
e[tot].to=v;
e[tot].w=w;
}又 挂 了 一 年 。 。 。 。 。
void adde(int u,int v,int w){
tot++;
e[tot].nxt=head[u];
e[tot].to=v;
e[tot].w=w;
head[u]=tot;//真想不通怎么忘了这个的
}4、快读(坏读)
inline int read(){
int x=0,f=-1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
return x*f;
}看这乌泱乌泱一大坨的代码,肯定没有问题吧。
呵……你可太小看吾等蒟蒻了喔~~~
inline int read(){
int x=0,f= ×× 1 ×× ;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
return x*f;
}5、数论
关于数论:最难的地方是式子,最坑的地方是取模和括号。
6、运算优先级
!运算符的优先级可能是最高的…………
所以每逢!就加括号就完事…………
7、检查
可以在代码中加些注释以示提醒…………
放到最后检查基本上就只能看看 freopen 之类的……
可能不容易看出来的点:模意义下的分数……