如果您想了解CF4C_Registrationsystem题解和cft4真题的知识,那么本篇文章将是您的不二之选。我们将深入剖析CF4C_Registrationsystem题解的各个方面,并为您解答
如果您想了解CF4C_Registration system 题解和cft4真题的知识,那么本篇文章将是您的不二之选。我们将深入剖析CF4C_Registration system 题解的各个方面,并为您解答cft4真题的疑在这篇文章中,我们将为您介绍CF4C_Registration system 题解的相关知识,同时也会详细的解释cft4真题的运用方法,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- CF4C_Registration system 题解(cft4真题)
- An iterative image registration technique with an application to stereo vision笔记
- asp.net – NLogConfigurationException – 从’System.String’到’System.Uri’的无效转换
- asp.net-mvc – 为什么Visual Studio 2010混合了System.Web和System.Web.Abstractions?
- asp.net-mvc-5 – 尝试安全透明方法’System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’访问安全关键方法失败
CF4C_Registration system 题解(cft4真题)
Registration system / 注册系统
CodeForce Round 4 C
题目连接:CF4C
题目描述
A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible,that‘s why they ask you to help. You‘re suggested to implement the prototype of site registration system. The system should work on the following principle.
Each time a new user wants to register,he sends to the system a request with his name. If such a name does not exist in the system database,it is inserted into the database,and the user gets the response OK,confirming the successful registration. If the name already exists in the system database,the system makes up a new user name,sends it to the user as a prompt and also inserts the prompt into the database. The new name is formed by the following rule. Numbers,starting with 1,are appended one after another to name (name1,name2,...),among these numbers the least ii is found so that name ii does not yet exist in the database.
输入格式
The first line contains number nn ( 1<=n<=10^{5}1<=n<=105 ). The following nn lines contain the requests to the system. Each request is a non-empty line,and consists of not more than 32 characters,which are all lowercase Latin letters.
输出格式
Print nn lines,which are system responses to the requests: OK in case of successful registration,or a prompt with a new name,if the requested name is already taken.
题意翻译
题目背景
一个名为"Berlanddesk"的电子邮件系统即将在Berland上线运营。该电子邮件系统的管理员希望整个系统的建设可以尽早完成,因此他们找到了资深程序员您,希望您能够为他们开发一个用户注册系统的原型产品。
该系统的运行遵循以下原则:
新用户注册时,他将向系统发送一则内容为其用户名的请求,如果该用户名尚未存在于系统数据库内,则将该用户名插入数据库,同时用户得到回应信息"OK"表示其已经成功注册。如果用户请求的用户名已经存在于数据库内,那么系统将产生一个新的用户名并将其加入数据库。新用户名由用户请求的用户名与正整数i构成,i为使"用户名i"尚未存在于数据库内的最小的i。
输入格式
第一行一个整数n(1<=n<=10^5)。接下来n行,每行表示用户向系统发出的一则请求。每行内容均非空且均为由至多32个小写拉丁字母组成的字符串。
输出格式
n行,每行表示系统对一则请求做出的回应。如果该用户名尚未存在于系统数据库内,则输出"OK"。如果用户请求的用户名已经被注册,则输出依照规则生成的新用户名。
输入输出样例
输入 #1
4 abacaba acaba abacaba acab
输出 #1
OK OK abacaba1 OK
输入 #2
6 first first second second third third
输出 #2
OK first1 OK second1 OK third1
思路
题意
整个题目的大概意思就是找重复值,没有重复过就直接输出OK
,如果重复就输出原字符串+重复的次数。
类似于在桌面新建文件夹,有重名的就在后面加一个标号。
最开始想到的
读题后,想直接进行模拟。输入用户名然后存入,在从数组中查找,找到一次统计量count就加一次。然而,题目的数据量是\(10^5\),而且是字符串,直接模拟然后查找必然会超时。
简单优化
超时是因为对于每一个新加入的数据,都需要从头查到尾,举一个最极端的例子,假如输入100个字符串,全部都是“Hello”,可以发现,我们循环查找的次数分别是\(1,2,3……100\)。对于这些重复的字符串我们能不能把统计的结果记下来,减少重复搜索呢?显然这是可以的。对于每次加入的重复的字符串,它们的值已经存储了,增加的只是数量,我们可以另开一个数组记录这个数量。
参考代码
//CF4C_Registration system #include<bits/stdc++.h> #define MAXN 100000 using namespace std; string name[MAXN + 5];//存储用户名,相同用户名只存储一次,重复输入只增加对应的cnt数 int cnt[MAXN + 5];//存储用户名出现的次数 int main(){ int n; string s; int num = 0;//记录输入的 不同的 用户名的数量 cin >> n; for(int i = 1; i <= n; i++){ bool flag = 0; cin >> s; for(int j = 0; j < num; j++){ if(name[j] == s){ cnt[j]++;//找到相同的,记录+1 cout << s << cnt[j] << endl; flag = 1; break; } } if(flag == 0){//未找到相同的,添加新记录再输出 name[num] = s; num++; cout << "OK" << endl; } } return 0; }
An iterative image registration technique with an application to stereo vision笔记
【摘要】 主要讲了图像配准的一种方法–利用图像的空间强度梯度和牛顿迭代法找到好的匹配。此方法更快(仅从较少的匹配中筛选)且适用于旋转、尺度、裁剪等变换。
【简介】 图像配准在计算机视觉中的图像匹配,模式识别和运动分析中应用广泛。但是现存的方法代价大且不能处理旋转或者其他变形的情况。
提出了一种新的技术–采用空间强度梯度信息找到最佳匹配。这样就可以利用更多图像信息找到两幅图的最佳匹配。这种方法比按固定顺序计算可能的配准位置需要比较的次数更少。此法利用了许多应用中两幅图已经近似配准了,且可以处理任何线性形变。最后介绍了其在双目视觉系统中的应用。
【配准问题介绍】
给定函数F(x)和G(x),分别表示各自在两幅图中的像素值,x是个向量。要求一个视差矢量h,使F(x+h)和G(x)的某些距离测度最小,其中x是R中的一些区域(难道不是R的全部?)。如图1
三种典型的距离度量:
本文将提出一种更一般化的图像差度度量方法,L2 norm和归一化相关都是该方法的特例。L1 norm可以看做是L2 norm的一种合理逼近。
【现存技术】
- 一种最显而易见的配准方法就是穷举搜索h的可能值空间,计算其距离。但非常低效。
- 爬山法。根据上次的h计算其附近可以使函数值下降的h作为下个h值,这样迭代。但可能会陷入局部最优。
- 序贯想相似性
asp.net – NLogConfigurationException – 从’System.String’到’System.Uri’的无效转换
调用NLog.Config.XmlLoggingConfiguration.Initialize时,会发生以下异常:
“在WebService目标[Target_AuditLog_WebService_Global]上设置属性’Url’时出错”
内部异常:“从’System.String’到’System.Uri’的无效转换.
目标看起来像这样:
<target name="Target_AuditLog_WebService_Global" xsi:type="WebService" namespace="http://ourLoggingServer.corp/" protocol="Soap12" methodName="AddLog" url="http://ourLoggingServer.corp/Logger.asmx"> <parameter /> <!-- Several params,none of type system.uri --> </target>
我发现这似乎他们认为它固定:
http://nlog.codeplex.com/workitem/5352
解决方法
asp.net-mvc – 为什么Visual Studio 2010混合了System.Web和System.Web.Abstractions?
此代码示例来自Steven Sanderson的“Pro ASP.NET MVC2 Framework”一书.
[TestMethod] public void HomePage_Recognizes_New_Visitor_And_Sets_Cookie() { // Arrange: First prepare some mock context objects var mockContext = new Mock<HttpContextBase>(); var mockRequest = new Mock<HttpRequestBase>(); var mockResponse = new Mock<HttpResponseBase>(); // The following lines define associations between the different mock objects // (i.e. tells Moq what alue to use for tMockContext.Request) mockContext.Setup(x=> x.Request).Returns(mockRequest.Object); mockContext.Setup(x=> x.Response).Returns(mockResponse.Object); mockRequest.Setup(x=> x.Cookies).Returns(new HttpCookieCollection()); mockResponse.Setup(x=> x.Cookies).Returns(new HttpCookieCollection()); var homeController = new HomeController(); var requestContext = new RequestContext(mockContext.Object,new RouteData()); homeController.ControllerContext = new ControllerContext(requestContext,homeController); // Act ViewResult viewResult = homeController.HomePage(); // Assert Assert.AreEqual(String.Empty,viewResult.ViewName); Assert.IsTrue((bool)viewResult.ViewData["IsFirstVisit"]); Assert.AreEqual(1,homeController.Response.Cookies.Count); Assert.AreEqual(bool.TrueString,homeController.Response.Cookies["HasVisitedBefore"].Value); }
我的项目引用了System.Web和System.Web.Abstractions库.
当代码文件只是“使用System.Web”时,我得到两个错误:
>(‘Assert’一词下的第25行)’System.Web.HttpResponseBase’类型在未引用的程序集中定义.您必须添加对程序集’System.Web.Abstractions,Version = 3.5.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35’的引用.
>(第25行和第26行,单词’Cookies’)’System.Web.HttpResponseBase’不包含’Cookies’的定义,也没有扩展方法’Cookies’接受’System.Web.HttpResponseBase’类型的第一个参数可以找到(你错过了使用指令或程序集引用吗?)
如果我将“使用System.Web.Abstractions”添加到代码文件并构建项目,上面的错误消失但后来我收到以下错误:
>名称空间’System.Web’中不存在类型或命名空间名称’Abstractions'(您是否缺少程序集引用?)
有趣的是,在两种情况下,当我在Response之后放置一个点时,Intellisense会提示我正确的选择(即Response.Cookies).似乎Intellisense有关于HttpResponseBase的信息,而构建引擎却没有.
知道可能导致这种情况的原因吗?
解决方法
使用从Apress站点下载的书籍的源代码,我可以毫无错误地构建您的代码,但是当我删除对System.Web.Abstractions的引用时,我会得到相同的行为,包括您注意到的intellisense信息提示.
asp.net-mvc-5 – 尝试安全透明方法’System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’访问安全关键方法失败
应用程序在某些机器上成功运行,但不是我的.它也不会在Web服务器上运行.
我已将System.Web.* dll的版本与工作机器上的版本进行了比较,它们看起来是相同的.
我也跟着我发现的其他线程的修复,但无济于事.我将不得不再次搜索找到我尝试过的那些,但这是我记得的第一个.
> Attempt by security transparent method ‘WebMatrix.WebData.PreApplicationStartCode.Start()’
我还需要更改/更新以防止出现此问题?
这是错误和堆栈跟踪:
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
例外细节:
System.MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisteradminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly,System.String)' Failed.
来源错误:
在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.
堆栈跟踪:
[MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisteradminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly,System.String)' Failed.] System.Web.WebPages.Administration.SiteAdmin.RegisteradminModule() +96 System.Web.WebPages.Administration.PreApplicationStartCode.Start() +41 [InvalidOperationException: The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisteradminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly,System.String)' Failed..] System.Web.Compilation.BuildManager.InvokePreStartinitMethodscore(ICollection`1 methods,Func`1 setHostingEnvironmentCultures) +547 System.Web.Compilation.BuildManager.InvokePreStartinitMethods(ICollection`1 methods) +132 System.Web.Compilation.BuildManager.CallPreStartinitMethods(String preStartinitListPath,Boolean& isRefAssemblyLoaded) +102 System.Web.Compilation.BuildManager.ExecutePreAppStart() +153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException) +521 [HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisteradminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly,System.String)' Failed..] System.Web.HttpRuntime.FirstRequestinit(HttpContext context) +9931916 System.Web.HttpRuntime.EnsureFirstRequestinit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context) +254
UPDATE
这是我的web.config中的一些信息
<compilation debug="true" targetFramework="4.5.2"> <assemblies> <add assembly="System.Web.Abstractions,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers,Version=3.0.0.0,PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing,PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc,Version=5.0.0.0,PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages.Razor,PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages,PublicKeyToken=31BF3856AD364E35" /> ... </assemblies> </compilation> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Windows.Forms" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Drawing" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Services" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Abstractions" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Routing" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly> </assemblyBinding>
解决方法
关于CF4C_Registration system 题解和cft4真题的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于An iterative image registration technique with an application to stereo vision笔记、asp.net – NLogConfigurationException – 从’System.String’到’System.Uri’的无效转换、asp.net-mvc – 为什么Visual Studio 2010混合了System.Web和System.Web.Abstractions?、asp.net-mvc-5 – 尝试安全透明方法’System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()’访问安全关键方法失败等相关知识的信息别忘了在本站进行查找喔。
本文标签: