# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404298 | idas | Cards (LMIO19_korteles) | C++11 | 194 ms | 656 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SZ(x) ((int)((x).size()))
#define LE(vec) vec[vec.size()-1]
#define TSTS int t; cin >> t; while(t--)solve()
const int INF = 1e9;
const long long LINF = 1e18;
const long double PI = asin(1)*2;
const int MOD = 1e9+7;
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef long long ll;
typedef long double ld;
void setIO()
{
FAST_IO;
}
void setIO (string s) {
setIO();
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str(),"w",stdout);
}
unordered_map<string, ll> up, down, lefts, rights;
map<pii, bool> used;
int main()
{
setIO();
int n;
cin >> n;
FOR(i, 0, n)
{
string a, b;
cin >> a >> b;
up[a]++;
down[b]++;
string lft = "", rt = "";
lft += a[0];
lft += b[0];
rt += a[1];
rt += b[1];
lefts[lft]++;
rights[rt]++;
}
ll ans = 0;
int in1 = 0, in2 = 0;
for(auto[x, y] : up)
{
in2 = 0;
for(auto[z, w] : down)
{
if(x == z && in1!=in2 && !used.count(MP(in1, in2)))
{
ans += y*w;
used[MP(in1, in2)] = true;
used[MP(in2, in1)] = true;
}
in2++;
}
in1++;
}
in1 = 0;
for(auto[x, y] : lefts)
{
in2 = 0;
for(auto[z, w] : rights)
{
if(x == z && in1!=in2 && !used.count(MP(in1, in2)))
{
ans += y*w;
used[MP(in1, in2)] = true;
used[MP(in2, in1)] = true;
}
in2++;
}
in1++;
}
cout << ans;
}
Compilation message (stderr)
# | 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... |