Submission #640249

#TimeUsernameProblemLanguageResultExecution timeMemory
640249makanhuliaZagrade (COI20_zagrade)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define db double #define pairll pair<ll,ll> #define lpairll pair<ll,pairll> #define repp(i,a,b) for (ll i = a; i <= b; i++) #define repz(i,a,b) for (ll i = a; i < b; i++) #define repm(i,a,b) for (ll i = a; i >= b; i--) #define fr first #define sc second #define mp make_pair #define pb push_back const ll N = 1e5+5, MOD = 1e9+7, M = 1e3+5; ll tc = 1, n, m, ar[N], br[N], str[M][M]; ll x, y, k, open = 0, close = 0; string s, s1, s2, ye = "YES", no = "NO"; vector<pairll> v; ll ask(ll l, ll r){ // if(ar[l] != -1 && ar[r] != -1 && (r-l) == 1){ // if (ar[l] == 0 && ar[r] == 1) return 1; // return 0; // } cout << "? " << l << " " << r << endl; ll dum; cin >> dum; return dum; }#include <bits/stdc++.h> using namespace std; #define ll long long #define db double #define pairll pair<ll,ll> #define lpairll pair<ll,pairll> #define repp(i,a,b) for (ll i = a; i <= b; i++) #define repz(i,a,b) for (ll i = a; i < b; i++) #define repm(i,a,b) for (ll i = a; i >= b; i--) #define fr first #define sc second #define mp make_pair #define pb push_back const ll N = 1e5+5, MOD = 1e9+7, M = 1e3+5; ll tc = 1, n, m, ar[N], br[N], str[M][M]; ll x, y, k, open = 0, close = 0; string s, s1, s2, ye = "YES", no = "NO"; vector<pairll> v; ll ask(ll l, ll r){ // if(ar[l] != -1 && ar[r] != -1 && (r-l) == 1){ // if (ar[l] == 0 && ar[r] == 1) return 1; // return 0; // } cout << "? " << l << " " << r << endl; ll dum; cin >> dum; return dum; } void input(){ cin >> n >> k; } void answ(){ cout << "! "; repp(i,1,n){ if (ar[i] == 0) cout << "("; else cout << ")"; } cout << endl; } void sub12(){ memset(str,-1,sizeof(str)); memset(ar,-1,sizeof(ar)); repp(i,1,n){ repp(j,i+1,n){ if ((j-i)%2){ str[i][j] = ask(i,j); if (str[i][j] == 1){ ar[i] = 0; ar[j] = 1; } } } } answ(); } void sub3(){ ll l = 1, r = n; memset(ar,-1,sizeof(ar)); while(l < r){ ll a1 = ask(l,r); if (a1 == 1){ ar[l] = 0; ar[r] = 1; l++; r--; continue; } else{ ll a2 = ask(l-1,l); //1 -> 0 1 //0 -> 0 0 if (a2 == 1){ ar[l] = 1; } else ar[l] = 0; //1 -> 0 1 //0 -> 1 1 ll a3 = ask(r,r+1); if (a3 == 1){ ar[r] = 0; } else ar[r] = 1; if (ar[l] && ar[r] == 0){ l++; r--; if (l < r){ ar[l] = 0; ar[r] = 1; l++; r--; } } else if (ar[l] && ar[r]){ l++; // if (l >= r) break; ar[l] = 0; l++; } else{ r--; // if (l >= r) break; ar[r] = 1; r--; } } } answ(); } void solve(){ if (n <= 1e3) sub12(); else sub3(); //answ(); } int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); //cin >> tc; while(tc--){ input(); solve(); } } void input(){ cin >> n >> k; } void answ(){ cout << "! "; repp(i,1,n){ if (ar[i] == 0) cout << "("; else cout << ")"; } cout << endl; } void sub12(){ memset(str,-1,sizeof(str)); memset(ar,-1,sizeof(ar)); repp(i,1,n){ repp(j,i+1,n){ if ((j-i)%2) str[i][j] = ask(i,j); if (str[i][j] == 1){ ar[i] = 0; ar[j] = 1; } } } answ(); } void sub3(){ ll l = 1, r = n; memset(ar,-1,sizeof(ar)); while(l < r){ ll a1 = ask(l,r); if (a1 == 1){ ar[l] = 0; ar[r] = 1; l++; r--; continue; } else{ ll a2 = ask(l-1,l); //1 -> 0 1 //0 -> 0 0 if (a2 == 1){ ar[l] = 1; } else ar[l] = 0; //1 -> 0 1 //0 -> 1 1 ll a3 = ask(r,r+1); if (a3 == 1){ ar[r] = 0; } else ar[r] = 1; if (ar[l] && ar[r] == 0){ l++; r--; if (l < r){ ar[l] = 0; ar[r] = 1; l++; r--; } } else if (ar[l] && ar[r]){ l++; // if (l >= r) break; ar[l] = 0; l++; } else{ r--; // if (l >= r) break; ar[r] = 1; r--; } } } answ(); } void solve(){ if (n <= 1e3) sub12(); else sub3(); //answ(); } int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); //cin >> tc; while(tc--){ input(); solve(); } }

Compilation message (stderr)

zagrade.cpp:31:2: error: stray '#' in program
   31 | }#include <bits/stdc++.h>
      |  ^
zagrade.cpp:31:3: error: 'include' does not name a type
   31 | }#include <bits/stdc++.h>
      |   ^~~~~~~
zagrade.cpp:47:10: error: redefinition of 'const long long int N'
   47 | const ll N = 1e5+5, MOD = 1e9+7, M = 1e3+5;
      |          ^
zagrade.cpp:17:10: note: 'const long long int N' previously defined here
   17 | const ll N = 1e5+5, MOD = 1e9+7, M = 1e3+5;
      |          ^
zagrade.cpp:47:21: error: redefinition of 'const long long int MOD'
   47 | const ll N = 1e5+5, MOD = 1e9+7, M = 1e3+5;
      |                     ^~~
zagrade.cpp:17:21: note: 'const long long int MOD' previously defined here
   17 | const ll N = 1e5+5, MOD = 1e9+7, M = 1e3+5;
      |                     ^~~
zagrade.cpp:47:34: error: redefinition of 'const long long int M'
   47 | const ll N = 1e5+5, MOD = 1e9+7, M = 1e3+5;
      |                                  ^
zagrade.cpp:17:34: note: 'const long long int M' previously defined here
   17 | const ll N = 1e5+5, MOD = 1e9+7, M = 1e3+5;
      |                                  ^
zagrade.cpp:48:4: error: redefinition of 'long long int tc'
   48 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |    ^~
zagrade.cpp:18:4: note: 'long long int tc' previously defined here
   18 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |    ^~
zagrade.cpp:48:12: error: redefinition of 'long long int n'
   48 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |            ^
zagrade.cpp:18:12: note: 'long long int n' previously declared here
   18 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |            ^
zagrade.cpp:48:15: error: redefinition of 'long long int m'
   48 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |               ^
zagrade.cpp:18:15: note: 'long long int m' previously declared here
   18 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |               ^
zagrade.cpp:48:18: error: redefinition of 'long long int ar [100005]'
   48 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |                  ^~
zagrade.cpp:18:18: note: 'long long int ar [100005]' previously declared here
   18 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |                  ^~
zagrade.cpp:48:25: error: redefinition of 'long long int br [100005]'
   48 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |                         ^~
zagrade.cpp:18:25: note: 'long long int br [100005]' previously declared here
   18 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |                         ^~
zagrade.cpp:48:32: error: redefinition of 'long long int str [1005][1005]'
   48 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |                                ^~~
zagrade.cpp:18:32: note: 'long long int str [1005][1005]' previously declared here
   18 | ll tc = 1, n, m, ar[N], br[N], str[M][M];
      |                                ^~~
zagrade.cpp:49:4: error: redefinition of 'long long int x'
   49 | ll x, y, k, open = 0, close = 0;
      |    ^
zagrade.cpp:19:4: note: 'long long int x' previously declared here
   19 | ll x, y, k, open = 0, close = 0;
      |    ^
zagrade.cpp:49:7: error: redefinition of 'long long int y'
   49 | ll x, y, k, open = 0, close = 0;
      |       ^
zagrade.cpp:19:7: note: 'long long int y' previously declared here
   19 | ll x, y, k, open = 0, close = 0;
      |       ^
zagrade.cpp:49:10: error: redefinition of 'long long int k'
   49 | ll x, y, k, open = 0, close = 0;
      |          ^
zagrade.cpp:19:10: note: 'long long int k' previously declared here
   19 | ll x, y, k, open = 0, close = 0;
      |          ^
zagrade.cpp:49:13: error: redefinition of 'long long int open'
   49 | ll x, y, k, open = 0, close = 0;
      |             ^~~~
zagrade.cpp:19:13: note: 'long long int open' previously defined here
   19 | ll x, y, k, open = 0, close = 0;
      |             ^~~~
zagrade.cpp:49:23: error: redefinition of 'long long int close'
   49 | ll x, y, k, open = 0, close = 0;
      |                       ^~~~~
zagrade.cpp:19:23: note: 'long long int close' previously defined here
   19 | ll x, y, k, open = 0, close = 0;
      |                       ^~~~~
zagrade.cpp:50:8: error: redefinition of 'std::string s'
   50 | string s, s1, s2, ye = "YES", no = "NO";
      |        ^
zagrade.cpp:20:8: note: 'std::string s' previously declared here
   20 | string s, s1, s2, ye = "YES", no = "NO";
      |        ^
zagrade.cpp:50:11: error: redefinition of 'std::string s1'
   50 | string s, s1, s2, ye = "YES", no = "NO";
      |           ^~
zagrade.cpp:20:11: note: 'std::string s1' previously declared here
   20 | string s, s1, s2, ye = "YES", no = "NO";
      |           ^~
zagrade.cpp:50:15: error: redefinition of 'std::string s2'
   50 | string s, s1, s2, ye = "YES", no = "NO";
      |               ^~
zagrade.cpp:20:15: note: 'std::string s2' previously declared here
   20 | string s, s1, s2, ye = "YES", no = "NO";
      |               ^~
zagrade.cpp:50:19: error: redefinition of 'std::string ye'
   50 | string s, s1, s2, ye = "YES", no = "NO";
      |                   ^~
zagrade.cpp:20:19: note: 'std::string ye' previously declared here
   20 | string s, s1, s2, ye = "YES", no = "NO";
      |                   ^~
zagrade.cpp:50:31: error: redefinition of 'std::string no'
   50 | string s, s1, s2, ye = "YES", no = "NO";
      |                               ^~
zagrade.cpp:20:31: note: 'std::string no' previously declared here
   20 | string s, s1, s2, ye = "YES", no = "NO";
      |                               ^~
zagrade.cpp:51:16: error: redefinition of 'std::vector<std::pair<long long int, long long int> > v'
   51 | vector<pairll> v;
      |                ^
zagrade.cpp:21:16: note: 'std::vector<std::pair<long long int, long long int> > v' previously declared here
   21 | vector<pairll> v;
      |                ^
zagrade.cpp:53:4: error: redefinition of 'long long int ask(long long int, long long int)'
   53 | ll ask(ll l, ll r){
      |    ^~~
zagrade.cpp:23:4: note: 'long long int ask(long long int, long long int)' previously defined here
   23 | ll ask(ll l, ll r){
      |    ^~~
zagrade.cpp:165:6: error: redefinition of 'void input()'
  165 | void input(){
      |      ^~~~~
zagrade.cpp:63:6: note: 'void input()' previously defined here
   63 | void input(){
      |      ^~~~~
zagrade.cpp:169:6: error: redefinition of 'void answ()'
  169 | void answ(){
      |      ^~~~
zagrade.cpp:67:6: note: 'void answ()' previously defined here
   67 | void answ(){
      |      ^~~~
zagrade.cpp:178:6: error: redefinition of 'void sub12()'
  178 | void sub12(){
      |      ^~~~~
zagrade.cpp:76:6: note: 'void sub12()' previously defined here
   76 | void sub12(){
      |      ^~~~~
zagrade.cpp:193:6: error: redefinition of 'void sub3()'
  193 | void sub3(){
      |      ^~~~
zagrade.cpp:93:6: note: 'void sub3()' previously defined here
   93 | void sub3(){
      |      ^~~~
zagrade.cpp:248:6: error: redefinition of 'void solve()'
  248 | void solve(){
      |      ^~~~~
zagrade.cpp:148:6: note: 'void solve()' previously defined here
  148 | void solve(){
      |      ^~~~~
zagrade.cpp:254:5: error: redefinition of 'int main()'
  254 | int main(){
      |     ^~~~
zagrade.cpp:154:5: note: 'int main()' previously defined here
  154 | int main(){
      |     ^~~~