Submission #10453561


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  string s; cin >> s;
  int Q = nextInt();

  set<int> pos[26];
  REP(i, N) {
    pos[s[i] - 'a'].insert(i);
  }

  REP(qi, Q) {
    int t = nextInt();
    int a = nextInt();
    // cout << t << " " << a << " " << b << endl;
    if (t == 1) {
      a--;
      char b; cin >> b;
      pos[ s[a] - 'a' ].erase(a);
      pos[ b - 'a' ].insert(a);
      s[a] = b;
    }
    if (t == 2) {
      a--;
      int b = nextInt() - 1;
      int ans = 0;
      REP(i, 26) {
        auto i1 = pos[i].lower_bound(a);
        auto i2 = pos[i].upper_bound(b);
        if (i1 != i2) ans++;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Submission Info

Submission Time
Task E - Simple String Queries
User hs484
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1381 Byte
Status AC
Exec Time 440 ms
Memory 24196 KB

Compile Error

./Main.cpp: In function ‘int nextInt()’:
./Main.cpp:14:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 int nextInt() { int x; scanf("%d", &x); return x;}
                                       ^
./Main.cpp: In function ‘ll nextLong()’:
./Main.cpp:15:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 ll nextLong() { ll x; scanf("%lld", &x); return x;}
                                        ^

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 241 ms 24196 KB
01-handmade-01 AC 1 ms 256 KB
01-handmade-02 AC 178 ms 24196 KB
01-handmade-03 AC 440 ms 24196 KB
01-handmade-04 AC 266 ms 24196 KB
01-handmade-05 AC 154 ms 24196 KB
01-handmade-06 AC 288 ms 24196 KB
01-handmade-07 AC 253 ms 24196 KB
01-handmade-08 AC 234 ms 24196 KB
01-handmade-09 AC 259 ms 24196 KB
01-handmade-10 AC 229 ms 24196 KB
01-handmade-11 AC 227 ms 24196 KB
02-small-00 AC 13 ms 256 KB
02-small-01 AC 19 ms 256 KB
02-small-02 AC 14 ms 256 KB
02-small-03 AC 20 ms 256 KB
02-small-04 AC 13 ms 256 KB
02-small-05 AC 12 ms 256 KB
02-small-06 AC 21 ms 256 KB
02-small-07 AC 13 ms 256 KB
02-small-08 AC 13 ms 256 KB
02-small-09 AC 14 ms 256 KB
02-small-10 AC 19 ms 256 KB
02-small-11 AC 13 ms 256 KB
02-small-12 AC 13 ms 256 KB
02-small-13 AC 18 ms 256 KB
02-small-14 AC 16 ms 256 KB
02-small-15 AC 16 ms 256 KB
02-small-16 AC 16 ms 256 KB
02-small-17 AC 13 ms 256 KB
02-small-18 AC 16 ms 256 KB
02-small-19 AC 16 ms 256 KB
03-large-00 AC 291 ms 24196 KB
03-large-01 AC 312 ms 24196 KB
03-large-02 AC 294 ms 24196 KB
03-large-03 AC 287 ms 24196 KB
03-large-04 AC 287 ms 24196 KB
03-large-05 AC 284 ms 24196 KB
03-large-06 AC 334 ms 24196 KB
03-large-07 AC 310 ms 24196 KB
03-large-08 AC 325 ms 24196 KB
03-large-09 AC 346 ms 24196 KB