답안 #733867

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733867 2023-05-01T11:22:21 Z vjudge1 Cryptography (NOI20_crypto) C++17
5 / 100
1000 ms 4956 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
const ll d = 1e9 + 7;
int main() {
    ll n;
    cin >> n;
    vector <ll> v(n), v1;
    for(ll i = 0; i < n; i++) {
        cin >> v[i];
    }
    v1 = v;
    ll ans = 1;
    sort(v1.begin(), v1.end());
    if(v == v1) {
        cout << 1;
        return 0;
    }
    reverse(v1.begin(), v1.end());
    if(v1 == v) {
        cout << n;
        return 0;
    }
    else reverse(v1.begin(), v1.end());
    for(ll i = 0; i < v.size(); i++) {
        for(ll j = 0; j < v1.size(); j++) {
            if(v[i] == v1[j]) {
                n--;
                ans += n * j;
                ans %= d;
                auto it = v1.begin() + j;
                auto it1 = v.begin() + i;
                v1.erase(it);
                v.erase(it1);
                i--;
                j--;
                break;
            }
        }
    }
    cout << ans;
}

Compilation message

Crypto.cpp: In function 'int main()':
Crypto.cpp:25:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(ll i = 0; i < v.size(); i++) {
      |                   ~~^~~~~~~~~~
Crypto.cpp:26:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(ll j = 0; j < v1.size(); j++) {
      |                       ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 134 ms 4956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 1047 ms 4940 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 5 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 1047 ms 4940 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -