Submission #3803940


Source Code Expand

# include <bits/stdc++.h>

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
string s;
       
ll ans = 0;

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> s;    

  int cnt = 0;
  for (int i = sz(s) - 1; i >= 0; i--) {
    if (s[i] == 'B')
      ans += cnt;
    else
      cnt++;
  }       
  cout << ans;

  return 0;
}






// Coded by Z..

Submission Info

Submission Time
Task A - Irreversible operation
User Zhanbolat
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1608 Byte
Status AC
Exec Time 3 ms
Memory 720 KiB

Compile Error

./Main.cpp: In function ‘void files(std::string)’:
./Main.cpp:45:50: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
     freopen ((problem + ".in").c_str(),"r",stdin);
                                                  ^
./Main.cpp:46:52: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
     freopen ((problem + ".out").c_str(),"w",stdout);
                                                    ^
./Main.cpp: In function ‘void localInput(const char*)’:
./Main.cpp:51:29: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
     freopen (in, "r", stdin);
                             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 14
Set Name Test Cases
Sample sample01.txt, sample02.txt
All sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
in01.txt AC 3 ms 720 KiB
in02.txt AC 3 ms 720 KiB
in03.txt AC 3 ms 720 KiB
in04.txt AC 3 ms 720 KiB
in05.txt AC 3 ms 720 KiB
in06.txt AC 3 ms 720 KiB
in07.txt AC 3 ms 720 KiB
in08.txt AC 2 ms 720 KiB
in09.txt AC 2 ms 720 KiB
in10.txt AC 2 ms 720 KiB
sample01.txt AC 1 ms 256 KiB
sample02.txt AC 1 ms 256 KiB