답안 #976380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976380 2024-05-06T13:46:53 Z vjudge1 별들과 삼각형 (IZhO11_triangle) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define bismillah ios_base::sync_with_stdio(0); cin.tie(0);
#define int 		  long long
#define v 			  vector
#define pb 			  push_back
#define ppb 		  pop_back
#define all(x)    x.begin(), x.end()
#define rall(x)   x.begin(), x.end()
#define pii 		  pair<int, int>
#define pll 		  pair<long long, long long>
#define fi 			  first
#define se 			  second
#define mp 			  make_pair
#define lb 			  lower_bound
#define ub 			  upper_bound
#define endl 		  '\n'
#define tc 			  int t = 1; while (t--)
// #define tc 			  int t; cin >> t; while (t--)
const int MOD = 1e9 + 7;
const int INF = 1e17;
using namespace std;

int yp[300000], yn[300000], xp[300000], xn[300000];

signed main(){
	bismillah;
	tc {
		//input
		int n; cin >> n;
		int coordX[n + 1], coordY[n + 1];
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			
			if (x >= 0)
				xp[x]++;
			else
				xn[-x]++;
			if (y >= 0)
				yp[y]++;
			else
				yn[-y]++;
				
			coordX[i] = x;
			coordY[i] = y;
		}
		
		//solve
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += (xp[coordX[i]] + xn[coordX[i]] - 1) * (yp[coordY[i]] + yn[coordY[i]] - 1);
		}
		
		//output
		cout << ans << endl;
	}
}

Compilation message

triangle.cpp:23:26: error: 'long long int yn [300000]' redeclared as different kind of entity
   23 | int yp[300000], yn[300000], xp[300000], xn[300000];
      |                          ^
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from triangle.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:222:1: note: previous declaration 'double yn(int, double)'
  222 | __MATHCALL (yn,, (int, _Mdouble_));
      | ^~~~~~~~~~
triangle.cpp: In function 'int main()':
triangle.cpp:42:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   42 |     yn[-y]++;
      |          ^
triangle.cpp:42:10: warning: ISO C++ forbids incrementing a pointer of type 'double (*)(int, double) noexcept' [-Wpointer-arith]
   42 |     yn[-y]++;
      |     ~~~~~^
triangle.cpp:42:10: error: lvalue required as increment operand
   42 |     yn[-y]++;
      |          ^
triangle.cpp:51:78: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   51 |    ans += (xp[coordX[i]] + xn[coordX[i]] - 1) * (yp[coordY[i]] + yn[coordY[i]] - 1);
      |                                                                              ^
triangle.cpp:51:64: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   51 |    ans += (xp[coordX[i]] + xn[coordX[i]] - 1) * (yp[coordY[i]] + yn[coordY[i]] - 1);
      |                                                  ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
triangle.cpp:51:80: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   51 |    ans += (xp[coordX[i]] + xn[coordX[i]] - 1) * (yp[coordY[i]] + yn[coordY[i]] - 1);
      |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
triangle.cpp:51:47: error: invalid operands of types 'long long int' and 'double (*)(int, double) noexcept' to binary 'operator*'
   51 |    ans += (xp[coordX[i]] + xn[coordX[i]] - 1) * (yp[coordY[i]] + yn[coordY[i]] - 1);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                          |                                     |
      |                                          long long int                         double (*)(int, double) noexcept