답안 #111979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111979 2019-05-17T03:25:23 Z AMO5 Memory 2 (JOI16_memory2) C++
컴파일 오류
0 ms 0 KB
#include "Memory2_lib.h"

void Solve(int T, int N){
	int p[1011],visit[1011];
	int adj[55][55];
	vector < pair < int, pii> > pos[55];
	if(T==1)
    {
		int n = N*2;
		memset(p,0,sizeof(p));
		for(int i = 1; i <= n; i++)
		{
			for(int j = i+1; j <= n; j++) 
			{
				int x = Flip(i,j);
				
				adj[i-1][j-1] = x;
				adj[j-1][i-1] = x;
			}
		}	
		for(int i = 0; i < n; i++)
		{
			for(int j = i+1; j < n; j++)
			{
				for(int k = j+1; k < n; k++)
				{
					if(adj[i][j]==adj[i][k]&&adj[i][j]==adj[j][k])
					{
						int curr = adj[i][j];
						pos[curr].pb(mp(i,mp(j,k)));
						//cout << adj[i][j] <<  "  " << i << " " << j << " " << k << endl;
					}
				}
			}
		}
		/*
		cout << "***" << endl;
		for(int i = 0; i <= 50; i++)
		{
			if(pos[i].empty())continue;
			cout << i << endl;
			for(int j = 0; j < pos[i].size(); j++)
			{
				cout << pos[i][j].fi << " " << pos[i][j].se.fi << " " << pos[i][j].se.se << endl;
			}
			cout << endl;
		}
		cout << "***" << endl;
		 */
		int pos1(-1),pos2(-1);
		for(int i = 0; i <= 50; i++)
		{
			pos1 = -1;
			if(pos[i].empty())continue;
			int vis[n];
			memset(vis,0,sizeof(vis));
			
			//cout << i << "  ";
			for(int j = 0; j < 2; j++)
			{
				//cout << pos[i][j].fi << " " << pos[i][j].se.fi << " " << pos[i][j].se.se << " ";
				if(!vis[pos[i][j].fi])
				{
					vis[pos[i][j].fi] = 1;
				}
				else
				{
					if(pos1==-1)pos1 = pos[i][j].fi;
					else pos2 = pos[i][j].fi;
				}
				
				if(!vis[pos[i][j].se.fi])
				{
					vis[pos[i][j].se.fi] = 1;
				}
				else
				{
					if(pos1==-1)pos1 = pos[i][j].se.fi;
					else pos2 = pos[i][j].se.fi;
				}
				
				if(!vis[pos[i][j].se.se])
				{
					vis[pos[i][j].se.se] = 1;
				}
				else
				{
					if(pos1==-1)pos1 = pos[i][j].se.se;
					else pos2 = pos[i][j].se.se;
				}
				
			}
			//cout << endl;
			
			//cout << " ~ " << pos1 << " " << pos2 << endl; 
			Answer(pos1,pos2,i);
			visit[pos1] = 1;
			visit[pos2] = 1;
		}
		pos1 = -1, pos2 = -1;
		for(int i = 0;  i < n; i++)
		{
			if(visit[i]==0)
			{
				if(pos1==-1)pos1 = i;
				else 
				{
					pos2 = i;
					break;
				}
			}
		}
		Answer(pos1,pos2,n/2-1);
		
		//for(int i = 0; i < n; i++)cout << p[i] << " " ;
		//cout << endl;
	}
	return;
}

Compilation message

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:6:2: error: 'vector' was not declared in this scope
  vector < pair < int, pii> > pos[55];
  ^~~~~~
memory2.cpp:6:11: error: 'pair' was not declared in this scope
  vector < pair < int, pii> > pos[55];
           ^~~~
memory2.cpp:6:18: error: expected primary-expression before 'int'
  vector < pair < int, pii> > pos[55];
                  ^~~
memory2.cpp:10:3: error: 'memset' was not declared in this scope
   memset(p,0,sizeof(p));
   ^~~~~~
memory2.cpp:30:7: error: 'pos' was not declared in this scope
       pos[curr].pb(mp(i,mp(j,k)));
       ^~~
memory2.cpp:30:25: error: 'mp' was not declared in this scope
       pos[curr].pb(mp(i,mp(j,k)));
                         ^~
memory2.cpp:30:25: note: suggested alternative: 'p'
       pos[curr].pb(mp(i,mp(j,k)));
                         ^~
                         p
memory2.cpp:30:20: error: 'mp' was not declared in this scope
       pos[curr].pb(mp(i,mp(j,k)));
                    ^~
memory2.cpp:30:20: note: suggested alternative: 'p'
       pos[curr].pb(mp(i,mp(j,k)));
                    ^~
                    p
memory2.cpp:54:7: error: 'pos' was not declared in this scope
    if(pos[i].empty())continue;
       ^~~
memory2.cpp:54:7: note: suggested alternative: 'pos2'
    if(pos[i].empty())continue;
       ^~~
       pos2
memory2.cpp:62:13: error: 'pos' was not declared in this scope
     if(!vis[pos[i][j].fi])
             ^~~
memory2.cpp:62:13: note: suggested alternative: 'pos2'
     if(!vis[pos[i][j].fi])
             ^~~
             pos2
memory2.cpp:72:13: error: 'pos' was not declared in this scope
     if(!vis[pos[i][j].se.fi])
             ^~~
memory2.cpp:72:13: note: suggested alternative: 'pos2'
     if(!vis[pos[i][j].se.fi])
             ^~~
             pos2
memory2.cpp:82:13: error: 'pos' was not declared in this scope
     if(!vis[pos[i][j].se.se])
             ^~~
memory2.cpp:82:13: note: suggested alternative: 'pos2'
     if(!vis[pos[i][j].se.se])
             ^~~
             pos2