Submission #9546

# Submission time Handle Problem Language Result Execution time Memory
9546 2014-09-28T07:09:05 Z dominyellow Wiring (kriii2_W) C++
0 / 4
0 ms 1208 KB
#include <stdio.h>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

int main(void){
	int N;
	scanf("%d", &N);

	map<int, int> q_map;

	q_map[0] = 0;

	map<pair<int, int>, bool> line_map;

	int line_count = 0;
	int i;
	for(int i=1; i<=N*N; i++){
		int q_i;
		q_i = (q_map[i-1]+i) % N;
		if(q_i == 0){
			break;
		}
		if(q_map.count(q_i) == 0){
			q_map[i] = q_i;
		}

		if(q_map[i-1] != q_i){
			if(line_map.count(make_pair(q_map[i-1], q_i)) == 0 && line_map.count(make_pair(q_i, q_map[i-1])) == 0){
				line_map[make_pair(q_map[i-1], q_i)] = true;
				line_count += 1;
			}
		}
	}
	printf("%d\n", line_count);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1208 KB Output is correct
2 Correct 0 ms 1208 KB Output is correct
3 Incorrect 0 ms 1208 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -