답안 #151594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151594 2019-09-03T15:55:55 Z MvC Zamjena (COCI18_zamjena) C++14
70 / 70
361 ms 18744 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "boxes.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=5e4+50;
const int mod=1e9+7;
using namespace std;
int n,i;
bool bs[nmax],bt[nmax];
map<pair<string,bool>,vector<pair<string,bool> > >mp;
map<string,bool>vc;
map<pair<string,bool>,bool>viz;
pair<string,bool>p;
string s[nmax],t[nmax];
void dfs(pair<string,bool>x)
{
	viz[x]=1;
	if(x.sc)vc[x.fr]=1;
	for(int i=0;i<mp[x].size();i++)
	{
		if(viz[mp[x][i]])continue;
		dfs(mp[x][i]);
	}
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>s[i];
		if(s[i][0]>='0' && s[i][0]<='9')bs[i]=1;
	}
	for(i=1;i<=n;i++)
	{
		cin>>t[i];
		if(t[i][0]>='0' && t[i][0]<='9')bt[i]=1;
		if(s[i]==t[i])continue;
		mp[mkp(s[i],bs[i])].pb(mkp(t[i],bt[i]));
		mp[mkp(t[i],bt[i])].pb(mkp(s[i],bs[i]));
	}
	for(auto it=mp.begin();it!=mp.end();it++)
	{
		p=it->fr;
		if(viz[p])continue;
		dfs(p);
		if(vc.size()>1)rc("NE");
		vc.clear();
	}
	rc("DA");
	return 0;
}

Compilation message

zamjena.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
zamjena.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
zamjena.cpp: In function 'void dfs(std::pair<std::__cxx11::basic_string<char>, bool>)':
zamjena.cpp:33:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<mp[x].size();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 3552 KB Output is correct
4 Correct 6 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 3512 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3496 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 3452 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
6 Correct 6 ms 3452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 3832 KB Output is correct
2 Correct 8 ms 3704 KB Output is correct
3 Correct 10 ms 4088 KB Output is correct
4 Correct 12 ms 4216 KB Output is correct
5 Correct 17 ms 4344 KB Output is correct
6 Correct 10 ms 4088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 5880 KB Output is correct
2 Correct 94 ms 8696 KB Output is correct
3 Correct 86 ms 10192 KB Output is correct
4 Correct 102 ms 11608 KB Output is correct
5 Correct 361 ms 18744 KB Output is correct
6 Correct 225 ms 13816 KB Output is correct