C++ 中的名称冲突之 "y1"
已经是第二次遇到这个问题了:
#include <bits/stdc++.h>
using namespace std; const int N(); int dp[N][][N][][N];
int x1, x2, y1, y2; int dfs(int x1, int s, int x2, int t, int y){
int & now=dp[x1][s][x2][t][y];
if(~now) return now;
int sum=, cnt=;
if(s==){
sum+=dfs(x1, , x2, t, y-), cnt++;
if(t==)
sum+=dfs(x1, s, x2, , y-), cnt++;
else if(x2>)
sum+=dfs(x1, , x2-, t, y), cnt++;
}
else{
if(x1>) sum+=dfs(x1-, s, x2, t, y), cnt++;
if(t==)
sum+=dfs(x1, s, x2, , y-), cnt++;
else if(x2>)
sum+=dfs(x1, s, x2-, t, y), cnt++;
} if((y1+)*(-s)+(y2+)*(-t)< y) //forbidden numbers;
sum+=dfs(x1, s, x2, t, y-), cnt++; return now = sum!=cnt;
} int a[N]; int main(){
int T;
int n;
for(cin>>T; T--; ){
cin>>n;
int p;
for(int i=; i<n; i++){
cin>>a[i];
if(a[i]==) p=i;
}
x1=, x2=, y1=, y2=;
int i; for(i=p-; i>= && a[i]>a[i+]; i--, x1++); for(; i>= && a[i]<a[i+]; i--, y1++);
for(i=p+; i<n && a[i]>a[i-]; i++, x2++);
for(; i<n && a[i]<a[i-]; i++, y2++); memset(dp, -, sizeof(dp));
x1=max(x1-, ), x2=max(x2-, ); // cout<<x1<<' '<<x2<<' '<<y1<<' '<<y2<<endl;
int peak=(p!=) + (p!=n-);
for(int i=; i<=n--x1-x2-peak; i++)
dp[][][][][i]=; //error-prone int s=p==, t=p==n-; //error-prone int res=dfs(x1, s, x2, t, n--x1-x2);
// cout<<res<<endl;
puts(res==?"Alice": "Bob");
}
return ;
}
试图在终端编译,运行: (gcc version 4.8.4)
g++ main.cpp -std=c++ -o main && ./main <in
返回结果:
main.cpp::: error: ‘int y1’ redeclared as different kind of symbol
int x1, x2, y1, y2;
^
In file included from /usr/include/features.h::,
from /usr/include/assert.h:,
from /usr/include/c++/4.8/cassert:,
from /usr/include/x86_64-linux-gnu/c++/4.8/bits/stdc++.h:,
from main.cpp::
/usr/include/x86_64-linux-gnu/bits/mathcalls.h::: error: previous declaration of ‘double y1(double)’
__MATHCALL (y1,, (_Mdouble_));
^
显示变量 y1 和 C++ 标准库中的某个变量名称冲突,这个问题应当引起注意。
另外这不是头文件写成 <bits/stdc++.h> 引起的,即使换成各具体的头文件(<iostream>, <algorithm>, <ctring>)还是会发生这个错误。
具体原因及解决办法还有待研究。
C++ 中的名称冲突之 "y1"的更多相关文章
- ArcMap中的名称冲突问题
这是一个非常有趣的问题. 现在我一个点层叫"汶川73",有一个面层也叫"汶川73",使用空间连接工具来计算每个面中被落入有多少个点.但不管怎么算,结果都只能生成 ...
- jQuery 名称冲突
jQuery 名称冲突 jQuery 使用 $ 符号作为 jQuery 的简介方式. 某些其他 JavaScript 库中的函数(比如 Prototype)同样使用 $ 符号. jQuery 使用名为 ...
- hadoop+javaWeb的开发中遇到包冲突问题(java.lang.VerifyError)
1.HDFS + WEB 项目 报java.lang.VerifyError... 异常 抛异常: Exception in thread "main" java.lang.Ver ...
- LINQ-to-SQL那点事~LINQ-to-SQL中的并发冲突与应对
回到目录 在上一篇文章中提到了并发冲突,还说详细的说明在这讲来说,呵呵,那现在就说一下吧! 并发冲突产生的原因 事实上,linq to sql中的并发冲突是指记录在进行update操作时,客户端A1取 ...
- jQuery中 $ 符号的冲突问题
jQuery中 $ 符号的冲突问题是常见问题之一. 在jQuery中,$是jQuery的别名,为了书写方便,我们更习惯用$('#id')这一类的方式来书写代码.当同一页面引用了jQuery多个版本 ...
- MyEclipse中修改项目运行地址栏中项目名称
MyEclipse中修改项目运行地址栏中项目名称 1.如果出现从SVN上检出的项目名称跟运行地址栏中的项目名称不一致, 可以通过以下步骤进行修改 项目鼠标右键,单击"Properties&q ...
- org.xml.sax.SAXParseException;在实体引用中, 实体名称必须紧跟在 '&' 后面
错误信息如下:org.xml.sax.SAXParseException;在实体引用中, 实体名称必须紧跟在 ‘’&’’ 后面 出现这个错误的原因是在xml中使用&,实际上xml中不支 ...
- php获取指定文件夹中文件名称
/** * php获取指定文件夹中文件名称 * @author jackie <2018.10.10> */ public static function getFileName($fil ...
- Spring 中参数名称解析 - ParameterNameDiscoverer
Spring 中参数名称解析 - ParameterNameDiscoverer Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.ht ...
随机推荐
- 程序4-6 utime函数实例
//http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...
- Asp.net mvc项目架构分享系列之架构搭建初步
copy to:http://www.cnblogs.com/ben121011/p/5014795.html 项目架构各部分解析 Core Models IDAL MSSQLDAL IBLL BLL ...
- Struts登录
- S2--《深入.NET平台和C#编程》
第一章 深入.NET框架 1.1 Microsoft .NET框架概述 .NET框架的优势 * 提供了一个面向对象的编程环境,完全支持面向对象编程,.NET 框架提高了软件的可复用性,可扩展 ...
- yslow性能优化的35条黄金守则
参考Best Practices for Speeding Up Your Web Site Exceptional Performance 团队总结了一系列优化网站性能的方法,分成了7个大类35条, ...
- zabbix一件漂亮的外衣配置
http://www.cnblogs.com/yyhh/archive/2015/09/08/4792830.html
- PowerDesigner16建表在SQL SERVER 2008报 对象名 'sysproperties' 无效。
http://blog.itpub.net/30150152/viewspace-1454979/
- Activiti系列:带有serviceTask的或者定时启动任务的流程部署失败的原因分析
在将两个带有serviceTask任务的流程部署到数据库的时候发现无法导入,最终分析出如下问题: 1)流程1是打算让定时启动事件可以每小时触发一次 由于原来是用 R/2015-11-01T01:00: ...
- WPF打印原理,自定义打印
一.基础知识 1.System.Printing命名空间 我们可以先看一下System.Printing命名空间,东西其实很多,功能也非常强大,可以说能够控制打印的每一个细节,曾经对PrintDial ...
- java8新特性全面解析
在Java Code Geeks上有大量的关于Java 8 的教程了,像玩转Java 8--lambda与并发,Java 8 Date Time API 教程: LocalDateTime和在Java ...