제출 #641700

#제출 시각아이디문제언어결과실행 시간메모리
641700Vladth11Chess Rush (CEOI20_chessrush)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " using namespace std; typedef long long ll; typedef pair <int, int> pii; const int NMAX = 100001; const int VMAX = 101; const int INF = 2e9; const int MOD = 1000000007; const int BLOCK = 447; const int base = 117; const int nr_of_bits = 24; const int inv2 = 500000004; constexpr int P = 1e9+7; int Add(int a, int b) { int ret = a%P; ret = (ret<0 ? P+ret : ret) + (b%P); return (ret>=0 ? ret%P : ret+P); } int Sub(int a, int b) { int ret = a%P; ret = (ret<0 ? P+ret : ret) - (b%P); return (ret>=0 ? ret%P : ret+P); } int Mul(int a, int b) { int ret = (1ll*(a%P) * (b%P)) % P; return (ret<0 ? P+ret : ret); } int modpow(int base, int exp, int modulus=P) { base %= modulus; int result = 1; while (exp > 0) { if (exp & 1) result = (1ll*result * base) % modulus; base = (1ll*base * base) % modulus; exp >>= 1; } return result; } int modinv(int a, int modulus=P) { return modpow(a,modulus-2); } int Div(int a, int b) { int ret = b%P; ret = (1ll*(a%P) * modinv(ret<0 ? P+ret : ret)) % P; return (ret<0 ? P+ret : ret); } int comb(int n, int k) { if(k < n - k) { k = n - k; } ll prod = 1, prod2 = 1; for(int i = k + 1; i <= n; i++) { prod *= i; prod %= MOD; prod2 *= (i - k); prod2 %= MOD; } return Div(prod, prod2); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int R, C, q; cin >> R >> C >> q; while(q--) { char T; cin >> T; int c1, cr; cin >> c1 >> cr; if(T =='P') { if(c1 == cr){ cout << R - 1 << " " << 1 << "\n"; }else{ cout << 0 << " " << 0 << "\n"; } }else if(T == 'R'){ if(c1 == cr){ cout << 1 << " " << 1 << "\n"; }else{ cout << 2 << " " << 2 << "\n"; } }else if(T == 'Q'){ pii start = {1, c1}; pii sfarsit = {R, cr}; if(start.second == sfarsit.second || sfarsit.first + sfarsit.second == start.first + start.second || sfarsit.first - sfarsit.second == start.first - start.second){ cout << 1 << " " << 1 << "\n"; }else{ int cnt = 2; for(int i = start.first, j = start.second; i > 0 && j > 0; i--, j--){ if(i + j == sfarsit.first + sfarsit.second || i - j == sfarsit.first - sfarsit.second || i == sfarsit.first || j == sfarsit.second){ cnt++; } } for(int i = start.first, j = start.second; i <= R && j > 0; i++, j--){ if(i + j == sfarsit.first + sfarsit.second || i - j == sfarsit.first - sfarsit.second || i == sfarsit.first || j == sfarsit.second) cnt++; } for(int i = start.first, j = start.second; i > 0 && j <= C; i--, j++){ if(i + j == sfarsit.first + sfarsit.second || i - j == sfarsit.first - sfarsit.second || i == sfarsit.first || j == sfarsit.second) cnt++; } for(int i = start.first, j = start.second; i <= R && j <= C; i++, j++){ if(i + j == sfarsit.first + sfarsit.second || i - j == sfarsit.first - sfarsit.second || i == sfarsit.first || j == sfarsit.second){ cnt++; } } swap(start, sfarsit); for(int i = start.first, j = start.second; i > 0 && j > 0; i--, j--){ if(i == sfarsit.first || j == sfarsit.second){ cnt++; } } for(int i = start.first, j = start.second; i <= R && j > 0; i++, j--){ if(i == sfarsit.first || j == sfarsit.second) cnt++; } for(int i = start.first, j = start.second; i > 0 && j <= C; i--, j++){ if(i == sfarsit.first || j == sfarsit.second) cnt++; } for(int i = start.first, j = start.second; i <= R && j <= C; i++, j++){ if(i == sfarsit.first || j == sfarsit.second){ cnt++; } } cout << 2 << " " << cnt << "\n"; } } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccWhS270.o: in function `Add(int, int)':
arithmetics.cpp:(.text+0x0): multiple definition of `Add(int, int)'; /tmp/ccyCs29Z.o:chessrush.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccWhS270.o: in function `Sub(int, int)':
arithmetics.cpp:(.text+0x80): multiple definition of `Sub(int, int)'; /tmp/ccyCs29Z.o:chessrush.cpp:(.text+0x80): first defined here
/usr/bin/ld: /tmp/ccWhS270.o: in function `Mul(int, int)':
arithmetics.cpp:(.text+0x100): multiple definition of `Mul(int, int)'; /tmp/ccyCs29Z.o:chessrush.cpp:(.text+0x100): first defined here
/usr/bin/ld: /tmp/ccWhS270.o: in function `modpow(int, int, int)':
arithmetics.cpp:(.text+0x190): multiple definition of `modpow(int, int, int)'; /tmp/ccyCs29Z.o:chessrush.cpp:(.text+0x190): first defined here
/usr/bin/ld: /tmp/ccWhS270.o: in function `modinv(int, int)':
arithmetics.cpp:(.text+0x1f0): multiple definition of `modinv(int, int)'; /tmp/ccyCs29Z.o:chessrush.cpp:(.text+0x1f0): first defined here
/usr/bin/ld: /tmp/ccWhS270.o: in function `Div(int, int)':
arithmetics.cpp:(.text+0x290): multiple definition of `Div(int, int)'; /tmp/ccyCs29Z.o:chessrush.cpp:(.text+0x290): first defined here
collect2: error: ld returned 1 exit status