Submission #590748

#TimeUsernameProblemLanguageResultExecution timeMemory
590748l_rehoMemory (IOI10_memory)C++14
100 / 100
2 ms300 KiB


static char card[51];
static int up[2], is_up[51], candy[25], candies, moves;

#include <bits/stdc++.h>
using namespace std;

map<char, int> mp;
vector<bool> open(51, false);

char faceup(int C);

void play() {
	
	int prev_open = -1;


	for(int i = 1; i <= 50; i++){
		char c = faceup(i);
		
		int idxC = mp[c];
		
		
		
		// se ne ho già trovata una di c ed è aperta, allora
		// basta cosi
		
		if(idxC && open[idxC]){
			open[idxC] = 0;
			prev_open = -1;
			continue;
		}
		
		// se ne ho già trovata una di c e non è aperta, allora
		// se ce ne sono altre aperte, allora devo riaprire la corrente e quella precedentemente trovata
	
		if(idxC && !open[idxC]){
			if(prev_open != -1){
				open[prev_open] = 0;
				prev_open = -1;
				faceup(i);
				faceup(idxC);
			}else
				faceup(idxC);
				
			continue;
		}
		
		// se non ho trovato c e non ho altre aperte dietro, allora i rimane aperta
		if(!idxC && prev_open == -1){
			prev_open = i;
			open[i] = 1;
			mp[c] = i;
			
			continue;
		}
		
		// se non ho trovato c e ne ho altre aperte dietro, allora i si chiude insieme a quell'altra
		
		if(!idxC && prev_open != -1){
			open[prev_open] = 0;
			open[i] = 0;
			mp[c] = i;
			
			prev_open = -1;
		}
		
	}
}

Compilation message (stderr)

memory.cpp:4:50: warning: 'moves' defined but not used [-Wunused-variable]
    4 | static int up[2], is_up[51], candy[25], candies, moves;
      |                                                  ^~~~~
memory.cpp:4:41: warning: 'candies' defined but not used [-Wunused-variable]
    4 | static int up[2], is_up[51], candy[25], candies, moves;
      |                                         ^~~~~~~
memory.cpp:4:30: warning: 'candy' defined but not used [-Wunused-variable]
    4 | static int up[2], is_up[51], candy[25], candies, moves;
      |                              ^~~~~
memory.cpp:4:19: warning: 'is_up' defined but not used [-Wunused-variable]
    4 | static int up[2], is_up[51], candy[25], candies, moves;
      |                   ^~~~~
memory.cpp:4:12: warning: 'up' defined but not used [-Wunused-variable]
    4 | static int up[2], is_up[51], candy[25], candies, moves;
      |            ^~
memory.cpp:3:13: warning: 'card' defined but not used [-Wunused-variable]
    3 | static char card[51];
      |             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...