답안 #978567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978567 2024-05-09T10:52:20 Z vjudge1 Council (JOI23_council) C++17
0 / 100
4000 ms 25700 KB
#include <time.h>
#include <cstdlib>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <set>
#include <iterator>
#include <deque>
#include <queue>
#include <sstream>
#include <array>
#include <string>
#include <tuple>
#include <chrono>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

using namespace std;

int tt = 1, n, m;
int A[300001][21], cnt[22];
map<vector<int>, int> mp;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        vector<int> v;
        for(int j = 1; j <= m; j++){
            cin >> A[i][j];
            cnt[j] += A[i][j];
            v.push_back(A[i][j]);
        }
        mp[v]++;
    }
    for(int i = 1; i <= n; i++){
        int mx = 0;
        if(m == 2){
            vector<int> vv;
            for(int j = 1; j <= m; j++) vv.push_back(A[i][j]);
            mp[vv]--;
            int f1 = 0, f2 = 0, kol = 2;
            if(cnt[1] - A[i][1] == n / 2) f1 = 1;
            if(cnt[1] - A[i][1] < n / 2) f1 = 2;

            if(cnt[2] - A[i][2] == n / 2) f2 = 1;
            if(cnt[2] - A[i][2] < n / 2) f2 = 2;

            if(f1 == 0 && f2 == 0){
                cout << 2 << "\n";
                mp[vv]++;
                continue;
            }
            vector<int> v1, v2, v3, v4;
            v1 = {0, 0};
            v2 = {1, 0};
            v3 = {0, 1};
            v4 = {1, 1};
            if(f1 == 2) kol--;
            if(f2 == 2) kol--;
            if(mp[v1] > 0){
                cout << kol << "\n";
                mp[vv]++;
                continue;
            }
            if(kol == 0){
                cout << kol << "\n";
                mp[vv]++;
                continue;
            }
            if(kol == 2){
                if(f1 == 1 && mp[v3] > 0){
                    if(f2 == 1) kol--;
                    cout << kol << "\n";
                    mp[vv]++;
                    continue;
                }

                if(f2 == 1 && mp[v2] > 0){
                    if(f1 == 1) kol--;
                    cout << kol << "\n";
                    mp[vv]++;
                    continue;
                }
                // cout << i << " " << f1 << " " << f2 << "\n";
                if(f1 == 1) kol--;
                if(f2 == 1) kol--;
                cout << kol << "\n";
                mp[vv]++;
                continue;
            }
            if(kol == 1){
                if(f1 == 1){
                    if(mp[v3] > 0){
                        mp[vv]++;
                        cout << kol << "\n";
                        continue;
                    }
                    cout << kol - 1 << "\n";
                    mp[vv]++;
                    continue;
                }
                else{
                    if(mp[v2] > 0){
                        mp[vv]++;
                        cout << kol << "\n";
                        continue;
                    }
                    cout << kol - 1 << "\n";
                    mp[vv]++;
                    continue;
                }
            }
        }
        for(int j = 1; j <= n; j++){
            if(i == j) continue;
            int kol = 0;
            for(int ind = 1; ind <= m; ind++){
                if(cnt[ind] - A[i][ind] - A[j][ind] >= n / 2) 
                    kol++;
            }
            mx = max(mx, kol);
        }
        cout << mx << "\n";
    }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 424 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 424 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 82 ms 25684 KB Output is correct
3 Correct 113 ms 25700 KB Output is correct
4 Execution timed out 4050 ms 25088 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 82 ms 25684 KB Output is correct
3 Correct 113 ms 25700 KB Output is correct
4 Execution timed out 4050 ms 25088 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 82 ms 25684 KB Output is correct
3 Correct 113 ms 25700 KB Output is correct
4 Execution timed out 4050 ms 25088 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 82 ms 25684 KB Output is correct
3 Correct 113 ms 25700 KB Output is correct
4 Execution timed out 4050 ms 25088 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 424 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -