답안 #364043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
364043 2021-02-08T06:12:55 Z Andyvanh1 Love Polygon (BOI18_polygon) C++11
0 / 100
343 ms 16620 KB
using namespace std;


// 17.4.1.2 Headers

// C


#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

void solve(){
    int n;
    cin>>n;
    map<string,string> Map;
    vector<string> arr(n);
    for(int i = 0; i < n; i++){
        string s1, s2;
        cin>>s1>>s2;
        Map.insert({s1,s2});
        arr[i] = s1;
    }
    if(n%2==1){
        cout<<-1;
        return;
    }
    int ans = n/2;
    int x = 0;
    for(int i = 0; i < n; i++){
        if(arr[i]==Map[Map[arr[i]]]&&arr[i]!=Map[arr[i]]){
            x++;
        }
    }
    ans-=x/2;

    int y = 0;

    for(int i = 0; i < n; i++){
        if(arr[i]==Map[arr[i]]){
            y++;
        }
    }
    ans+=(int)ceil((double)y/2);

    cout<<ans;
}



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);





    int tc = 1;
//read(tc);

    while(tc--) {
        //write("Case #", i+1, ": ");
        solve();

    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 309 ms 16620 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 343 ms 14444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -