Submission #154814

# Submission time Handle Problem Language Result Execution time Memory
154814 2019-09-24T20:21:23 Z TadijaSebez None (JOI16_memory2) C++11
100 / 100
2 ms 504 KB
#include "Memory2_lib.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
mt19937 rng(time(0));
void Solve(vector<int> pos)
{
	if(pos.size()==2)
	{
		Answer(pos[0],pos[1],Flip(pos[0],pos[1]));
		return;
	}
	int x=rng()%pos.size();
	vector<pair<int,int>> ans;
	for(int i=0;i<pos.size();i++) if(i!=x)
	{
		ans.pb({Flip(pos[i],pos[x]),pos[i]});
	}
	sort(ans.begin(),ans.end());
	vector<int> work;
	for(int i=0,j;i<ans.size();i=j)
	{
		vector<int> now;
		for(j=i;j<ans.size() && ans[i].first==ans[j].first;j++) now.pb(ans[j].second);
		if(now.size()==2)
		{
			Answer(now[0],now[1],ans[i].first);
		}
		else
		{
			work=now;
			work.pb(pos[x]);
		}
	}
	Solve(work);
}
void Solve(int T, int N)
{
	vector<int> work;
	for(int i=0;i<N*2;i++) work.pb(i);
	Solve(work);
}

Compilation message

memory2.cpp: In function 'void Solve(std::vector<int>)':
memory2.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<pos.size();i++) if(i!=x)
              ~^~~~~~~~~~~
memory2.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0,j;i<ans.size();i=j)
                ~^~~~~~~~~~~
memory2.cpp:24:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=i;j<ans.size() && ans[i].first==ans[j].first;j++) now.pb(ans[j].second);
           ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 396 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct