Submission #98217

#TimeUsernameProblemLanguageResultExecution timeMemory
98217luciocfIdeal city (IOI12_city)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define x first #define y second using namespace std; const int maxn = 1e5+10; const long long mod = 1e9; typedef long long ll; typedef pair<int, int> pt; int n; ll soma[maxn]; pii pt[maxn]; bool comp(pt a, pt b) {return a.y < b.y;} int DistanceSum(int N, int *X, int *Y) { n = N; for (int i = 0; i < n; i++) pt[i+1] = {X[i], Y[i]}; sort(pt+1, pt+n+1); for (int i = 1; i <= n; i++) soma[i] = (soma[i-1]+(ll)pt[i].x)%mod; ll ans = 0LL; for (int i = 1; i <= n; i++) { ll v = (soma[n]-soma[i]+mod)%mod; ans = (ans+v)%mod; ans = (ans-((n-i)*(ll)pt[i].x)%mod+mod)%mod; v = soma[i-1]; ans = (ans-v+mod)%mod; ans = (ans+((i-1)*(ll)pt[i].x)%mod)%mod; } sort(pt+1, pt+n+1, comp); for (int i = 1; i <= n; i++) soma[i] = (soma[i-1]+(ll)pt[i].y)%mod; for (int i = 1; i <= n; i++) { ll v = (soma[n]-soma[i]+mod)%mod; ans = (ans+v)%mod; ans = (ans-(((ll)n-(ll)i)*(ll)pt[i].y)%mod+mod)%mod; v = soma[i-1]; ans = (ans-v+mod)%mod; ans = (ans+(((ll)i-1LL)*(ll)pt[i].y)%mod)%mod; } return ans; }

Compilation message (stderr)

city.cpp:18:1: error: 'pii' does not name a type
 pii pt[maxn];
 ^~~
city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:26:7: error: expected ']' before '+' token
   pt[i+1] = {X[i], Y[i]};
       ^
city.cpp:26:5: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
   pt[i+1] = {X[i], Y[i]};
     ^
city.cpp:26:5: error: decomposition declaration cannot be declared with type 'pt {aka std::pair<int, int>}'
city.cpp:26:5: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
city.cpp:26:9: error: redeclaration of 'auto i'
   pt[i+1] = {X[i], Y[i]};
         ^
city.cpp:25:11: note: 'int i' previously declared here
  for (int i = 0; i < n; i++)
           ^
city.cpp:26:16: error: use of 'i' before deduction of 'auto'
   pt[i+1] = {X[i], Y[i]};
                ^
city.cpp:26:22: error: use of 'i' before deduction of 'auto'
   pt[i+1] = {X[i], Y[i]};
                      ^
city.cpp:26:24: error: unable to deduce 'std::initializer_list<auto>' from '{<expression error>, <expression error>}'
   pt[i+1] = {X[i], Y[i]};
                        ^
city.cpp:28:9: error: expected primary-expression before '+' token
  sort(pt+1, pt+n+1);
         ^
city.cpp:28:15: error: expected primary-expression before '+' token
  sort(pt+1, pt+n+1);
               ^
city.cpp:31:30: error: expected primary-expression before '[' token
   soma[i] = (soma[i-1]+(ll)pt[i].x)%mod;
                              ^
city.cpp:40:27: error: expected primary-expression before '[' token
   ans = (ans-((n-i)*(ll)pt[i].x)%mod+mod)%mod;
                           ^
city.cpp:45:27: error: expected primary-expression before '[' token
   ans = (ans+((i-1)*(ll)pt[i].x)%mod)%mod;
                           ^
city.cpp:48:9: error: expected primary-expression before '+' token
  sort(pt+1, pt+n+1, comp);
         ^
city.cpp:48:15: error: expected primary-expression before '+' token
  sort(pt+1, pt+n+1, comp);
               ^
city.cpp:51:30: error: expected primary-expression before '[' token
   soma[i] = (soma[i-1]+(ll)pt[i].y)%mod;
                              ^
city.cpp:58:35: error: expected primary-expression before '[' token
   ans = (ans-(((ll)n-(ll)i)*(ll)pt[i].y)%mod+mod)%mod;
                                   ^
city.cpp:63:33: error: expected primary-expression before '[' token
   ans = (ans+(((ll)i-1LL)*(ll)pt[i].y)%mod)%mod;
                                 ^