제출 #549884

#제출 시각아이디문제언어결과실행 시간메모리
549884Pherokung세 명의 친구들 (BOI14_friends)C++14
0 / 100
15 ms7520 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const ll mod = 1e9+7, p = 10007; ll n,pw[200005],ans=-1,l[200005],r[200005],val; char s[200005]; ll mul(ll a,ll b) {return (a*b) % mod;} ll add(ll a,ll b) {return (a+b) % mod;} ll sub(ll a,ll b) {return (a-b+mod) % mod;} int main(){ scanf("%lld%s",&n,s+1); if(!(n%2)){ printf("NOT POSSIBLE"); return 0; } pw[0] = 1; for(int i=1;i<=n;i++) pw[i] = mul(pw[i-1],p); val = 0; for(int i=1;i<=n;i++){ val = mul(val,p), val = add(val,(s[i]-'A'+1)); l[i] = val; } val = 0; for(int i=n;i>=1;i--){ val = add(val,mul((s[i]-'A'+1),pw[n-i])); r[i] = val; } for(int i=1;i<=n;i++){ ll L = n/2, R = n/2+2, M = n/2+1; if(i <= L){ val = sub(l[M],mul(l[i],pw[M-i])); val = add(mul(l[i-1],pw[M-i]),val); if(val == r[R]){ if(ans == -1) ans = i; else{ printf("NOT UNIQUE"); return 0; } } } else if(i == M){ if(l[L] == r[R]){ if(ans == -1) ans = i; else{ printf("NOT UNIQUE"); return 0; } } } else if(i >= R){ val = sub(l[i-1],mul(l[M-1],pw[i-M])); ll xxx = val; val = add(mul(val,pw[n-i]),r[i+1]); if(l[L] == val){ if(ans == -1) ans = i; else{ printf("NOT UNIQUE"); return 0; } } } } if(ans == -1) printf("NOT POSSIBLE"); else{ ll cnt = n/2, pos = 1; while(cnt){ if(pos != ans){ printf("%c",s[pos]); cnt--; } pos++; } } }

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

friends.cpp: In function 'int main()':
friends.cpp:54:7: warning: unused variable 'xxx' [-Wunused-variable]
   54 |    ll xxx = val;
      |       ^~~
friends.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%lld%s",&n,s+1);
      |  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...