Submission #211655

# Submission time Handle Problem Language Result Execution time Memory
211655 2020-03-20T23:01:46 Z JustInCase Osmosmjerka (COCI17_osmosmjerka) C++17
20 / 160
4000 ms 141724 KB
#include <bits/stdc++.h>
 
const int32_t DELTA_I[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
const int32_t DELTA_J[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
 
const int32_t MAX_N = 500;
const int32_t MAX_M = 500;
 
char block[MAX_N + 5][MAX_M + 5];
std::unordered_map< std::string, int32_t > cnt;
 
int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
 
	int32_t n, m, k;
	std::cin >> n >> m >> k;
 
	for(int32_t i = 0; i < n; i++) {
		for(int32_t j = 0; j < m; j++) {
			std::cin >> block[i][j];			
		}
	}
	
	int32_t totalCnt = 0;
	for(int32_t i = 0; i < n; i++) {
		for(int32_t j = 0; j < m; j++) {
			int32_t currI = i, currJ = j;
			for(int32_t p = 0; p < 8; p++) {
				std::string s = "";
				do {
					s += block[currI][currJ];
					
					currI += DELTA_I[p];
					currJ += DELTA_J[p];
 
					if(currI < 0) {
						currI += n;
					}
					if(currJ < 0) {
						currJ += m;
					}
 
					currI %= n;
					currJ %= m;
 
				} while(s.size() < n * (k % n));
				
				totalCnt++;
				cnt[s]++;
			}
		}
	}
 
	int32_t a = 0, b = totalCnt * totalCnt;
	for(auto &x : cnt) {
		a += x.second * x.second;
	}
 
	int32_t gcd = std::__gcd(a, b);
	a /= gcd;
	b /= gcd;
 
	std::cout << a << "/" << b << '\n';
}

Compilation message

osmosmjerka.cpp: In function 'int main()':
osmosmjerka.cpp:47:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     } while(s.size() < n * (k % n));
             ~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Correct 7 ms 512 KB Output is correct
5 Incorrect 6 ms 384 KB Output isn't correct
6 Execution timed out 4070 ms 141724 KB Time limit exceeded
7 Execution timed out 4074 ms 109564 KB Time limit exceeded
8 Incorrect 125 ms 896 KB Output isn't correct