# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472203 |
2021-09-13T09:17:14 Z |
Mr_Ph |
Zamjena (COCI18_zamjena) |
C++14 |
|
1000 ms |
12388 KB |
///made by : Mr_Ph :D
#include<bits/stdc++.h>
#include<unordered_map>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
const double PI=acos(-1.0);
const ll mod=(ll)1e9+7;
//int a1[4] = {0, 0, 1, -1};
//int b1[4] = {1, -1, 0, 0};
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define lower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define upper(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define ent_arr for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
///the end of the defines ;)
map<string,vector<string>>adj;
map<string,bool>vs;
//map<string,string>mp;
bool isint(string s)
{
for(int i=0;i<s.sz;i++)
{
if(s[i]<'0'||s[i]>'9')
return false;
}
return true;
}
vector<string>aa;
void dfs(string node)
{
if(isint(node))
aa.push_back(node);
vs[node]=true;
for(auto i:adj[node])
if(!vs[i])
dfs(i);
}
void solve()
{
int n;
cin>>n;
vector<string>arr(n);
vector<string>brr(n);
for(int i=0; i<n; i++)
{
cin>>arr[i];
//mp[arr[i]]=arr[i];
}
for(int i=0;i<n;i++)
{
cin>>brr[i];
//mp[brr[i]]=brr[i];
adj[brr[i]].push_back(arr[i]);
adj[arr[i]].push_back(brr[i]);
}
for(int i=0;i<n;i++)
{
vs.clear();
aa.clear();
if(isint(arr[i])&&isint(brr[i]))
{
if(arr[i]!=brr[i])
{
cout<<"NE"<<endl;
return;
}
}
else
{
if(isint(arr[i]))
dfs(brr[i]);
else //if(isint(mp[brr[i]]))
dfs(arr[i]);
if(aa.sz>1)
{
cout<<"NE"<<endl;
return;
}
}
}
// for(int i=0;i<n;i++)
//{
// if(mp[arr[i]]!=mp[brr[i]])
// {
// cout<<"NE"<<endl;
// return;
// }
// }
cout<<"DA"<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
//freopen("window.in","r",stdin);
//freopen("output.txt","w",stdout);
int t=1;//int st;
//cin>>t;//cin>>st;
while(t--)
solve();
}
Compilation message
zamjena.cpp: In function 'bool isint(std::string)':
zamjena.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i=0;i<s.sz;i++)
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
534 ms |
628 KB |
Output is correct |
2 |
Correct |
20 ms |
460 KB |
Output is correct |
3 |
Correct |
4 ms |
972 KB |
Output is correct |
4 |
Correct |
5 ms |
1080 KB |
Output is correct |
5 |
Correct |
19 ms |
1060 KB |
Output is correct |
6 |
Correct |
6 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
2892 KB |
Output is correct |
2 |
Correct |
369 ms |
4732 KB |
Output is correct |
3 |
Correct |
41 ms |
7192 KB |
Output is correct |
4 |
Correct |
65 ms |
9020 KB |
Output is correct |
5 |
Execution timed out |
1094 ms |
12388 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |