Submission #778982

# Submission time Handle Problem Language Result Execution time Memory
778982 2023-07-11T06:06:40 Z vjudge1 Zamjena (COCI18_zamjena) C++17
28 / 70
1000 ms 3704 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define pb push_back
#define N 105
map<string,string> mp;
signed main(){
	lalala;
	int n;cin>>n;
	vector<string> bir, iki;
	for(int i=0;i<n;i++){
		string str;cin>>str;
		bir.pb(str);
		mp[str]="&&";
	}
	int yes=1;
	for(int i=0;i<n;i++){
		string str;cin>>str;
		mp[str]="&&";
		iki.pb(str);
		int yes1=1,yes2=1;
		string a,b;
		for(int j=0;j<str.length();j++){
			if(iki[i][j]-'0'>9){
				yes1=0;break;
			}
			a.pb(iki[i][j]);
		}
		for(int j=0;j<bir[i].length();j++){
			if(bir[i][j]-'0'>9){
				yes2=0;break;
			}
			b.pb(bir[i][j]);
		}
		//cout<<a<<" "<<b<<endl;
		if(yes1){
			if(yes2){
				if(iki[i]==bir[i])continue;
				yes=0;continue;
			}
			if(mp[bir[i]]=="&&"){
				mp[bir[i]]=iki[i];
				continue;
			}
			if(mp[bir[i]]!=iki[i])yes=0;
			continue;

		}
		if(yes2){
			if(mp[iki[i]]==bir[i])continue;
			if(mp[iki[i]]=="&&"){
				mp[iki[i]]=bir[i];continue;
			}
			yes=0;continue;
		}
		if(mp[iki[i]]=="&&")mp[iki[i]]=mp[bir[i]];
		if(mp[bir[i]]=="&&")mp[bir[i]]=mp[iki[i]];
		if(mp[iki[i]]!=mp[bir[i]])yes=0;
	}
	int uwu=100;
	while(uwu--){
		for(int i=0;i<n;i++){
			if(mp[iki[i]]=="&&")mp[iki[i]]=mp[bir[i]];
			if(mp[bir[i]]=="&&")mp[bir[i]]=mp[iki[i]];
			if(mp[bir[i]]==mp[iki[i]])continue;
			yes=0;
		}
	}
	if(yes)cout<<"DA"<<endl;
	else cout<<"NE"<<endl;


}

Compilation message

zamjena.cpp: In function 'int main()':
zamjena.cpp:25:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int j=0;j<str.length();j++){
      |               ~^~~~~~~~~~~~~
zamjena.cpp:31:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int j=0;j<bir[i].length();j++){
      |               ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 468 KB Output is correct
2 Correct 50 ms 340 KB Output is correct
3 Correct 174 ms 724 KB Output is correct
4 Correct 149 ms 852 KB Output is correct
5 Correct 186 ms 852 KB Output is correct
6 Incorrect 180 ms 856 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 564 ms 1920 KB Output is correct
2 Execution timed out 1084 ms 3704 KB Time limit exceeded
3 Halted 0 ms 0 KB -