Submission #404296

#TimeUsernameProblemLanguageResultExecution timeMemory
404296idasCards (LMIO19_korteles)C++11
0 / 100
193 ms2844 KiB
#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, int> 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)

korteles.cpp: In function 'int main()':
korteles.cpp:60:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   60 |     for(auto[x, y] : up)
      |             ^
korteles.cpp:63:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   63 |         for(auto[z, w] : down)
      |                 ^
korteles.cpp:77:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   77 |     for(auto[x, y] : lefts)
      |             ^
korteles.cpp:80:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   80 |         for(auto[z, w] : rights)
      |                 ^
korteles.cpp: In function 'void setIO(std::string)':
korteles.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
korteles.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen((s+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...