답안 #376016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
376016 2021-03-10T16:46:39 Z Aldas25 Cards (LMIO19_korteles) C++14
0 / 100
1000 ms 37268 KB
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 23;
const ll MOD = 1e9+7;
const ll INF = 1e16;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

int n;
int cards[MAXN][2][2];
map<pii, ll> cntUp, cntDown, cntRight, cntLeft;
map<pair<pii, pii>, ll> cntAll;

int main() {
	setIO();

    cin >> n;
    FOR(i, 1, n) FOR(j, 0, 1) FOR(k, 0, 1) {
        char c; cin >> c;
        cards[i][j][k] = (c-'A');
    }

    ll ans = 0;
    FOR(i, 1, n) {
        int a = cards[i][0][0], b = cards[i][0][1];
        int c = cards[i][1][0], d = cards[i][1][1];

        ll cur = 0;

        cur += cntUp[{c,d}];
        cur += cntDown[{a,b}];
        cur += cntLeft[{b,d}];
        cur += cntRight[{a,c}];
        cur -= cntAll[{{c, d}, {a, b}}];
        cur -= cntAll[{{b, a}, {d, c}}];

        ans += cur;

        cntUp[{a,b}]++;
        cntLeft[{a,c}]++;
        cntRight[{b,d}]++;
        cntDown[{c,d}]++;
        cntAll[{{a,b},{c,d}}]++;
    }

    cout << ans << "\n";

	return 0;
}

Compilation message

korteles.cpp: In function 'void setIO(std::string)':
korteles.cpp:34:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   34 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
korteles.cpp:35:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   35 |  freopen((s+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 37268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 176 ms 9884 KB Output is correct
3 Execution timed out 1080 ms 29404 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -