Submission #494779

# Submission time Handle Problem Language Result Execution time Memory
494779 2021-12-16T08:57:35 Z levsog2004 Chessboard (IZhO18_chessboard) C++14
0 / 100
213 ms 3468 KB
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef  long long ll;
const ll N = 2000004;
ll n, m, l, k, t, x,ans=N*N, y,dp[N];
pair<ll, ll> a[N];
int check(int n, int m, int x, int y)
{
	x /= m;
	y /= m;
	if (x + y % 2 == 0)
	{
		return 1;
	}
	else
		return 0;

}
int main() 
{
	for (int i = 2; i <= 100005; ++i)
			dp[i] = i * i / 2;
		for (int i = 3; i <= 100005; ++i)
		{
			for (int j = 1; j*j <= i; ++j)
			{
				if(i%j==0)
				dp[i] = min(ll(dp[i/j] * (j*j)), dp[i]);
			}
		}
			cin >> n >> m;
			for (int i = 0; i < m; ++i)
			{
				cin >> a[i].first >> a[i].second;
				cin >> x >> x;
			}
			x = 0;

			ans = dp[n];
			if (m != 0)
				for (int i = 1; i*i <= n; ++i)
				{
					if (n%i == 0)
					{
						for (int j = 0; j < m; ++j)
						{
							x += check(n, i, a[j].first - 1, a[j].second - 1);
						}
						ans = min(x, dp[n / i] - x);
					}
					x = 0;
				}
			cout << ans << endl;
			return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 131 ms 1204 KB Output is correct
2 Correct 135 ms 1068 KB Output is correct
3 Incorrect 141 ms 1080 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 3468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 1084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 1084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 3468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 131 ms 1204 KB Output is correct
2 Correct 135 ms 1068 KB Output is correct
3 Incorrect 141 ms 1080 KB Output isn't correct
4 Halted 0 ms 0 KB -