Submission #10446685


Source Code Expand

Copy
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

char T[maxN];
set <int> S[400];

void solve()
{
	int n, q;
	scanf ("%d%s%d", &n, T, &q);
	
	FOR(i, 0, n)
		S[T[i]].insert(i);
	FOR(i, 'a', 'z'+1)
		S[i].insert(n+1);
	
	while (q--)
	{
		int ev;
		scanf ("%d", &ev);
		if (ev == 1)
		{
			int i;
			char in[5];
			scanf ("%d%s", &i, in);
			i--;
			S[T[i]].erase(i);
			T[i] = in[0];
			S[T[i]].insert(i);
		}
		
		else
		{
			int a, b;
			scanf ("%d%d", &a, &b);
			a--, b--;
			int res = 0;
			FOR(c, 'a', 'z'+1)
				if (*(S[c].lower_bound(a)) <= b)
					res++;
			printf("%d\n", res);
		}
	}
} 
 
int main()
{
    int t;
    t = 1;//scanf ("%d", &t);
    while (t--)
    	solve();
    return 0;    
}


Submission Info

Submission Time
Task E - Simple String Queries
User bgrm
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1210 Byte
Status AC
Exec Time 256 ms
Memory 24192 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:27:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d%s%d", &n, T, &q);
                             ^
./Main.cpp:37:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d", &ev);
                    ^
./Main.cpp:42:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf ("%d%s", &i, in);
                          ^
./Main.cpp:52:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf ("%d%d", &a, &b);
                          ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 1
AC × 43
Set Name Test Cases
Sample 00-sample-00
All 00-sample-00, 01-handmade-00, 01-handmade-01, 01-handmade-02, 01-handmade-03, 01-handmade-04, 01-handmade-05, 01-handmade-06, 01-handmade-07, 01-handmade-08, 01-handmade-09, 01-handmade-10, 01-handmade-11, 02-small-00, 02-small-01, 02-small-02, 02-small-03, 02-small-04, 02-small-05, 02-small-06, 02-small-07, 02-small-08, 02-small-09, 02-small-10, 02-small-11, 02-small-12, 02-small-13, 02-small-14, 02-small-15, 02-small-16, 02-small-17, 02-small-18, 02-small-19, 03-large-00, 03-large-01, 03-large-02, 03-large-03, 03-large-04, 03-large-05, 03-large-06, 03-large-07, 03-large-08, 03-large-09
Case Name Status Exec Time Memory
00-sample-00 AC 1 ms 256 KB
01-handmade-00 AC 207 ms 24192 KB
01-handmade-01 AC 1 ms 256 KB
01-handmade-02 AC 149 ms 24192 KB
01-handmade-03 AC 256 ms 24192 KB
01-handmade-04 AC 144 ms 24192 KB
01-handmade-05 AC 114 ms 24192 KB
01-handmade-06 AC 199 ms 24192 KB
01-handmade-07 AC 169 ms 24192 KB
01-handmade-08 AC 205 ms 24192 KB
01-handmade-09 AC 145 ms 24192 KB
01-handmade-10 AC 199 ms 24192 KB
01-handmade-11 AC 203 ms 24192 KB
02-small-00 AC 7 ms 256 KB
02-small-01 AC 9 ms 256 KB
02-small-02 AC 7 ms 256 KB
02-small-03 AC 9 ms 256 KB
02-small-04 AC 6 ms 256 KB
02-small-05 AC 6 ms 256 KB
02-small-06 AC 9 ms 256 KB
02-small-07 AC 6 ms 256 KB
02-small-08 AC 6 ms 256 KB
02-small-09 AC 7 ms 256 KB
02-small-10 AC 9 ms 256 KB
02-small-11 AC 6 ms 256 KB
02-small-12 AC 6 ms 256 KB
02-small-13 AC 9 ms 256 KB
02-small-14 AC 7 ms 256 KB
02-small-15 AC 7 ms 256 KB
02-small-16 AC 7 ms 256 KB
02-small-17 AC 6 ms 256 KB
02-small-18 AC 8 ms 256 KB
02-small-19 AC 8 ms 256 KB
03-large-00 AC 213 ms 24192 KB
03-large-01 AC 216 ms 24192 KB
03-large-02 AC 229 ms 24192 KB
03-large-03 AC 218 ms 24192 KB
03-large-04 AC 204 ms 24192 KB
03-large-05 AC 210 ms 24192 KB
03-large-06 AC 202 ms 24192 KB
03-large-07 AC 199 ms 24192 KB
03-large-08 AC 211 ms 24192 KB
03-large-09 AC 207 ms 24192 KB