Submission #121848

# Submission time Handle Problem Language Result Execution time Memory
121848 2019-06-27T06:50:45 Z TuGSGeReL Ideal city (IOI12_city) C++14
Compilation error
0 ms 0 KB
int DistanceSum(int n, int *x, int *y) {
	int mnx = INT_MAX, mny = INT_MAX;
	
	for (int i = 0; i < n; i++)
	{
		mnx = min(mnx, x[i]);
		mny = min(mny, y[i]);
	}
	
	for (int i = 0; i < n; i++)
	{
		x[i] -= mnx;
		y[i] -= mny;
	}
	
	if ( n <= 0 )
	{
		
	} else {
		for (int i = 0; i < n; i++)
		{
			cx[x[i]]++;
			cy[y[i]]++;
		}
		
		int sx = 0, ans = 0, sy = 0, ssx = 0, ssy = 0;
		
		for (int i = n; i >= 0; i--)
		{
			ans = (ans + (ssx * cx[i] + cy[i] * ssy) % mod) % mod;
			sy = (sy + cy[i]) % mod;
			sx = (sx + cx[i]) % mod;
			ssx = (ssx + sx) % mod;
			ssy = (ssy + sy) % mod;
		}
		
		return ans;
	}
}

Compilation message

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:2:12: error: 'INT_MAX' was not declared in this scope
  int mnx = INT_MAX, mny = INT_MAX;
            ^~~~~~~
city.cpp:2:12: note: suggested alternative: '__INT_MAX__'
  int mnx = INT_MAX, mny = INT_MAX;
            ^~~~~~~
            __INT_MAX__
city.cpp:6:9: error: 'min' was not declared in this scope
   mnx = min(mnx, x[i]);
         ^~~
city.cpp:7:3: error: 'mny' was not declared in this scope
   mny = min(mny, y[i]);
   ^~~
city.cpp:7:3: note: suggested alternative: 'mnx'
   mny = min(mny, y[i]);
   ^~~
   mnx
city.cpp:13:11: error: 'mny' was not declared in this scope
   y[i] -= mny;
           ^~~
city.cpp:13:11: note: suggested alternative: 'mnx'
   y[i] -= mny;
           ^~~
           mnx
city.cpp:22:4: error: 'cx' was not declared in this scope
    cx[x[i]]++;
    ^~
city.cpp:22:4: note: suggested alternative: 'x'
    cx[x[i]]++;
    ^~
    x
city.cpp:23:4: error: 'cy' was not declared in this scope
    cy[y[i]]++;
    ^~
city.cpp:23:4: note: suggested alternative: 'y'
    cy[y[i]]++;
    ^~
    y
city.cpp:30:24: error: 'cx' was not declared in this scope
    ans = (ans + (ssx * cx[i] + cy[i] * ssy) % mod) % mod;
                        ^~
city.cpp:30:24: note: suggested alternative: 'sx'
    ans = (ans + (ssx * cx[i] + cy[i] * ssy) % mod) % mod;
                        ^~
                        sx
city.cpp:30:32: error: 'cy' was not declared in this scope
    ans = (ans + (ssx * cx[i] + cy[i] * ssy) % mod) % mod;
                                ^~
city.cpp:30:32: note: suggested alternative: 'sy'
    ans = (ans + (ssx * cx[i] + cy[i] * ssy) % mod) % mod;
                                ^~
                                sy
city.cpp:30:47: error: 'mod' was not declared in this scope
    ans = (ans + (ssx * cx[i] + cy[i] * ssy) % mod) % mod;
                                               ^~~
city.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^