이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pi;
typedef long long int lint;
const int inf = 0x3f3f3f3f;
const int maxn = 50000 + 10;
int n;
string a[maxn], b[maxn];
map< string, vector< int > > c, d;
map< string, bool > memo;
map< string, vector< string > > isti;
bool ok = 1;
bool isNumber(string t) {
if(t[0] >= '0' and t[0] <= '9') return 1;
return 0;
}
void dfs(string word, string number) {
if(!ok) return;
if(memo[word]) return;
memo[word] = 1;
for(int i = 0; i < isti[word].size(); ++i) {
if(isNumber(isti[word][i]) and isti[word][i] != number) ok = 0;
if(!ok) return;
if(memo[isti[word][i]]) continue;
dfs(isti[word][i], number);
}
}
int main ()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> a[i];
if(not isNumber(a[i]))
c[a[i]].pb(i);
}
for(int i = 0; i < n; ++i) {
cin >> b[i];
if(not isNumber(b[i]))
d[b[i]].pb(i);
}
for(int i = 0; i < n; ++i) {
isti[a[i]].pb(b[i]);
isti[b[i]].pb(a[i]);
}
for(int i = 0; i < n; ++i) {
if(not memo[a[i]] and isNumber(a[i])) {
dfs(a[i], a[i]);
if(!ok)
return cout << "NE", 0;
}
if(not memo[b[i]] and isNumber(b[i])) {
dfs(b[i], b[i]);
if(!ok)
return cout << "NE", 0;
}
}
cout << "DA";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
zamjena.cpp: In function 'void dfs(std::__cxx11::string, std::__cxx11::string)':
zamjena.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < isti[word].size(); ++i) {
~~^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |