제출 #47424

#제출 시각아이디문제언어결과실행 시간메모리
47424tincamateiChessboard (IZhO18_chessboard)C++14
70 / 100
153 ms61184 KiB
#include <cstdio>

const int MAX_N = 100000;
int x1[MAX_N], y1[MAX_N], x2[MAX_N], y2[MAX_N];

int main() {
  int n, k;
  long long mismatch, best = 10000000000LL;
  scanf("%d%d", &n, &k);
  for(int i = 0; i < k; ++i) {
    scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
    x1[i]--;y1[i]--;
    x2[i]--;y2[i]--;
  }
  for(int lat = 1; lat < n; ++lat)
    if(n % lat == 0) { 
      mismatch = 0;
      for(int i = 0; i < k; ++i)
        if((x1[i]/lat + y1[i]/lat) % 2 == 0)
          ++mismatch;
        else
          --mismatch;
      if(mismatch + (long long)n * n / lat / lat / 2 * lat * lat < best)
        best = mismatch + (long long)n * n / lat / lat / 2 * lat * lat;
      mismatch = -mismatch;
      if(mismatch + ((long long)n * n / lat / lat + 1) / 2 * lat * lat < best)
        best = mismatch + ((long long)n * n / lat / lat + 1) / 2 * lat * lat;
    }
  printf("%lld", best);
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

chessboard.cpp: In function 'int main()':
chessboard.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~
chessboard.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...