제출 #567224

#제출 시각아이디문제언어결과실행 시간메모리
567224tqbfjotldMisspelling (JOI22_misspelling)C++14
8 / 100
157 ms8852 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int rel[20]; int A[500005]; int B[500005]; int mem[20][26]; int func(int n, int last){ if (mem[n][last]!=-1) return mem[n][last]; if (n==1) return 1; if (rel[n-2]==1){ return mem[n][last] = func(n-1,last); } int ans = 0; for (int x = 0; x<26; x++){ if (rel[n-2]==0 && last>x){ ans += func(n-1,x); } if (rel[n-2]==2 && last<x){ ans += func(n-1,x); } ans %= 1000000007; } return mem[n][last] = ans; } main(){ int n,m; scanf("%lld%lld",&n,&m); for (int x = 0; x<m; x++){ scanf("%lld%lld",&A[x],&B[x]); A[x]--; B[x]--; } int ans = 0; for (int x = 0; x<(int)pow(3,n-1); x++){ int t = x; for (int y = 0; y<n-1; y++){ rel[y] = t%3; //printf("%lld ",rel[y]); t/=3; } //printf("\n"); bool can = true; for (int y = 0; y<m; y++){ if (A[y]<B[y]){ for (int z = 0; z<B[y]-A[y]; z++){ if (rel[A[y]+z]==0){ can = false; break; } if (rel[A[y]+z]==2){ break; } } } else{ for (int z = 0; z<A[y]-B[y]; z++){ if (rel[B[y]+z]==2){ can = false; break; } if (rel[B[y]+z]==0){ break; } } } } if (can){ //printf("hi\n"); memset(mem,-1,sizeof(mem)); for (int x = 0; x<26; x++){ ans += func(n,x); ans %= 1000000007; } } } printf("%lld",ans); }

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

misspelling.cpp:30:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 |  main(){
      |  ^~~~
misspelling.cpp: In function 'int main()':
misspelling.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
misspelling.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         scanf("%lld%lld",&A[x],&B[x]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...