Submission #815599

# Submission time Handle Problem Language Result Execution time Memory
815599 2023-08-08T17:16:26 Z serifefedartar PIN (CEOI10_pin) C++17
0 / 100
8 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 20
#define MAXN 1000005
    
int temp[4], same[4];
int cnt[40][40][40][40];
int get(char ch) {
    if (ch >= '0' && ch <= '9')
        return ch-'0';
    return ch-'temp'+10;
}

int main() {
    fast
    int N, D;
    vector<string> PIN(N);
    for (int i = 0; i < N; i++) {
        cin >> PIN[i];
        for (int mask = 0; mask < 16; mask++) {
            for (int plc = 0; plc < 4; plc++) {
                if ((1<<plc) & mask)
                    temp[plc] = get(PIN[i][plc]);
                else
                    temp[plc] = 36;
            }
            cnt[temp[0]][temp[1]][temp[2]][temp[3]]++;
        }
    }

    for (int plc1 = 0; plc1 <= 36; plc1++) {
        for (int plc2 = 0; plc2 <= 36; plc2++) {
            for (int plc3 = 0; plc3 <= 36; plc3++) {
                for (int plc4 = 0; plc4 <= 36; plc4++) {
                    int same_plc = (plc1 < 36) + (plc2 < 36) + (plc3 < 36) + (plc4 < 36);
                    same[same_plc] += (cnt[plc1][plc2][plc3][plc4] * (cnt[plc1][plc2][plc3][plc4] - 1)) / 2; 
                } 
            }
        }
    }

    if (D == 1)
        cout << same[3] << "\n";
    else if (D == 2)
        cout << same[2] - 3 * same[3] << "\n";
    else if (D == 3)
        cout << same[1] - 2 * same[2] + 3 * same[3] << "\n";
    else
        cout << same[0] - same[1] + same[2] - same[3] << "\n";
}

Compilation message

pin.cpp:17:15: warning: multi-character character constant [-Wmultichar]
   17 |     return ch-'temp'+10;
      |               ^~~~~~
pin.cpp: In function 'int main()':
pin.cpp:23:25: warning: 'N' is used uninitialized in this function [-Wuninitialized]
   23 |     vector<string> PIN(N);
      |                         ^
pin.cpp:48:5: warning: 'D' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     if (D == 1)
      |     ^~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 212 KB Output isn't correct
2 Incorrect 5 ms 340 KB Output isn't correct
3 Incorrect 5 ms 340 KB Output isn't correct
4 Incorrect 5 ms 340 KB Output isn't correct
5 Incorrect 5 ms 340 KB Output isn't correct
6 Incorrect 5 ms 340 KB Output isn't correct
7 Incorrect 5 ms 336 KB Output isn't correct
8 Incorrect 5 ms 212 KB Output isn't correct
9 Incorrect 5 ms 340 KB Output isn't correct
10 Incorrect 5 ms 212 KB Output isn't correct
11 Incorrect 5 ms 340 KB Output isn't correct
12 Incorrect 6 ms 328 KB Output isn't correct
13 Incorrect 6 ms 340 KB Output isn't correct
14 Incorrect 5 ms 212 KB Output isn't correct
15 Incorrect 8 ms 332 KB Output isn't correct
16 Incorrect 5 ms 340 KB Output isn't correct
17 Incorrect 5 ms 212 KB Output isn't correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 Incorrect 5 ms 340 KB Output isn't correct
20 Incorrect 5 ms 340 KB Output isn't correct