Submission #3474834


Source Code Expand

#include<cstdio>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<vector>
using namespace std;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;
typedef long long int ll;
ll a[200005][30],ans;
char s[200005];
int main()
{
	int i,j,k;
    scanf("%s",s+1);
    memset(a,0,sizeof(a));
    int len=strlen(s+1);
    ans=0;
    for(i=1;i<=len;i++)
    {
        for(j=0;j<26;j++)
            a[i][j]=a[i-1][j];
        a[i][s[i]-'a']++;
    }
    for(i=1;i<=len;i++)
        ans+=len-i-a[len][s[i]-'a']+a[i][s[i]-'a'];
    print(ans+1),putc('\n');
    return 0;
}

Submission Info

Submission Time
Task B - Reverse and Compare
User xusuyang
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1677 Byte
Status AC
Exec Time 25 ms
Memory 47360 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:49:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",s+1);
                    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 23
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 14 ms 47104 KB
sample_02.txt AC 13 ms 47104 KB
sample_03.txt AC 14 ms 47104 KB
subtask_1_01.txt AC 13 ms 47104 KB
subtask_1_02.txt AC 24 ms 47360 KB
subtask_1_03.txt AC 13 ms 47104 KB
subtask_1_04.txt AC 14 ms 47104 KB
subtask_1_05.txt AC 13 ms 47104 KB
subtask_1_06.txt AC 14 ms 47104 KB
subtask_1_07.txt AC 14 ms 47104 KB
subtask_1_08.txt AC 24 ms 47360 KB
subtask_1_09.txt AC 24 ms 47360 KB
subtask_1_10.txt AC 24 ms 47360 KB
subtask_1_11.txt AC 24 ms 47360 KB
subtask_1_12.txt AC 24 ms 47360 KB
subtask_1_13.txt AC 24 ms 47360 KB
subtask_1_14.txt AC 24 ms 47360 KB
subtask_1_15.txt AC 24 ms 47360 KB
subtask_1_16.txt AC 25 ms 47360 KB
subtask_1_17.txt AC 24 ms 47360 KB