이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,O3,unroll-loops")
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpi vector<pii>
#define vvpi vector<vpi>
#define vb vector<bool>
#define vvb vector<vb>
#define endl "\n"
#define sp << " " <<
#define F(i, s, n) for(int i = s; i < n; i++)
#define pb push_back
#define fi first
#define se second
int mod = 998244353;
int inf = LLONG_MAX >> 3;
int mult(int x, int y) {
return (x%mod)*(y%mod)%mod;
}
void solve() {
int n;
cin >> n;
vector<string> statements[2];
F(i, 0, n) {
string x;
cin >> x;
statements[0].pb(x);
}
F(i, 0, n) {
string x;
cin >> x;
statements[1].pb(x);
}
map<string, string> val;
F(i, 0, n) {
bool in1 = (statements[0][i][0] - '0') < 10;
bool in2 = (statements[1][i][0] - '0') < 10;
if(!in1 && in2) swap(statements[0][i], statements[1][i]);
if((in1 + in2) == 2) {
if(statements[0][i][0] != statements[1][i][0]) {
cout << "NE" << endl;
return;
}
}
else if((in1 + in2) == 1) {
string value = statements[0][i];
if(val[statements[1][i]] == "") {
val[statements[1][i]] = value;
} else if(val[statements[1][i]] != value) {
cout << "NE" << endl;
return;
}
}
}
F(i, 0, n) {
bool in1 = (statements[0][i][0] - '0') < 10;
bool in2 = (statements[1][i][0] - '0') < 10;
if((in1 + in2) == 0) {
if(val[statements[0][i]] != "" && val[statements[1][i]] != "" && val[statements[0][i]] != val[statements[1][i]]) {
cout << "NE" << endl;
return;
}
}
}
cout << "DA" << endl;
}
void setIO() {
ios::sync_with_stdio(0); cin.tie(0);
#ifdef Local
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
signed main() {
setIO();
int t = 1;
//cin >> t;
while(t--) solve();
}
# | 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... |