Submission #372735


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
template<class T> inline bool amax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool amin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> ostream& operator << (ostream &os, const vector<T> &v) { os << "["; for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); it++) { os << (it != v.begin() ? ", " : "") << *it; } os << "]"; return os; }
template<class T> ostream& operator << (ostream &os, const set<T> &s) { os << "["; for (typename set<T>::const_iterator it = s.begin(); it != s.end(); it++) { os << (it != s.begin() ? ", " : "") << *it; } os << "]"; return os; }
template<class Key, class Val> ostream& operator << (ostream &os, const map<Key, Val> &m) { os << "{"; for (typename map<Key, Val>::const_iterator it = m.begin(); it != m.end(); it++) { os << (it != m.begin() ? ", " : "") << it->first << ":" << it->second; } os << "}"; return os; }
template<class T, class S> ostream& operator << (ostream &os, const pair<T, S> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <class Target, class Source> inline Target lexical_cast (const Source &s) { Target t; stringstream ss; ss << s; ss >> t; return t; }

//> v < ^ (clock wise)
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
const int INFI = 1<<28;
const long long int INFL = 1LL<<60;
const double INFD = 1e+300;
const float INFF = 1e+100;
const double EPS = 1e-8;

int bubble_sort(string s) {
    int n = s.size();
    int res = 0;
    while (1) {
        bool update = false;
        for (int i = 0; i < n-1; i++) {
            if (s[i] < s[i+1]) {
                update = true;
                swap(s[i], s[i+1]);
                res++;
            }
        }
        if (!update) break;
    }
    return res;
}

int main(){
    cout.setf(ios::fixed); cout.precision(10);
    ios_base::sync_with_stdio(false);
    map<int, int> M;
    map<string, int> A;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        cout << bubble_sort(s)%3 << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task F - チェックディジット
User itf
Language C++ (GCC 4.9.2)
Score 200
Code Size 2282 Byte
Status AC
Exec Time 424 ms
Memory 924 KiB

Judge Result

Set Name Subtask00 Subtask01 Subtask02 Subtask03 Subtask04 Subtask05 Subtask06 Subtask07
Score / Max Score 25 / 25 25 / 25 25 / 25 25 / 25 25 / 25 25 / 25 25 / 25 25 / 25
Status
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
Set Name Test Cases
Subtask00 00_n_3e1
Subtask01 01_n_1e2
Subtask02 02_n_3e2
Subtask03 03_n_1e3
Subtask04 04_n_3e3
Subtask05 05_n_1e4
Subtask06 06_n_3e4
Subtask07 07_n_1e5
Case Name Status Exec Time Memory
00_n_3e1 AC 26 ms 804 KiB
01_n_1e2 AC 24 ms 924 KiB
02_n_3e2 AC 28 ms 808 KiB
03_n_1e3 AC 40 ms 736 KiB
04_n_3e3 AC 39 ms 800 KiB
05_n_1e4 AC 65 ms 800 KiB
06_n_3e4 AC 141 ms 800 KiB
07_n_1e5 AC 424 ms 808 KiB
sample AC 26 ms 808 KiB