제출 #107566

#제출 시각아이디문제언어결과실행 시간메모리
107566dfistric세 명의 친구들 (BOI14_friends)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define FORd(i, a, b) for (int i = (a); i >= (b); i--) #define REP(i, n) FOR(i, 0, n) #define ll long long using namespace std; const int MAXN = 2001000; ll ha[MAXN], pot[MAXN]; const int BASE = 35537, MOD = 1e9 + 7; ll val(int x, int y) { if (y < x) return 0; ll out = ha[y]; if (x) out = (((out - ha[x - 1] * pot[y - x + 1]) % MOD) + MOD) % MOD; return out; } int main() { ios_base::sync_with_stdio(false); pot[0] = 1; FOR(i, 1, MAXN) pot[i] = (pot[i - 1] * BASE) % MOD; int n; cin >> n; string s; cin >> s; ll curr = 0; REP(i, n) { curr = (curr * BASE + s[i]) % MOD; ha[i] = curr; } string out = ""; ll val = -1; REP(i, n) { if (i <= n / 2) { ll a = (val(0, i - 1) * pot[n / 2 - i] + val(i + 1, n / 2)) % MOD; ll b = val(n / 2 + 1, n - 1); if (a != b) continue; string curr = s.substr(n / 2 + 1, n / 2); if (out != "" && val != a) { cout << "NOT UNIQUE\n"; return 0; } else { val = a; out = curr; } } else { ll a = val(0, n / 2 - 1); ll b = (val(n / 2, i - 1) * pot[n - i - 1] + val(i + 1, n - 1)) % MOD; if (a != b) continue; string curr = s.substr(0, n / 2 - 1); if (out != "" && val != a) { cout << "NOT UNIQUE\n"; return 0; } else { val = a; out = curr; } } } if (out == "") cout << "NOT POSSIBLE\n"; else cout << out << "\n"; return 0; }

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

friends.cpp: In function 'int main()':
friends.cpp:42:33: error: 'val' cannot be used as a function
             ll a = (val(0, i - 1) * pot[n / 2 - i] + val(i + 1, n / 2)) % MOD;
                                 ^
friends.cpp:42:70: error: 'val' cannot be used as a function
             ll a = (val(0, i - 1) * pot[n / 2 - i] + val(i + 1, n / 2)) % MOD;
                                                                      ^
friends.cpp:43:40: error: 'val' cannot be used as a function
             ll b = val(n / 2 + 1, n - 1);
                                        ^
friends.cpp:57:36: error: 'val' cannot be used as a function
             ll a = val(0, n / 2 - 1);
                                    ^
friends.cpp:58:37: error: 'val' cannot be used as a function
             ll b = (val(n / 2, i - 1) * pot[n - i - 1] + val(i + 1, n - 1)) % MOD;
                                     ^
friends.cpp:58:74: error: 'val' cannot be used as a function
             ll b = (val(n / 2, i - 1) * pot[n - i - 1] + val(i + 1, n - 1)) % MOD;
                                                                          ^