답안 #316130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316130 2020-10-25T11:35:03 Z georgerapeanu Tenis (COCI20_tenis) C++11
55 / 110
76 ms 4888 KB
#include <bits/stdc++.h>

using namespace std;

const int NMAX = 100005;

int n;
int ran[3][NMAX + 5];
int pos[3][NMAX + 5];

long long ans[3];

int appeared[NMAX + 5];
int fr[1 << 3];
int wh[NMAX + 5];
int wins[NMAX + 5];

int get_best(int a,int b){
    pair<pair<int,int>,int> bst = {{1e9,1e9},1e9};

    for(int h = 0;h < 3;h++){
        pair<pair<int,int>,int> tmp = {{min(pos[h][a],pos[h][b]),max(pos[h][a],pos[h][b])},h};
        bst = min(bst,tmp);
    }
    return bst.second;
}

int get_winner(int a,int b){
    pair<pair<int,int>,int> bst = {{1e9,1e9},1e9};

    for(int h = 0;h < 3;h++){
        pair<pair<int,int>,int> tmp = {{min(pos[h][a],pos[h][b]),max(pos[h][a],pos[h][b])},h};
        bst = min(bst,tmp);
    }
    return ran[bst.second][bst.first.first];
}

int bonus[NMAX + 5];

int main(){
    
    scanf("%d",&n);

    for(int h = 0;h <= 2;h++){
        for(int i = 1;i <= n;i++){
            scanf("%d",&ran[h][i]);
            pos[h][ran[h][i]] = i;
        }
    }

    for(int i = 1;i <= n;i++){
        vector<int> noi;
        for(int h = 0;h <= 2;h++){
            if(wh[ran[h][i]] == 0 || wh[ran[h][i]] == i){
                if(wh[ran[h][i]] == 0){
                    noi.push_back(ran[h][i]);
                    wh[ran[h][i]] = i;
                }
                appeared[ran[h][i]] |= 1 << h;
            }
        }
        for(auto it:noi){
            for(int conf = 0;conf < (1 << 3);conf++){
                int tmp = conf & appeared[it];
                int lowest_common_bit = 0;
                for(int i = 0;i < 3;i++){
                    if((conf >> i) & 1){
                        lowest_common_bit = i;
                        break;
                    }
                }
                ans[lowest_common_bit] += fr[conf];
            }
        }
        for(auto it:noi){
            fr[appeared[it]]++;
        }
        for(int i = 0;i < (int)noi.size();i++){
            for(int j = i + 1;j < (int)noi.size();j++){
                ans[get_best(noi[i],noi[j])]++;
                wins[get_winner(noi[i],noi[j])]++;
            }
        }
        bonus[i - 1] += (int)noi.size();
    }

    for(int i = n;i >= 0;i--){
        bonus[i] += bonus[i + 1];
    }

    for(int i = 1;i <= n;i++){
        wins[i] += bonus[wh[i]];
    }

    for(int i = 0;i < 3;i++)printf("%lld ",ans[i]);printf("\n");
    for(int i = 1;i <= n;i++)printf("%d ",wins[i]);printf("\n");

    return 0;
}

Compilation message

tenis.cpp: In function 'int main()':
tenis.cpp:64:21: warning: unused variable 'tmp' [-Wunused-variable]
   64 |                 int tmp = conf & appeared[it];
      |                     ^~~
tenis.cpp:95:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   95 |     for(int i = 0;i < 3;i++)printf("%lld ",ans[i]);printf("\n");
      |     ^~~
tenis.cpp:95:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   95 |     for(int i = 0;i < 3;i++)printf("%lld ",ans[i]);printf("\n");
      |                                                    ^~~~~~
tenis.cpp:96:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   96 |     for(int i = 1;i <= n;i++)printf("%d ",wins[i]);printf("\n");
      |     ^~~
tenis.cpp:96:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   96 |     for(int i = 1;i <= n;i++)printf("%d ",wins[i]);printf("\n");
      |                                                    ^~~~~~
tenis.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
tenis.cpp:46:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |             scanf("%d",&ran[h][i]);
      |             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Partially correct 1 ms 384 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Partially correct 1 ms 384 KB Partially correct
4 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Partially correct 1 ms 384 KB Partially correct
4 Correct 3 ms 512 KB Output is correct
5 Partially correct 29 ms 2168 KB Partially correct
6 Correct 45 ms 3064 KB Output is correct
7 Partially correct 60 ms 3960 KB Partially correct
8 Partially correct 76 ms 4860 KB Partially correct
9 Partially correct 75 ms 4856 KB Partially correct
10 Partially correct 72 ms 4888 KB Partially correct