답안 #261711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
261711 2020-08-12T02:32:42 Z cheeheng Colors (RMI18_colors) C++14
7 / 100
197 ms 7212 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;

vector<int> AdjList[150005];
int a[150005];
int b[150005];
ii ab[150005];

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

    while(t --){
        int N, M;
        scanf("%d%d", &N, &M);

        for(int i = 1; i <= N; i ++){
            scanf("%d", &a[i]);
        }

        for(int i = 1; i <= N; i ++){
            scanf("%d", &b[i]);
        }

        for(int i = 0; i < M; i ++){
            int u, v;
            scanf("%d%d", &u, &v);
            AdjList[u].push_back(v);
            AdjList[v].push_back(u);
        }

        int ans = 1;
        for(int i = 1; i <= N; i ++){
            if(b[i] > a[i]){
                ans = 0;
                break;
            }
        }

        if(ans == 0){
            printf("0\n");
            continue;
        }

        if((long long)M == (long long)N*(N-1)/2 || true){
            multiset<int> s;
            for(int i = 1; i <= N; i ++){
                ab[i] = ii(a[i], b[i]);
                s.insert(a[i]);
            }
            sort(ab+1, ab+(N+1), greater<ii>());

            for(int i = 1; i <= N; i ++){
                if(ab[i].first == ab[i].second){continue;}
                if(ab[i].first < ab[i].second){
                    ans = 0;
                    break;
                }
                if(s.find(ab[i].second) != s.end()){

                }else{
                    ans = 0;
                    break;
                }

                s.erase(s.find(ab[i].first));
            }
            printf("%d\n", ans);
        }
    }


    return 0;
}

Compilation message

colors.cpp: In function 'int main()':
colors.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ~~~~~^~~~~~~~~~
colors.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &N, &M);
         ~~~~~^~~~~~~~~~~~~~~~
colors.cpp:20:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a[i]);
             ~~~~~^~~~~~~~~~~~~
colors.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &b[i]);
             ~~~~~^~~~~~~~~~~~~
colors.cpp:29:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 5652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 7032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 5752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 5752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 5652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 197 ms 7212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 5240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 5652 KB Output isn't correct
2 Halted 0 ms 0 KB -