QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572685#3934. Counting ClausesLaVuna47#AC ✓0ms3884kbC++173.2kb2024-09-18 15:56:102024-09-18 15:56:10

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 15:56:10]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3884kb
  • [2024-09-18 15:56:10]
  • 提交

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define RFOR(i, n) for(int i = n-1; i >= 0; --i)
#define output_vec(vec) { FOR(i_, sz(vec)) cout << vec[i_] << ' '; cout << '\n'; }
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<bool> vb;
typedef short si;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int n, m;
vector<vector<int>> a;

bool check(int mask)
{
    //int n = sz(a);
    //int m = sz(a[0]);
    vector<int> v(m, -1);
    FOR (i, m)
    {
        if (mask & 1 << i)
            v[i] = 1;
    }
    FOR (i, n)
    {
        bool ok = false;
        FOR (j, m)
        {
            auto it1 = find(all(a[i]), (j + 1));
            auto it2 = find(all(a[i]), -(j + 1));
            if (it1 == a[i].end() && it2 == a[i].end())
                continue;
            if (it1 != a[i].end() && it2 != a[i].end())
                {
                    ok = true;
                    break;
                }
            
            if (it1 != a[i].end())
            {
                if (v[j] == 1)
                {
                    ok = true;
                    break;
                }
            }
            else
            {
                if (v[j] == -1)
                {
                    ok = true;
                    break;
                }
            }
        }
        if (!ok)
            return false;
    }
    return true;
}

int solve()
{
    //int n, m;
    if (!(cin >> n >> m))
        return 1;
    
    
    
    a.clear();    
    a.resize(n, vector<int>(3));
    FOR (i, n)
        FOR (j, 3)
            cin >> a[i][j];
            
    if (n >= 8)
        cout << "satisfactory\n";
    else
        cout << "unsatisfactory\n";
    return 0;
            
    for (int i = 0; i < 1 << m; i++)
    {
        if (check(i))
        {
            cout << i << '\n';
            cout << "satisfactory\n";
            return 0;
        }
    }
    cout << "unsatisfactory\n";
    return 0;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1e9;
    //cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

5 3
-1 2 3
-1 -2 3
1 -2 3
1 -2 -3
1 2 -3

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

8 3
1 2 3
1 2 -3
1 -2 3
1 -2 -3
-1 2 3
-1 2 -3
-1 -2 3
-1 -2 -3

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

4 3
-2 1 3
3 -2 1
3 -3 2
2 -3 1

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

8 20
14 8 12
-10 7 20
3 -10 -1
5 12 3
18 -18 17
4 7 13
-3 -18 -19
-4 18 -7

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

3 3
-2 -1 1
-2 3 1
2 3 -3

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

9 20
5 10 -11
5 15 -2
-3 -8 -10
-17 -6 13
14 3 -3
-9 -14 -4
-15 -16 -19
-7 -19 -4
-5 -1 -14

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

7 20
-5 -17 -10
13 -19 9
-13 3 10
-5 4 14
-20 -7 6
19 -4 2
-14 16 -5

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

2 20
-4 -18 -20
16 -15 11

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

10 20
6 -16 -5
17 5 -17
-15 15 7
-17 16 -13
-18 -15 7
17 -17 16
-17 -16 14
-17 12 -7
-6 -18 15
-14 3 17

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

5 20
-6 3 4
12 -7 5
-19 9 11
-15 -12 -5
-12 -8 -18

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

11 20
8 7 -10
17 -16 4
9 19 3
-18 4 -10
-13 -12 12
-14 -2 -7
1 15 19
-20 1 12
9 18 -15
-10 -5 -17
-3 -12 -9

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

6 20
16 -18 7
10 16 -20
-18 6 -12
-16 -5 3
-7 9 11
-3 -10 -18

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

12 20
10 20 19
18 5 8
-20 13 -16
8 15 9
-1 -11 -15
-17 -18 -8
-5 18 -19
8 12 17
17 -8 13
-8 -9 12
-9 -14 8
14 20 -18

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1 20
10 -3 13

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

13 15
-11 12 -8
14 6 10
5 8 -10
11 -11 -13
12 13 -10
4 -15 -7
12 -9 8
-6 -15 -2
-7 -6 6
13 10 -7
-11 -13 2
5 -8 6
-11 11 6

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

9 14
-11 5 8
-6 -3 11
10 -11 -6
-6 -5 9
-7 13 14
-7 -6 9
-10 -9 3
10 6 2
-4 -3 11

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

18 8
7 -6 6
1 8 7
-2 -8 8
-8 -7 -4
3 6 2
3 -1 -2
1 8 5
6 4 -6
3 -1 -5
3 2 -1
-7 -3 -1
7 -8 -2
6 1 4
-4 -3 -8
8 -1 -3
-1 6 5
4 -7 -6
2 6 3

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

15 20
18 -1 -19
-2 6 -6
-6 -20 -2
-15 2 11
3 -4 6
20 -19 9
7 13 -9
-6 18 -4
8 -20 6
9 18 20
16 -2 17
-4 -5 20
-2 -6 -1
-1 1 -11
-19 -11 18

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

20 20
6 -4 12
15 -7 -5
1 14 -13
-12 -8 -11
-12 15 -17
20 -16 -1
10 20 18
2 -17 10
3 17 -20
5 -5 -13
3 16 -17
13 6 -1
6 -15 12
13 3 -17
1 -19 7
3 -2 -9
-19 -5 4
14 15 -7
-11 6 12
14 -3 -13

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

1 20
-9 -13 8

output:

unsatisfactory

result:

ok single line: 'unsatisfactory'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

17 20
-12 20 11
2 13 -2
6 -6 14
12 -8 5
-19 16 19
-18 13 -13
8 -1 16
12 -10 20
-14 15 9
16 -14 -7
-13 14 9
17 7 5
-20 9 10
4 -16 -14
17 -11 18
6 -19 -14
4 -8 -12

output:

satisfactory

result:

ok single line: 'satisfactory'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

16 20
-5 -17 -20
-10 -19 6
-13 -19 -3
-11 -4 20
-14 -15 -8
-4 -10 19
-4 -2 -1
-12 1 18
17 8 6
8 -11 20
-5 -18 -8
19 -1 -3
-15 -7 16
7 -15 20
13 11 5
6 -16 -14

output:

satisfactory

result:

ok single line: 'satisfactory'