Untitled
unknown
plain_text
22 days ago
2.7 kB
3
Indexable
Never
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define ll long long #define db double #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() #define speed ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0); /* " وَأَن لَّيْسَ لِلْإِنسَانِ إِلَّا مَا سَعَى ﴿39﴾ وَأَنَّ سَعْيَهُ سَوْفَ يُرَى ﴿40﴾ ثُمَّ يُجْزَاهُ الْجَزَاء الْأَوْفَى " */ const ll N = 1e6 + 5, inf = 2e18, mod = 1e9 + 7; ll dx[] = {0, 0, -1, 1, -1, 1, 1, -1}; ll dy[] = {1, -1, 0, 0, 1, 1, -1, -1}; char di[] = {'R', 'L', 'U', 'D'}; vector<string> maybe; struct item { string val; ll bulk, cow; }; void BT(string temp = "") { if (temp.size() == 4) { set<char> st; for (int i = 0; i < 4; i++) st.insert(temp[i]); if (st.size() == 4) maybe.push_back(temp); return; } for (char c = '0'; c <= '9'; c++) BT(temp + c); } void solve() { BT(); ll n; cin >> n; vector<item> v(n); for (int i = 0; i < n; ++i) cin >> v[i].val >> v[i].bulk >> v[i].cow; vector<string> valid; for (int k = 0; k < maybe.size(); ++k) { string temp = maybe[k]; bool ok = 1; map<char, bool> mp; for (int i = 0; i < 4; ++i) mp[temp[i]] = 1; for (int i = 0; i < n; ++i) { ll b = 0, c = 0; for (int j = 0; j < 4; ++j) { if (temp[j] == v[i].val[j]) b++; else if (mp[v[i].val[j]]) c++; } if (b != v[i].bulk or c != v[i].cow) { ok = 0; break; } } if (ok) valid.push_back(temp); } if(!valid.size()) cout<<"Incorrect data"; else if(valid.size()==1) cout<<valid[0]; else cout<<"Need more data"; } void file() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } int main() { speed file(); int testcases = 1; // cin >> testcases; while (testcases--) solve(); }
Leave a Comment