Submission #131407

#TimeUsernameProblemLanguageResultExecution timeMemory
131407DodgeBallManGondola (IOI14_gondola)C++14
55 / 100
26 ms4116 KiB
#include <bits/stdc++.h>/ #include "gondola.h" #define pii pair<int, int> #define x first #define y second using namespace std; 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++ ) printf("%d ",ori[i]); // printf("\n"); 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; } int countReplacement( int n, int num[] ) { return 0; } // int main() { // int n, se[100], num[100]; // scanf("%d",&n); // for( int i = 0 ; i < n ; i++ ) scanf("%d",&num[i]); // memset( se, 0, sizeof se ); // int x = replacement( n, num, se ); // printf("%d\n",x); // for( int i = 0 ; i < x ; i++ ) printf("%d ",se[i]); // }

Compilation message (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++ ) {
                      ~~^~~~~~~~~~~~
#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...
#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...