답안 #165526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165526 2019-11-27T12:00:02 Z Abdulaziz_Kazim Zamjena (COCI18_zamjena) C++17
56 / 70
958 ms 65540 KB
#include<bits/stdc++.h>
using namespace std;
string dizi[50007];
string dizi2[50007];
map<string,vector<pair<int,bool>>>degisken;
map<string,string>act;
int main()
{
	// freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
	int n;
	cin >> n;
	// string gir;
	for(int i=0;i<n;i++)
	{
		cin >> dizi[i];
		if(!isdigit(dizi[i][0]))
		{
			degisken[dizi[i]].push_back({i,0});
		}
	}
	for(int i=0;i<n;i++)
	{
		cin >> dizi2[i];
		if(!isdigit(dizi2[i][0]))
		{
			degisken[dizi2[i]].push_back({i,1});
			// if(isdigit(dizi[i][0]))
			// {

			// }
		}
		else
		{
			if(isdigit(dizi[i][0]))
			{
				if(dizi[i]!=dizi2[i])
				{
					cout << "NE\n";
					exit(0);
				}
			}
		}
	}
	for(int i=0;i<=n;i++)
	{
		// for(int i=0;i<n;i++)
		// {
		// 	cout << dizi[i] << " ";
		// }
		// cout <<"\n";
		// for(int i=0;i<n;i++)
		// {
		// 	cout << dizi2[i] << " ";
		// }
		// cout <<"\n\n";
		if(!isdigit(dizi[i][0]) && !isdigit(dizi2[i][0]) && dizi[i]!=dizi2[i])
		{
			// cout << i << " ";
			string za=dizi2[i];
			for(auto x:degisken[za])
			{
				degisken[dizi[i]].push_back(x);

				// cout << x.first << " ";
				if(x.second==0)
				{
					dizi[x.first]=dizi[i];
				}
				else
					dizi2[x.first]=dizi[i];
			}
			degisken[za].clear();
		}
	}
	for(int i=0;i<n;i++)
	{
		if(isdigit(dizi[i][0]) && !isdigit(dizi2[i][0]))
		{
			string muz=dizi[i],muz2=dizi2[i];
			for(auto x:degisken[muz2])
			{
				if(x.second==0)
				{
					dizi[x.first]=muz;
				}
				else
					dizi2[x.first]=muz;
			}
			degisken[muz2].clear();
		}
		else if(!isdigit(dizi[i][0])&& isdigit(dizi2[i][0]))
		{
			string muz=dizi2[i],muz2=dizi[i];
			for(auto x:degisken[muz2])
			{
				if(x.second==0)
				{
					dizi[x.first]=muz;
				}
				else
					dizi2[x.first]=muz;
			}
			degisken[muz2].clear();
		}
	}
	/*for(int i=0;i<n;i++)
	{
		cout << dizi[i] << " ";
	}
	cout <<"\n";
	for(int i=0;i<n;i++)
	{
		cout<< dizi2[i] << " ";
	}*/
	for(int i=0;i<n;i++)
	{
		if(dizi[i]!=dizi2[i])
		{
			cout <<"NE\n";
			exit(0);
		}
	}
	cout << "DA\n";
	exit(0);
	// for(int i=0;i<n;i++)
	// {
	// 	if(!isdigit(dizi[i][0]) && !isdigit(dizi2[i][0]))
	// 	{
	// 		for(auto x:degisken2[dizi2[i]])
	// 		{
	// 			// degisken[dizi[i]]
	// 		}
	// 	}
	// }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 5 ms 3448 KB Output is correct
4 Correct 5 ms 3448 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 5 ms 3448 KB Output is correct
4 Correct 5 ms 3448 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 5 ms 3444 KB Output is correct
4 Correct 5 ms 3448 KB Output is correct
5 Correct 5 ms 3452 KB Output is correct
6 Correct 5 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 5548 KB Output is correct
2 Correct 8 ms 3704 KB Output is correct
3 Correct 14 ms 4092 KB Output is correct
4 Correct 53 ms 7292 KB Output is correct
5 Correct 13 ms 3960 KB Output is correct
6 Correct 12 ms 3832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 958 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -