QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#460596#8829. AibohphobiaQwertyPi#Compile Error//C++142.8kb2024-07-01 21:19:302024-07-01 21:19:30

Judging History

你现在查看的是最新测评结果

  • [2024-07-01 21:19:30]
  • 评测
  • [2024-07-01 21:19:30]
  • 提交

answer

#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define sz(a) (int) (a).size();
using namespace std;

void solve() {
    string s; cin >> s;
    map<char, int> M;
    for (auto c : s) {
        M[c]++;
    }

    if (M.size() == 1) {
        if (s.size() == 1) {
            cout << "YES" << '\n';
            cout << s << '\n';
        } else {
            cout << "NO" << '\n';
        }
        return;
    }
    
    if (M.size() == 2) {
        bool has_1 = false;
        for (auto [c, cc] : M) {
            if (cc == 1) has_1 = true;
        }
        
        if (!has_1) {
            cout << "NO" << '\n';
            return;
        }
        char fi = '\0';
        vector<char> C;
        for (auto [c, cc] : M) {
            C.push_back(c);
        }
        if (M[C[0]] > 1) swap(C[0], C[1]);
        cout << "YES" << '\n';
        for (auto c : C) {
            for (int j = 0; j < M[c]; j++) {
                cout << c;
            }
        }
        cout << '\n';
        return;
    }

    cout << "YES" << '\n';
    for (auto [c, cc] : M) {
        cout << c;
    }
    for (auto [c, cc] : M) {
        for (int  i = 1; i < cc; i++) {
            cout << c;
        }
    }
    cout << '\n';
}

int32_t main(){
#ifndef LOCAL
    cin.tie(0); cout.tie(0)->sync_with_stdio(false);
#endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
}#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define sz(a) (int) (a).size();
using namespace std;

void solve() {
    string s; cin >> s;
    map<char, int> M;
    for (auto c : s) {
        M[c]++;
    }

    if (M.size() == 1) {
        if (s.size() == 1) {
            cout << "YES" << '\n';
            cout << s << '\n';
        } else {
            cout << "NO" << '\n';
        }
        return;
    }
    
    if (M.size() == 2) {
        bool has_1 = false;
        for (auto [c, cc] : M) {
            if (cc == 1) has_1 = true;
        }
        
        if (!has_1) {
            cout << "NO" << '\n';
            return;
        }
        char fi = '\0';
        vector<char> C;
        for (auto [c, cc] : M) {
            C.push_back(c);
        }
        if (M[C[0]] > 1) swap(C[0], C[1]);
        cout << "YES" << '\n';
        for (auto c : C) {
            for (int j = 0; j < M[c]; j++) {
                cout << c;
            }
        }
        cout << '\n';
        return;
    }

    cout << "YES" << '\n';
    for (auto [c, cc] : M) {
        cout << c;
    }
    for (auto [c, cc] : M) {
        for (int  i = 1; i < cc; i++) {
            cout << c;
        }
    }
    cout << '\n';
}

int32_t main(){
#ifndef LOCAL
    cin.tie(0); cout.tie(0)->sync_with_stdio(false);
#endif
    int t; cin >> t;
    while (t--) {
        solve();
    }
}

Details

answer.code:69:2: error: stray ‘#’ in program
   69 | }#include <bits/stdc++.h>
      |  ^
answer.code: In function ‘void solve()’:
answer.code:25:19: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   25 |         for (auto [c, cc] : M) {
      |                   ^
answer.code:35:19: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   35 |         for (auto [c, cc] : M) {
      |                   ^
answer.code:50:15: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   50 |     for (auto [c, cc] : M) {
      |               ^
answer.code:53:15: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   53 |     for (auto [c, cc] : M) {
      |               ^
answer.code: At global scope:
answer.code:69:3: error: ‘include’ does not name a type
   69 | }#include <bits/stdc++.h>
      |   ^~~~~~~
answer.code:74:6: error: redefinition of ‘void solve()’
   74 | void solve() {
      |      ^~~~~
answer.code:6:6: note: ‘void solve()’ previously defined here
    6 | void solve() {
      |      ^~~~~
answer.code: In function ‘void solve()’:
answer.code:93:19: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   93 |         for (auto [c, cc] : M) {
      |                   ^
answer.code:103:19: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  103 |         for (auto [c, cc] : M) {
      |                   ^
answer.code:118:15: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  118 |     for (auto [c, cc] : M) {
      |               ^
answer.code:121:15: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  121 |     for (auto [c, cc] : M) {
      |               ^
answer.code: At global scope:
answer.code:129:9: error: redefinition of ‘int32_t main()’
  129 | int32_t main(){
      |         ^~~~
answer.code:61:9: note: ‘int32_t main()’ previously defined here
   61 | int32_t main(){
      |         ^~~~