Submission #111984

# Submission time Handle Problem Language Result Execution time Memory
111984 2019-05-17T03:38:47 Z TexTang None (JOI16_memory2) C++14
0 / 100
3 ms 512 KB
#include "Memory2_lib.h"
#include <iostream>
#include <vector>
using namespace std;

void Solve(int T, int N){
	pair <int,int> a[N];
	int count[2*N][2*N];
	bool visited[2*N];
	for(int i = 0;i < 2*N;i++) visited[i] = false;
	int l = 0,r = 2*N - 1;
	int lr[2*N][2*N];

	for(int p = 0;p < N - 1;p++){
		l = 0,r = 2*N - 1;
		while(r > l){
			while(visited[r] && r != l) r--;
			while(visited[l] && r != l) l++;
			lr[l][r] = Flip(l,r);
			l++,r--;
		}
		l = 0,r = 2*N - 1;
		vector <pair <int,int> > tmp;
		while(r > l ){
			while(visited[r] && r != l) r--;
			while(visited[l] && r != l) l++;
			if(!visited[l] && !visited[r] && lr[l][r] == p){
				tmp.push_back(make_pair(l,r));
			}
			l++,r--;
		}
		int x,y;
		if(tmp.size() == 1){
			x = tmp[0].first;
			y = tmp[0].second;
		} else {
			int l1,r1,l2,r2;
			l1 = tmp[0].first;
			r1 = tmp[0].second;
			l2 = tmp[1].first;
			r2 = tmp[1].second;
			if(Flip(l1,l2) != p){
				x = r1, y = r2;
			} else if (Flip(l1,r2) != p){
				x = l2, y = r1;
			} else if (Flip(r1,l2) != p){
				x = l1, y = r2;
			} else { //Flip(r1,r2)
				x = l1, y = l2;
			}
		}
		visited[x] = visited[y] = true;
		a[p].first = x;
		a[p].second = y;
	}
	vector <int> u;
	for(int i = 0;i < 2*N;i++){
		if(!visited[i]) u.push_back(i);
	}
	a[N - 1].first = u[0];
	a[N - 1].second = u[1];

	for(int i = 0;i < N;i++){
		//cout << a[i].first << a[i].second << i << endl;
		Answer(a[i].first, a[i].second, i);
	}
}

Compilation message

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:8:6: warning: unused variable 'count' [-Wunused-variable]
  int count[2*N][2*N];
      ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Wrong Answer[1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -