Submission #958028

#TimeUsernameProblemLanguageResultExecution timeMemory
958028Zena_HossamCryptography (NOI20_crypto)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define ll int using namespace std; namespace __gnu_pbds { typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; } using namespace __gnu_pbds; #define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //#define ll double #define ll1 long long #define F first #define S second #define sz size() #define all(s) s.begin(),s.end() #define all1(s) s.rbegin(),s.rend() ll mod=1e9+7; int main() { fi //freopen("stdin.in","r",stdin);freopen("stdout.out","w",stdout); //cin>>T;ll oo=0; ll n; cin>>n; map<ll,ll>d ll m[n+5]={},dd[n+5]={}; ll o=1; for(ll i=1;i<=n;i++){ o=(i*o)%mod; m[i]=o; } ll arr[n],a[n]; for(ll i=0;i<n;i++){ cin>>a[i]; arr[i]=a[i]; } sort(a,a+n); for(ll i=0;i<n;i++){ d[a[i]]=i+1; } for(ll i=1;i<=n;i++){ dd[d[arr[i-1]]]=i; } ll k[n+5]={};ll c=0; ordered_set q; for(ll i=1;i<=n;i++){ //cout<<i-q.order_of_key(dd[i])-1<<" "; c+=((m[(n-dd[i])]%mod)*((i-1-q.order_of_key(dd[i]))%mod))%mod;q.insert(dd[i]); }cout<<(c+1)%mod; }

Compilation message (stderr)

Crypto.cpp: In function 'int main()':
Crypto.cpp:4:12: error: expected initializer before 'int'
    4 | #define ll int
      |            ^~~
Crypto.cpp:33:5: note: in expansion of macro 'll'
   33 |     ll m[n+5]={},dd[n+5]={};
      |     ^~
Crypto.cpp:33:17: error: expected primary-expression before ',' token
   33 |     ll m[n+5]={},dd[n+5]={};
      |                 ^
Crypto.cpp:33:18: error: 'dd' was not declared in this scope
   33 |     ll m[n+5]={},dd[n+5]={};
      |                  ^~
Crypto.cpp:37:9: error: 'm' was not declared in this scope
   37 |         m[i]=o;
      |         ^
Crypto.cpp:47:9: error: 'd' was not declared in this scope
   47 |         d[a[i]]=i+1;
      |         ^
Crypto.cpp:50:12: error: 'd' was not declared in this scope
   50 |         dd[d[arr[i-1]]]=i;
      |            ^
Crypto.cpp:56:14: error: 'm' was not declared in this scope
   56 |         c+=((m[(n-dd[i])]%mod)*((i-1-q.order_of_key(dd[i]))%mod))%mod;q.insert(dd[i]);
      |              ^
Crypto.cpp:52:8: warning: unused variable 'k' [-Wunused-variable]
   52 |     ll k[n+5]={};ll c=0;
      |        ^