Submission #535831

# Submission time Handle Problem Language Result Execution time Memory
535831 2022-03-11T12:50:14 Z idas Cards (LMIO19_korteles) C++11
0 / 100
1000 ms 33752 KB
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr)
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define TSTS int ttt; cin >> ttt; while(ttt--) solve()
#define all(x) (x).begin(), (x).end()
#define le(vec) vec[vec.size()-1]
#define sz(x) ((int)((x).size()))
#define pb push_back
#define s second
#define f first

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;

const int INF=1e9, MOD=1e9+7, mod=998244353;
const ll LINF=1e13;

void setIO()
{
    FAST_IO;
}

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

const int N=5e5+10;
int n;
ll ans;
char g[N][2][2];
map<vector<char>, int> Up, Left, Right, Down, LU, UR, RD, DL, all;

int main()
{
    setIO();
    cin >> n;
    FOR(i, 0, n)
    {
        FOR(j, 0, 2)
        {
            FOR(k, 0, 2)
            {
                cin >> g[i][j][k];
            }
        }
    }

    FOR(i, 0, n)
    {
        char a=g[i][0][0], b=g[i][0][1], c=g[i][1][0], d=g[i][1][1];
        ans+=Up[{c,d}];
        ans+=Right[{a,c}];
        ans+=Down[{a,b}];
        ans+=Left[{b,d}];
        if(a==d){
            ans-=UR[{c,a,c}];
            ans-=DL[{b,a,b}];
        }
        if(b==c){
            ans-=LU[{d,b,d}];
            ans-=RD[{a,b,a}];
        }
        if(a==d && b==c){
            ans+=all[{b,a,a,b}];
        }

        Up[{a,b}]++;
        Right[{b,d}]++;
        Down[{c,d}]++;
        Left[{a,c}]++;
        LU[{c,a,b}]++;
        UR[{a,b,d}]++;
        RD[{b,d,c}]++;
        DL[{d,c,a}]++;
        all[{a,b,c,d}]++;
    }

    cout << ans;
}

Compilation message

korteles.cpp: In function 'void setIO(std::string)':
korteles.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
korteles.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 33752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 243 ms 13184 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -