Submission #973210

# Submission time Handle Problem Language Result Execution time Memory
973210 2024-05-01T16:04:59 Z njoop Cryptography (NOI20_crypto) C++14
0 / 100
3 ms 4700 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int n, in, ord[300010];
ll fac[3000010], mod = 1e9+7, ans;
vector<pair<int, int>> v;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    fac[0] = 1;
    for(int i=1; i<300010; i++) {
        fac[i] = i * fac[i-1];
        fac[i] %= mod;
    }
    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> in;
        v.push_back({in, i});
    }
    sort(v.begin(), v.end());
    for(int i=0; i<v.size(); i++) {
        ord[v[i].second] = i;
    }
    for(int i=1; i<=n; i++) {
        ans += ord[i]*fac[n-i];
        ans %= mod;
    }
    cout << ans;
    return 0;
}

Compilation message

Crypto.cpp: In function 'int main()':
Crypto.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i=0; i<v.size(); i++) {
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4696 KB Output is correct
2 Incorrect 3 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4696 KB Output is correct
2 Incorrect 3 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4696 KB Output is correct
2 Incorrect 3 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4696 KB Output is correct
2 Incorrect 3 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -