Submission #189335

# Submission time Handle Problem Language Result Execution time Memory
189335 2020-01-14T01:46:27 Z dndhk None (JOI16_memory2) C++14
100 / 100
3 ms 376 KB
#include "Memory2_lib.h"
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_N = 100;
int ans[MAX_N+1];
vector<int> vt[MAX_N+1];

void Solve(int T, int N){
	int i1 = 0, i2 = 1;
	int r0 = Flip(i1, i2), r1, r2;
	int n = 2;
	int t = -1;
	for(int n=2; n<N*2; n++){
		r1 = Flip(i1, n);
		r2 = Flip(i2, n);
		//cout<<i1<<" "<<i2<<" "<<n<<" "<<r0<<" "<<r1<<" "<<r2<<" "<<endl;
		if(r1==r2){
			if(r0==r1){
				if(t==-1){
					t = n;
				}else{
					ans[i1] = ans[i2] = r0;
					i1 = t; i2 = n;
					r0 = Flip(i1, i2);
					t = -1;
				}
			}else{
				ans[n] = r1;
			}
		}else{
			if(r0==r1){
				if(t!=-1){
					ans[t] = r0;	
				}
				ans[i1] = r0;
				i1 = n;
				r0 = r2;
				t = -1;
			}else{
				if(t!=-1){
					ans[t] = r0;
				}
				ans[i2] = r0;
				i2 = n;
				r0 = r1;
				t = -1;
			}
		}
	}
	ans[i1] = ans[i2] = r0;
	for(int i=0; i<N*2; i++){
		vt[ans[i]].pb(i);
	}
	for(int i=0; i<N; i++){
		Answer(vt[i][0], vt[i][1], i);
	}
	return;
}

Compilation message

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:18:6: warning: unused variable 'n' [-Wunused-variable]
  int n = 2;
      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 360 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 2 ms 256 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 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 248 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct