Submission #855723

# Submission time Handle Problem Language Result Execution time Memory
855723 2023-10-01T17:13:21 Z vjudge1 Zamjena (COCI18_zamjena) C++17
42 / 70
99 ms 12640 KB
#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;
            }
        }
    }
    vector<pair<int, pair<string, string>>> _2s;
    F(i, 0, n) {
        bool in1 = (statements[0][i][0] - '0') < 10;
        bool in2 = (statements[1][i][0] - '0') < 10;
        if((in1 + in2) == 0) {
            _2s.pb({-((val[statements[0][i]] != "") + (val[statements[1][i]] != "")), {statements[0][i], statements[1][i]}});
        }
    }
    sort(_2s.begin(), _2s.end());
    F(i, 0, _2s.size()) {
        string s1 = _2s[i].se.fi;// çıaldaldsaldasldka
        string s2 = _2s[i].se.se;// çıaldaldsaldasldka
        if(val[s1] != "" && val[s2] == "") val[s2] = val[s1];
        if(val[s1] == "" && val[s2] != "") val[s1] = val[s2];
        if(val[s1] != "" && val[s2] != "" && val[s1] != val[s2]) {
            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();
}

Compilation message

zamjena.cpp: In function 'void solve()':
zamjena.cpp:15:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 | #define F(i, s, n) for(int i = s; i < n; i++)
......
   71 |     F(i, 0, _2s.size()) {
      |       ~~~~~~~~~~~~~~~~               
zamjena.cpp:71:5: note: in expansion of macro 'F'
   71 |     F(i, 0, _2s.size()) {
      |     ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 1 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 4 ms 1112 KB Output is correct
4 Incorrect 4 ms 1116 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2876 KB Output is correct
2 Correct 32 ms 5400 KB Output is correct
3 Correct 47 ms 6972 KB Output is correct
4 Correct 39 ms 7768 KB Output is correct
5 Correct 99 ms 12640 KB Output is correct
6 Correct 93 ms 10964 KB Output is correct