Submission #409515

# Submission time Handle Problem Language Result Execution time Memory
409515 2021-05-21T02:54:01 Z maomao90 MalnaRISC (COI21_malnarisc) C++17
76.4122 / 100
2 ms 332 KB
    #include <bits/stdc++.h> 
    using namespace std;
     
    template <class T>
    inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
    template <class T>
    inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
    #define mnto(x, y) x = min(x, (__typeof__(x)) y)
    #define mxto(x, y) x = max(x, (__typeof__(x)) y)
    #define REP(i, s, e) for (int i = s; i < e; i++)
    #define RREP(i, s, e) for (int i = s; i >= e; i--)
    typedef long long ll;
    typedef long double ld;
    #define MP make_pair
    #define FI first
    #define SE second
    typedef pair<int, int> ii;
    typedef pair<ll, ll> pll;
    #define MT make_tuple
    typedef tuple<int, int, int> iii;
    #define ALL(_a) _a.begin(), _a.end()
    #define pb emplace_back
    typedef vector<int> vi;
    typedef vector<ii> vii;
     
    #define INF 1000000005
    #define LINF 1000000000000000005
    #define MOD 1000000007
    #define MAXN 200005
     
    int n;
    vector<vii> ans;
     
    int main() {
    	scanf("%d", &n);
    	REP (i, 0, n - 1) {
    		vii res;
    		for (int j = 1; j + 1 <= n; j += 2) {
    			res.pb(j, j + 1);
    		}
    		if (!res.empty()) ans.pb(res);
          	if (ans.size() >= n) break;
    		res.clear();
    		for (int j = 2; j + 1 <= n; j += 2) {
    			res.pb(j, j + 1);
    		}
    		if (!res.empty()) ans.pb(res);
          	if (ans.size() >= n) break;
    	}
    	printf("%d\n", (int) ans.size());
    	REP (i, 0, ans.size()) {
    		for (ii i : ans[i]) {
    			printf("CMPSWP R%d R%d ", i.FI, i.SE);
    		}
    		printf("\n");
    	}
    	return 0;
    }

Compilation message

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:42:27: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |            if (ans.size() >= n) break;
      |                ~~~~~~~~~~~^~~~
malnarisc.cpp:48:27: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |            if (ans.size() >= n) break;
      |                ~~~~~~~~~~~^~~~
malnarisc.cpp:10:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     #define REP(i, s, e) for (int i = s; i < e; i++)
......
   51 |      REP (i, 0, ans.size()) {
      |           ~~~~~~~~~~~~~~~~                  
malnarisc.cpp:51:6: note: in expansion of macro 'REP'
   51 |      REP (i, 0, ans.size()) {
      |      ^~~
malnarisc.cpp:35:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |      scanf("%d", &n);
      |      ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 332 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 332 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 332 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 332 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 332 KB Partially correct