Submission #442816

# Submission time Handle Problem Language Result Execution time Memory
442816 2021-07-09T07:50:52 Z ivandasfs Sob (COCI19_sob) C++14
0 / 110
50 ms 5616 KB
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;

const ll INF = 1e9+5;
const ll MOD = 1e9+7;

vector <int> b;

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=m ; i<n+m ; i++) {
		b.pb(i);
	}
	int l = 0;
	for (int i=20 ; i>=0 ; i--) {
		int p = (1<<i);
		if (n >= p) {
		//	cout <<"p = "<<p<<endl;
			int st = 0;
			int cnt = 0;
			for (int j=0 ; j<b.size() ; j++) {
				if ((b[j]&p) == 0) {
					cnt++;
					if (cnt == p) {
						st = j - p + 1;
						break;
					}
				} else cnt = 0;
			}
			if (cnt == p) {
			//	cout <<"A\n";
				for (int j=0 ; j<p ; j++) {
					printf("%d %d\n", l, b[st+j]);
					l++;
				}
				vector <int> nb;
				for (int j=0 ; j<b.size() ; j++) {
					if (j<st or j>=st+p) nb.pb(b[j]);
				}
				b = nb;
			} else {
			//	cout <<"B\n";
				cnt = 0;
				for (int j=0 ; j<b.size() ; j++) {
					if (b[j] % p == 0) st = j;
				}
				if (b[b.size()-1] & p) st = b.size();
				for (int j=st ; j<b.size() ; j++) {
					printf("%d %d\n", l, b[j]);
					l++;
					cnt++;
				}
				int pos;
				for (int j=0 ; j<st ; j++) {
					if (b[j]%p == l%p) pos = j;
				}
				while (b[pos]%p != b[0]%p) {
					printf("%d %d\n", l, b[pos]);
					l++;
					cnt++;
					pos++;
				}
				int j = 0;
				for ( ; cnt<p ; j++) {
					printf("%d %d\n", l, b[j]);
					l++;
					cnt++;
				}
				vector <int> nb;
				for (j++ ; j<pos ; j++) nb.pb(b[j]);
				for (j=pos ; j<st ; j++) nb.pb(b[j]);
				b = nb;
			}
			n -= p;
		}
	}
	return 0;
}

Compilation message

sob.cpp: In function 'int main()':
sob.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for (int j=0 ; j<b.size() ; j++) {
      |                   ~^~~~~~~~~
sob.cpp:54:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int j=0 ; j<b.size() ; j++) {
      |                    ~^~~~~~~~~
sob.cpp:61:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for (int j=0 ; j<b.size() ; j++) {
      |                    ~^~~~~~~~~
sob.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (int j=st ; j<b.size() ; j++) {
      |                     ~^~~~~~~~~
sob.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
sob.cpp:70:9: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   70 |     int pos;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Runtime error 50 ms 5616 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Runtime error 50 ms 5616 KB Execution killed with signal 11