Submission #1540559
Source Code Expand
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF ((int)(2e9))
#define LINF ((int)(1e18))
#define out cout <<
#define ln << endl
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define ll long long
#define B out "BreakPoint\n";
#define read(_nowans) scanf("%d",&_nowans)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_nowans1,_nowans2) scanf("%d %d",&_nowans1,&_nowans2)
#define msn(_data,_nowans) memset(_data,_nowans,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_nowans1,_nowans2,_nowans3) scanf("%d %d %d",&_nowans1,&_nowans2,&_nowans3)
#define lb( _x , _y ) ( lower_bound( _x.begin() , _x.end() , _y ) - _x.begin() + 1 )
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print( int _x ){ printf("%d\n",_x); }
_tp<_tyn T>void print( T _data[] , int _size ){
for( int i = 1 ; i <= _size ; i++ )
cout << _data[i] << " ";
cout << endl;
}
#define MAXN 200100
char s[MAXN];
int n;
int main(){
//fin( "B.txt" );
while( scanf("%s",s) != EOF ){
n = strlen(s);
//在第i个字符上
ll ans = 0LL;
for( int i = 1 ; i < n ; i++ ){
int l = i-1 , r = i+1;
/*
while( l >= 0 && r < n && s[l] == s[r] ){
l--;
r++;
}
*/
while( l >= 0 && r < n ){
if( s[l] != s[r] ) ans++;
l--;
r++;
}
}
// cout << "1: " << ans << endl;
//在字符i和i+1之间
for( int i = 0 ; i < n-1 ; i++ ){
int l = i , r = i+1;
/*
while( l >= 0 && r < n && s[l] == s[r] ){
l--;
r++;
}
*/
while( l >= 0 && r < n ){
if( s[l] != s[r] ) ans++;
l--;
r++;
}
}
printf("%lld\n",ans+1);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Reverse and Compare |
User |
interestingLSY |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2439 Byte |
Status |
TLE |
Exec Time |
2103 ms |
Memory |
384 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
All |
sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
1 ms |
256 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
sample_03.txt |
AC |
1 ms |
256 KB |
subtask_1_01.txt |
AC |
1 ms |
256 KB |
subtask_1_02.txt |
TLE |
2103 ms |
384 KB |
subtask_1_03.txt |
AC |
1 ms |
256 KB |
subtask_1_04.txt |
AC |
1 ms |
256 KB |
subtask_1_05.txt |
AC |
1 ms |
256 KB |
subtask_1_06.txt |
AC |
3 ms |
256 KB |
subtask_1_07.txt |
AC |
213 ms |
256 KB |
subtask_1_08.txt |
TLE |
2103 ms |
384 KB |
subtask_1_09.txt |
TLE |
2103 ms |
384 KB |
subtask_1_10.txt |
TLE |
2103 ms |
384 KB |
subtask_1_11.txt |
TLE |
2103 ms |
384 KB |
subtask_1_12.txt |
TLE |
2103 ms |
384 KB |
subtask_1_13.txt |
TLE |
2103 ms |
384 KB |
subtask_1_14.txt |
TLE |
2103 ms |
384 KB |
subtask_1_15.txt |
TLE |
2103 ms |
384 KB |
subtask_1_16.txt |
TLE |
2103 ms |
384 KB |
subtask_1_17.txt |
TLE |
2103 ms |
384 KB |