제출 #131416

#제출 시각아이디문제언어결과실행 시간메모리
131416DodgeBallMan곤돌라 (IOI14_gondola)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>/ #include "gondola.h" #define pii pair<int, int> #define x first #define y second using namespace std; long long mod = 1e9 + 9; int valid( int n, int num[] ) { unordered_map<int,int> m; int st = 0; for( int i = 0 ; i < n ; i++ ) { if( m[num[i]] > 0 ) return 0; if( num[i] <= n && st == 0 ) st = num[i]; else if( num[i] <= n && st > 0 && st != num[i] ) return 0; if( st != 0 ) st = ( st % n ) + 1; m[num[i]]++; } return 1; } int replacement( int n, int num[], int se[] ) { vector<pii> all; int ori[250100]; memset( ori, -1, sizeof ori ); for( int i = 0 ; i < n ; i++ ) if( num[i] <= n ) { ori[i] = num[i] - 1; for( int j = i + 1 ; j < n ; j++ ) ori[j] = ( num[i] - 1 + j - i ) % n; for( int j = i - 1 ; j >= 0 ; j-- ) ori[j] = ( num[i] - 1 + n + j - i ) % n; break; } if( ori[0] == -1 ) for( int i = 0 ; i < n ; i++ ) ori[i] = i; for( int i = 0 ; i < n ; i++ ) ori[i]++; for( int i = 0 ; i < n ; i++ ) if( num[i] > n ) all.emplace_back( pii( num[i], ori[i] ) ); sort( all.begin(), all.end() ); int cnt = 0, fix = n + 1; for( int i = 0 ; i < all.size() ; i++ ) { int a, b; tie( a, b ) = all[i]; while( b != a ) { se[cnt] = b; b = fix; cnt++, fix++; } } return cnt; } long long modpow( long long base, long long power ) { long long ret = 1; for( ; power ; power >>= 1) { if( power & 1 ) ret = ( ret * base ) % M; base = ( base * base ) % M; } return ret; } int countReplacement( int n, int num[] ) { vector<int> all; if( !valid( n, num ) ) return 0; for( int i = 0 ; i < n ; i++ ) if( num[i] > n ) all.emplace_back( num[i] ); sort( all.begin(), all.end() ); now = n + 1; long long ret = 1; for( int i = 0 ; i < all.size() ; i++ ) { ret = (ret * modpow( ( int )v.size() - 1, v[i] - now ) ) % mod; now = v[i] + 1; } if( all.size() == n ) ret = ( ret * n ) % mod; return ( int )ret; } // int main() { // int n, se[100], num[100]; // scanf("%d",&n); // for( int i = 0 ; i < n ; i++ ) scanf("%d",&num[i]); // int x = countReplacement( n, num ); // printf("%d\n",x); // }

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

gondola.cpp:1:25: warning: extra tokens at end of #include directive
 #include <bits/stdc++.h>/
                         ^
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:39:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0 ; i < all.size() ; i++ ) {
                      ~~^~~~~~~~~~~~
gondola.cpp: In function 'long long int modpow(long long int, long long int)':
gondola.cpp:54:48: error: 'M' was not declared in this scope
         if( power & 1 ) ret = ( ret * base ) % M;
                                                ^
gondola.cpp:55:34: error: 'M' was not declared in this scope
         base = ( base * base ) % M;
                                  ^
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:64:5: error: 'now' was not declared in this scope
     now = n + 1;
     ^~~
gondola.cpp:64:5: note: suggested alternative: 'pow'
     now = n + 1;
     ^~~
     pow
gondola.cpp:66:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0 ; i < all.size() ; i++ ) {
                      ~~^~~~~~~~~~~~
gondola.cpp:67:37: error: 'v' was not declared in this scope
         ret = (ret * modpow( ( int )v.size() - 1, v[i] - now ) ) % mod;
                                     ^
gondola.cpp:70:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if( all.size() == n ) ret = ( ret * n ) % mod;
         ~~~~~~~~~~~^~~~