Submission #1285990

#TimeUsernameProblemLanguageResultExecution timeMemory
1285990aritro_Gondola (IOI14_gondola)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using ordset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; /* less<T> can be changed to: 1. less_equal<T> 2. greater<T> ordered_set functions: 1. *(os.find_by_order(x)) -> return the value at position x (0 base) 2. os.order_of_key(x) -> return the number of elements less than x */ typedef long long ll; //#define int ll #define endl '\n' #define pb push_back #define ff first #define ss second #define all(a) a.begin(),a.end() const int MOD=1000000007; #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define fios(); ios_base::sync_with_stdio(0);cin.tie(0); #define fraction(x); cout.unsetf(ios::floatfield); cout.precision(x); cout.setf(ios::fixed,ios::floatfield); #define file(); freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); bool valid(int n,vector<int>arr){ //subtask 1 int a[n*2]; for(int i=0;i<n;i++) a[i]=arr[i]; for(int i=n;i<n*2;i++) a[i]=arr[i-n]; int cur=1; bool b=0; for(int i=0;i<n*2;i++){ if(cur==n+1) break; if(a[i]==1&&b==0){ b=1; cur++; } else if(a[i]==cur) cur++; else if(a[i]!=cur&&b==1) return 0; if(cur==n+1) break; } return 1; } void solve(){ int n; cin>>n; vector<int> a(n); for(int i=0;i<n;i++) cin>>a[i]; cout<<valid(n,a)<<endl; return; } int32_t main(){ fios(); //file(); int t=1; cin>>t; for(int tc=1;tc<=t;tc++){ //cout<<"Case "<<tc<<": "; solve(); } return 0; }

Compilation message (stderr)

gondola.cpp: In function 'bool valid(int, std::vector<int>)':
gondola.cpp:41:32: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' writing between 12884901888 and 17179869180 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
   41 |     for(int i=n;i<n*2;i++) a[i]=arr[i-n];
gondola.cpp:39:9: note: at offset [-4294967296, -4] into destination object 'a' of size [0, 9223372036854775807]
   39 |     int a[n*2];
      |         ^
/usr/bin/ld: /tmp/ccWLNIGV.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cckCV4x5.o:gondola.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccWLNIGV.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `valid'
/usr/bin/ld: grader.cpp:(.text.startup+0xfc): undefined reference to `replacement'
/usr/bin/ld: grader.cpp:(.text.startup+0x18d): undefined reference to `countReplacement'
collect2: error: ld returned 1 exit status