Submission #149060

# Submission time Handle Problem Language Result Execution time Memory
149060 2019-09-01T05:39:26 Z Outfraware Boat People(#3577, c4big, bsyo2k, cepiloth) FunctionCup Museum (FXCUP4_museum) C++17
Compilation error
0 ms 0 KB
#include "museum.h"

#include <string>
#include <algorithm>
#include <map>

void score(std::map<string, int>& m, int i, int j) {
	string s;
	s.append(to_string(i));
	s.append(to_string(j));
	sort(s.begin(), s.end());
	m[s]++;
}

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	int N = B.size();

	std::map<string, int> m;
	for (int i = 0; i < N; i++) {
		int candB = B[i];
		int candT = T[i];
		int candG = G[i];
		
		for (int j = 0; j < N; j++) {
			// 같으면 continue
			if (i == j) {
				continue;
			}
			string s;
			if (candB == B[j]) {
				score(m, i, j);
				continue;
			}

			if (candT == T[j]) {
				score(m, i, j);

				continue;
			}

			if (candG == G[j]) {
				score(m, i, j);
				continue;
			}

		}
	}
	return m.size();
}

Compilation message

museum.cpp:7:21: error: 'string' was not declared in this scope
 void score(std::map<string, int>& m, int i, int j) {
                     ^~~~~~
museum.cpp:7:21: note: suggested alternatives:
In file included from /usr/include/c++/7/string:39:0,
                 from museum.cpp:3:
/usr/include/c++/7/bits/stringfwd.h:74:33: note:   'std::__cxx11::string'
   typedef basic_string<char>    string;
                                 ^~~~~~
/usr/include/c++/7/bits/stringfwd.h:74:33: note:   'std::__cxx11::string'
museum.cpp:7:32: error: template argument 1 is invalid
 void score(std::map<string, int>& m, int i, int j) {
                                ^
museum.cpp:7:32: error: template argument 3 is invalid
museum.cpp:7:32: error: template argument 4 is invalid
museum.cpp: In function 'void score(int&, int, int)':
museum.cpp:8:2: error: 'string' was not declared in this scope
  string s;
  ^~~~~~
museum.cpp:8:2: note: suggested alternatives:
In file included from /usr/include/c++/7/string:39:0,
                 from museum.cpp:3:
/usr/include/c++/7/bits/stringfwd.h:74:33: note:   'std::__cxx11::string'
   typedef basic_string<char>    string;
                                 ^~~~~~
/usr/include/c++/7/bits/stringfwd.h:74:33: note:   'std::__cxx11::string'
museum.cpp:9:2: error: 's' was not declared in this scope
  s.append(to_string(i));
  ^
museum.cpp:9:11: error: 'to_string' was not declared in this scope
  s.append(to_string(i));
           ^~~~~~~~~
museum.cpp:9:11: note: suggested alternatives:
In file included from /usr/include/c++/7/string:52:0,
                 from museum.cpp:3:
/usr/include/c++/7/bits/basic_string.h:6454:3: note:   'std::__cxx11::to_string'
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6454:3: note:   'std::__cxx11::to_string'
museum.cpp:11:2: error: 'sort' was not declared in this scope
  sort(s.begin(), s.end());
  ^~~~
museum.cpp:11:2: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from museum.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:4856:5: note:   'std::sort'
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^~~~
museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:18:11: error: 'string' was not declared in this scope
  std::map<string, int> m;
           ^~~~~~
museum.cpp:18:11: note: suggested alternatives:
In file included from /usr/include/c++/7/string:39:0,
                 from museum.cpp:3:
/usr/include/c++/7/bits/stringfwd.h:74:33: note:   'std::__cxx11::string'
   typedef basic_string<char>    string;
                                 ^~~~~~
/usr/include/c++/7/bits/stringfwd.h:74:33: note:   'std::__cxx11::string'
museum.cpp:18:22: error: template argument 1 is invalid
  std::map<string, int> m;
                      ^
museum.cpp:18:22: error: template argument 3 is invalid
museum.cpp:18:22: error: template argument 4 is invalid
museum.cpp:29:11: error: expected ';' before 's'
    string s;
           ^
museum.cpp:48:11: error: request for member 'size' in 'm', which is of non-class type 'int'
  return m.size();
           ^~~~