#4377: 真不懂


jason3e7 (jason3e7)

學校 : 不指定學校
編號 : 6907
來源 : [123.194.129.186]
最後登入時間 :
2018-12-29 23:03:42
c077. 00417 - Word Index -- UVa417 | From: [114.39.214.115] | 發表日期 : 2010-10-10 17:01

為什麼 UVa會過

這裡都不會過...

真奇怪

 
#4379: Re:真不懂


jason3e7 (jason3e7)

學校 : 不指定學校
編號 : 6907
來源 : [123.194.129.186]
最後登入時間 :
2018-12-29 23:03:42
c077. 00417 - Word Index -- UVa417 | From: [114.39.214.115] | 發表日期 : 2010-10-10 17:11

為什麼 UVa會過

這裡都不會過...

真奇怪


忘了附上原始碼

#include<iostream>
using namespace std;
bool checksb(string );

int main()
{
string all[83682];
int point[5]={0};
int pointend=0;
int count=1;
while(count<=83681)
{
int word=0;
while(pointend-word>=0)
{
all[count]+=(char)(point[word]+'a');
word++;
}
//cout<<all[count]<<endl;

int temp=0;
int begin=pointend;
while(point[pointend-temp]>=(25-temp))// over
{
begin--;
temp++;
}


if(begin==pointend)//one
{
point[begin]++;
}
else//more one
{
if(begin==(-1))
{
point[0]=0;
pointend++;
for(int i=1;i<=pointend;i++)
{
point[i]=point[i-1]+1;
}
}
else
{
point[begin]++;
for(int i=begin+1;i<=pointend;i++)
{
point[i]=point[i-1]+1;
}
}
}

count++;
}
string s;
while(cin>>s)
{
if(checksb(s)==true)
{
for(int i=1;i<=83681;i++)
{
if(s==all[i])
{
cout<<i<<endl;
break;
}
}
}
else
{
cout<<"0"<<endl;
}
}
}

bool checksb(string s)
{
for(int i=1;i<s.length();i++)
if(s[i]<=s[i-1])
return false;
return true;
}

 

 
ZeroJudge Forum