답안 #888330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
888330 2023-12-17T01:37:16 Z 1075508020060209tc Paths (BOI18_paths) C++14
20 / 100
295 ms 38556 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//const int mod=998244353;
int n;int m;int K;
int cr[500005];
int ar[500005];
int br[500005];
vector<int>e[500005];
int ans;

void solve2(){
for(int i=1;i<=m;i++){
    if(cr[ar[i]]!=cr[br[i]]){ans+=2;}
}
}

void solve3(){
int ret=0;
for(int nw=1;nw<=n;nw++){
    vector<int>tbl(10,0);
    for(int i=0;i<e[nw].size();i++){
        int v=e[nw][i];
//        if(cr[v]==cr[nw]){continue;}
        for(int j=1;j<=5;j++){
            if(j==cr[v]){continue;}
            if(j==cr[nw]){continue;}
            if(cr[v]==cr[nw]){continue;}
            ret+=tbl[j];
        }
        tbl[cr[v]]++;
    }
}
ret*=2;
ans+=ret;
}

signed main(){
cin>>n>>m>>K;
for(int i=1;i<=n;i++){
    cin>>cr[i];
}
for(int i=1;i<=m;i++){
    cin>>ar[i]>>br[i];
    e[ar[i]].push_back(br[i]);
    e[br[i]].push_back(ar[i]);
}
ans=0;
solve2();
solve3();
cout<<ans<<"\n";


}

Compilation message

paths.cpp: In function 'void solve3()':
paths.cpp:23:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0;i<e[nw].size();i++){
      |                 ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 16988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 28128 KB Output is correct
2 Correct 97 ms 30544 KB Output is correct
3 Correct 251 ms 37968 KB Output is correct
4 Correct 151 ms 32464 KB Output is correct
5 Correct 136 ms 32536 KB Output is correct
6 Correct 197 ms 36012 KB Output is correct
7 Correct 295 ms 38248 KB Output is correct
8 Correct 244 ms 38556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 16988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16984 KB Output is correct
2 Incorrect 35 ms 21848 KB Output isn't correct
3 Halted 0 ms 0 KB -