Submission #855841

# Submission time Handle Problem Language Result Execution time Memory
855841 2023-10-02T03:07:27 Z Trisanu_Das Chessboard (IZhO18_chessboard) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <climits>
#define int long long 

int f(int s, int a) {
	a %= s * 2;
	return min(a, s * 2 - a);
}
 
int main() {
	int x1[N], y1[N], x2[N], y2[N];
	int n, k, tot, t, temp, ans;
	cin >> n >> k;
	for (i = 0; i < k; i++){
      cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      --x1[i]; --y1[i];
    }
	ans = LLONG_MAX;
	for (i = 1; i < n; i++)
		if (n % i == 0) {
			k = (s / t) * (s / t) / 2 * t * t;
			for (i = 0; i < n; i++) temp += (f(i, x2[i]) - f(i, x1[i])) * (f(i, y2[i]) - f(i, y1[i]));
			ans = min(ans, min(temp, n * n - temp));
		}
	cout << ans << '\n';
}

Compilation message

chessboard.cpp: In function 'long long int f(long long int, long long int)':
chessboard.cpp:8:9: error: 'min' was not declared in this scope; did you mean 'std::min'?
    8 |  return min(a, s * 2 - a);
      |         ^~~
      |         std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from chessboard.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
At global scope:
cc1plus: error: '::main' must return 'int'
chessboard.cpp: In function 'int main()':
chessboard.cpp:12:9: error: 'N' was not declared in this scope
   12 |  int x1[N], y1[N], x2[N], y2[N];
      |         ^
chessboard.cpp:14:2: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   14 |  cin >> n >> k;
      |  ^~~
      |  std::cin
In file included from chessboard.cpp:1:
/usr/include/c++/10/iostream:60:18: note: 'std::cin' declared here
   60 |   extern istream cin;  /// Linked to standard input
      |                  ^~~
chessboard.cpp:15:7: error: 'i' was not declared in this scope
   15 |  for (i = 0; i < k; i++){
      |       ^
chessboard.cpp:16:14: error: 'x1' was not declared in this scope
   16 |       cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |              ^~
chessboard.cpp:16:23: error: 'y1' was not declared in this scope
   16 |       cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |                       ^~
chessboard.cpp:16:32: error: 'x2' was not declared in this scope
   16 |       cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |                                ^~
chessboard.cpp:16:41: error: 'y2' was not declared in this scope
   16 |       cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |                                         ^~
chessboard.cpp:20:7: error: 'i' was not declared in this scope
   20 |  for (i = 1; i < n; i++)
      |       ^
chessboard.cpp:22:9: error: 's' was not declared in this scope
   22 |    k = (s / t) * (s / t) / 2 * t * t;
      |         ^
chessboard.cpp:23:42: error: 'x2' was not declared in this scope
   23 |    for (i = 0; i < n; i++) temp += (f(i, x2[i]) - f(i, x1[i])) * (f(i, y2[i]) - f(i, y1[i]));
      |                                          ^~
chessboard.cpp:23:56: error: 'x1' was not declared in this scope
   23 |    for (i = 0; i < n; i++) temp += (f(i, x2[i]) - f(i, x1[i])) * (f(i, y2[i]) - f(i, y1[i]));
      |                                                        ^~
chessboard.cpp:23:72: error: 'y2' was not declared in this scope
   23 |    for (i = 0; i < n; i++) temp += (f(i, x2[i]) - f(i, x1[i])) * (f(i, y2[i]) - f(i, y1[i]));
      |                                                                        ^~
chessboard.cpp:23:86: error: 'y1' was not declared in this scope
   23 |    for (i = 0; i < n; i++) temp += (f(i, x2[i]) - f(i, x1[i])) * (f(i, y2[i]) - f(i, y1[i]));
      |                                                                                      ^~
chessboard.cpp:24:19: error: 'min' was not declared in this scope; did you mean 'std::min'?
   24 |    ans = min(ans, min(temp, n * n - temp));
      |                   ^~~
      |                   std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from chessboard.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
chessboard.cpp:24:10: error: 'min' was not declared in this scope; did you mean 'std::min'?
   24 |    ans = min(ans, min(temp, n * n - temp));
      |          ^~~
      |          std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from chessboard.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
chessboard.cpp:26:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |  cout << ans << '\n';
      |  ^~~~
      |  std::cout
In file included from chessboard.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
chessboard.cpp:13:12: warning: unused variable 'tot' [-Wunused-variable]
   13 |  int n, k, tot, t, temp, ans;
      |            ^~~