제출 #135396

#제출 시각아이디문제언어결과실행 시간메모리
135396Boxworld말 (IOI15_horses)C++14
17 / 100
1564 ms8496 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; struct year{int x,y;}a[500100]; long long s[500100]; string ans,ho; int n; string cmp(string a,string b){ int la=a.length(),lb=b.length(); if (la>lb)return a; if (la<lb)return b; for (int i=0;i<la;i++){ if (a[i]<b[i])return b; else if (a[i]>b[i])return a; } return b; } int mod(string a){ long long tmp=0,big=1000000007; for (int i=0;i<a.length();i++){ tmp=tmp*10+int(a[i])-48; tmp%=big; } return (int)tmp; } string mul(string sa,int b){ s[0]=sa.length(); for (int i=0;i<s[0];i++)s[s[0]-i]=((long long)(sa[i])-48)*b; for (int i=1;i<s[0];i++){ s[i+1]+=s[i]/10; s[i]%=10; } while(s[s[0]]>=10){ s[s[0]+1]=s[s[0]]/10; s[s[0]]%=10; s[0]++; } while(s[s[0]]==0&&s[0]>1)s[0]--; string ss=""; for (int i=s[0];i>0;i--){ ss+=char(s[i]+48); s[i]=0; } return ss; } int init(int N, int X[], int Y[]){ n=N; for (int i=0;i<n;i++){a[i].x=X[i];a[i].y=Y[i];} ho="1";ans="0"; for (int i=0;i<n;i++){ ho=mul(ho,a[i].x); string s=mul(ho,a[i].y); ans=cmp(ans,s); // cout<<"YEAR#"<<i<<" horse="<<ho<<" money="<<s<<" ans="<<ans<<"\n"; } return mod(ans); } int updateX(int pos, int val) { a[pos].x=val; ho="1";ans="0"; for (int i=0;i<n;i++){ ho=mul(ho,a[i].x); string s=mul(ho,a[i].y); ans=cmp(ans,s); // cout<<"YEAR#"<<i<<" horse="<<ho<<" money="<<s<<" ans="<<ans<<"\n"; } return mod(ans); } int updateY(int pos, int val) { a[pos].y=val; ho="1";ans="0"; for (int i=0;i<n;i++){ ho=mul(ho,a[i].x); string s=mul(ho,a[i].y); ans=cmp(ans,s); // cout<<"YEAR#"<<i<<" horse="<<ho<<" money="<<s<<" ans="<<ans<<"\n"; } return mod(ans); }

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

horses.cpp: In function 'std::__cxx11::string cmp(std::__cxx11::string, std::__cxx11::string)':
horses.cpp:8:29: warning: declaration of 'a' shadows a global declaration [-Wshadow]
 string cmp(string a,string b){
                             ^
horses.cpp:4:22: note: shadowed declaration is here
 struct year{int x,y;}a[500100];
                      ^
horses.cpp:9:20: warning: conversion to 'int' from 'std::__cxx11::basic_string<char>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
     int la=a.length(),lb=b.length();
            ~~~~~~~~^~
horses.cpp:9:34: warning: conversion to 'int' from 'std::__cxx11::basic_string<char>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
     int la=a.length(),lb=b.length();
                          ~~~~~~~~^~
horses.cpp: In function 'int mod(std::__cxx11::string)':
horses.cpp:18:17: warning: declaration of 'a' shadows a global declaration [-Wshadow]
 int mod(string a){
                 ^
horses.cpp:4:22: note: shadowed declaration is here
 struct year{int x,y;}a[500100];
                      ^
horses.cpp:20:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<a.length();i++){
                  ~^~~~~~~~~~~
horses.cpp: In function 'std::__cxx11::string mul(std::__cxx11::string, int)':
horses.cpp:40:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     for (int i=s[0];i>0;i--){
                ~~~^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:53:16: warning: declaration of 's' shadows a global declaration [-Wshadow]
         string s=mul(ho,a[i].y);
                ^
horses.cpp:5:11: note: shadowed declaration is here
 long long s[500100];
           ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:65:16: warning: declaration of 's' shadows a global declaration [-Wshadow]
         string s=mul(ho,a[i].y);
                ^
horses.cpp:5:11: note: shadowed declaration is here
 long long s[500100];
           ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:77:16: warning: declaration of 's' shadows a global declaration [-Wshadow]
         string s=mul(ho,a[i].y);
                ^
horses.cpp:5:11: note: shadowed declaration is here
 long long s[500100];
           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...